package it.univr.di.cstnu.util; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.ObjectSet; import it.univr.di.cstnu.graph.LabeledNode; import javax.annotation.Nonnull; /** * This interface defines the methods for managing distances between nodes in a graph. It is designed to represent all-pairs-shortest-paths distances. */ @SuppressWarnings("InterfaceWithOnlyOneDirectInheritor") public interface GraphDistances { /** * @param source the source node * @param destination the destination node * * @return the distance between a source node and the destination one if a finite distance exists, +∞ otherwise */ int getDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination); /** * @return the source nodes present in the matrix, if any, an empty list otherwise. */ ObjectSet getNodes(); /** * @param node the node * * @return the map (node, distance) of nodes reachable from 'node' if there are any, an empty set otherwise. */ Object2IntMap getReachable(@Nonnull LabeledNode node); /** * Sets the new distance between a source node and the destination node. * * @param source the source node. * @param destination the destination node. * @param distance the new distance between source and destination. */ void putDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination, int distance); /** * Sets the new distance between a source node and all destination nodes in destinations. All previous nodes reachable by the source are removed. * * @param source the source node. * @param destinations a map of all (reachable destination, distance) from the source node. */ void putDistances(@Nonnull LabeledNode source, @Nonnull Object2IntMap destinations); /** * Remove the distance between source node and destination one. * * @param source the source node * @param destination the destination node */ void removeDistance(@Nonnull LabeledNode source, @Nonnull LabeledNode destination); }