Class FloydWarshallAPSP<N,​E>

  • Type Parameters:
    N - node class
    E - edge class
    All Implemented Interfaces:
    APSPResult<N,​E>

    public class FloydWarshallAPSP<N,​E>
    extends Object
    implements APSPResult<N,​E>
    Implementation of the Floyd-Warshall dynamic programming algorithm for the all pairs shortest paths problem.
    • Constructor Detail

    • Method Detail

      • findAPSP

        public void findAPSP()
      • getShortestPathDistance

        public float getShortestPathDistance​(N src,
                                             N tgt)
        Description copied from interface: APSPResult
        Retrieves the length of the shortest path between the given nodes.
        Specified by:
        getShortestPathDistance in interface APSPResult<N,​E>
        Parameters:
        src - the source node
        tgt - the target node
        Returns:
        the length of the shortest path from src to tgt, or Graphs.INVALID_DISTANCE if there exists no such path.
      • getShortestPath

        public @Nullable List<E> getShortestPath​(N src,
                                                 N tgt)
        Description copied from interface: APSPResult
        Retrieves the shortest path between the given nodes, or null if there exists no such path.
        Specified by:
        getShortestPath in interface APSPResult<N,​E>
        Parameters:
        src - the source node
        tgt - the target node
        Returns:
        the shortest path from src to tgt, or null if there exists no such path.