Package it.univr.di.cstnu.util
Class GraphDistancesImpl
java.lang.Object
it.univr.di.cstnu.util.GraphDistancesImpl
- All Implemented Interfaces:
GraphDistances
Implementation based on two nested hash maps.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetDistance(LabeledNode source, LabeledNode destination) it.unimi.dsi.fastutil.objects.ObjectSet<LabeledNode> getNodes()it.unimi.dsi.fastutil.objects.Object2IntMap<LabeledNode> getReachable(LabeledNode node) voidputDistance(LabeledNode source, LabeledNode destination, int distance) Sets the new distance between a source node and the destination node.voidputDistances(LabeledNode source, it.unimi.dsi.fastutil.objects.Object2IntMap<LabeledNode> destinations) Sets the new distance between a source node and all destination nodes in destinations.voidremoveDistance(LabeledNode source, LabeledNode destination) Remove the distance between source node and destination one.toString()
-
Constructor Details
-
GraphDistancesImpl
public GraphDistancesImpl()Default constructor
-
-
Method Details
-
getDistance
- Specified by:
getDistancein interfaceGraphDistances- Parameters:
source- the source nodedestination- the destination node- Returns:
- the distance between a source node and the destination one if a finite distance exists, +∞ otherwise
-
getNodes
- Specified by:
getNodesin interfaceGraphDistances- Returns:
- the source nodes present in the matrix, if any, an empty list otherwise.
-
getReachable
public it.unimi.dsi.fastutil.objects.Object2IntMap<LabeledNode> getReachable(@Nonnull LabeledNode node) - Specified by:
getReachablein interfaceGraphDistances- Parameters:
node- the node- Returns:
- the map (node, distance) of nodes reachable from 'node' if there are any, an empty set otherwise.
-
putDistance
public void putDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination, int distance) Description copied from interface:GraphDistancesSets the new distance between a source node and the destination node.- Specified by:
putDistancein interfaceGraphDistances- Parameters:
source- the source node.destination- the destination node.distance- the new distance between source and destination.
-
putDistances
public void putDistances(@Nonnull LabeledNode source, @Nonnull it.unimi.dsi.fastutil.objects.Object2IntMap<LabeledNode> destinations) Description copied from interface:GraphDistancesSets the new distance between a source node and all destination nodes in destinations. All previous nodes reachable by the source are removed.- Specified by:
putDistancesin interfaceGraphDistances- Parameters:
source- the source node.destinations- a map of all (reachable destination, distance) from the source node.
-
removeDistance
Description copied from interface:GraphDistancesRemove the distance between source node and destination one.- Specified by:
removeDistancein interfaceGraphDistances- Parameters:
source- the source nodedestination- the destination node
-
toString
-