Class BaseShortestPathAlgorithm<V,​E>

    • Field Detail

      • graph

        protected final Graph<V,​E> graph
    • Constructor Detail

      • BaseShortestPathAlgorithm

        public BaseShortestPathAlgorithm​(Graph<V,​E> graph)
        Constructs a new instance of the algorithm for a given graph.
        Parameters:
        graph - the graph
    • Method Detail

      • getPathWeight

        public double getPathWeight​(V source,
                                    V sink)
        Get the weight of the shortest path from a source vertex to a sink vertex. Returns Double.POSITIVE_INFINITY if no path exists.
        Specified by:
        getPathWeight in interface ShortestPathAlgorithm<V,​E>
        Parameters:
        source - the source vertex
        sink - the sink vertex
        Returns:
        the weight of the shortest path from a source vertex to a sink vertex, or Double.POSITIVE_INFINITY if no path exists
      • createEmptyPath

        protected final GraphPath<V,​E> createEmptyPath​(V source,
                                                             V sink)
        Create an empty path. Returns null if the source vertex is different than the target vertex.
        Parameters:
        source - the source vertex
        sink - the sink vertex
        Returns:
        an empty path or null null if the source vertex is different than the target vertex