Class GraphDistancesImpl

java.lang.Object
it.univr.di.cstnu.util.GraphDistancesImpl
All Implemented Interfaces:
GraphDistances

public class GraphDistancesImpl extends Object implements GraphDistances
Implementation based on two nested hash map.
  • Constructor Details

    • GraphDistancesImpl

      public GraphDistancesImpl()
      Default constructor
  • Method Details

    • getDistance

      public int getDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination)
      Specified by:
      getDistance in interface GraphDistances
      Parameters:
      source - the source node
      destination - the destination node
      Returns:
      the distance between source node and destination one if a finite distance exists, +∞ otherwise
    • getNodes

      public it.unimi.dsi.fastutil.objects.ObjectSet<LabeledNode> getNodes()
      Specified by:
      getNodes in interface GraphDistances
      Returns:
      the source nodes present in the matrix if any, empty list otherwise.
    • getReachable

      public it.unimi.dsi.fastutil.objects.Object2IntMap<LabeledNode> getReachable(@Nonnull LabeledNode node)
      Specified by:
      getReachable in interface GraphDistances
      Parameters:
      node - the node
      Returns:
      the map (node, distance) of nodes reachable from 'node' if there are any, empty set otherwise.
    • putDistance

      public void putDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination, int distance)
      Description copied from interface: GraphDistances
      Sets the new distance between source node and destination one.
      Specified by:
      putDistance in interface GraphDistances
      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: GraphDistances
      Sets the new distance between source node and all destination nodes in destinations. All previous nodes reachable by source are removed.
      Specified by:
      putDistances in interface GraphDistances
      Parameters:
      source - the source node.
      destinations - a map of all (reachable destination, distance) from source node.
    • removeDistance

      public void removeDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination)
      Description copied from interface: GraphDistances
      Remove the distance between source node and destination one.
      Specified by:
      removeDistance in interface GraphDistances
      Parameters:
      source - the source node
      destination - the destination node
    • toString

      public String toString()
      Overrides:
      toString in class Object