org.jgrapht.alg

## Class FloydWarshallShortestPaths<V,E>

- java.lang.Object
- - org.jgrapht.alg.FloydWarshallShortestPaths<V,E>

-     public class FloydWarshallShortestPaths<V,E>
      extends Object

  The Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in O(n^3) time. It can also calculate the graph diameter. Note that during construction time, no computations are performed! All computations are performed the first time one of the member methods of this class is invoked. The results are stored, so all subsequent calls to the same method are computationally efficient. Warning: This code has not been tested (and probably doesn't work) on multi-graphs. Code should be updated to work properly on multi-graphs.
  Author:
    Tom Larkworthy, Soren Davidsen (soren@tanesha.net), Joris Kinable

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FloydWarshallShortestPaths(Graph<V,E> graph)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getDiameter()`
    `Graph<V,E>` | `getGraph()`
    `GraphPath<V,E>` | `getShortestPath(V a, V b)` Get the shortest path between two vertices.
    `List<V>` | `getShortestPathAsVertexList(V a, V b)`
    `List<GraphPath<V,E>>` | `getShortestPaths()` Get all shortest paths in the graph.
    `List<GraphPath<V,E>>` | `getShortestPaths(V v)` Get shortest paths from a vertex to all other vertices in the graph.
    `int` | `getShortestPathsCount()`
    `double` | `shortestDistance(V a, V b)` Get the length of a shortest path.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FloydWarshallShortestPaths

          public FloydWarshallShortestPaths(Graph<V,E> graph)

  - ### Method Detail

    - #### getGraph

          public Graph<V,E> getGraph()

      Returns:
        the graph on which this algorithm operates

    - #### getShortestPathsCount

          public int getShortestPathsCount()

      Returns:
        total number of shortest paths

    - #### shortestDistance

          public double shortestDistance(V a,
                                V b)

      Get the length of a shortest path.
      Parameters:
        `a` - first vertex
        `b` - second vertex
      Returns:
        shortest distance between a and b

    - #### getDiameter

          public double getDiameter()

      Returns:
        the diameter (longest of all the shortest paths) computed for the graph. If the graph is vertexless, return 0.0.

    - #### getShortestPath

          public GraphPath<V,E> getShortestPath(V a,
                                       V b)

      Get the shortest path between two vertices.
      Parameters:
        `a` - From vertice
        `b` - To vertice
      Returns:
        the path, or null if none found

    - #### getShortestPathAsVertexList

          public List<V> getShortestPathAsVertexList(V a,
                                            V b)

    - #### getShortestPaths

          public List<GraphPath<V,E>> getShortestPaths(V v)

      Get shortest paths from a vertex to all other vertices in the graph.
      Parameters:
        `v` - the originating vertex
      Returns:
        List of paths

    - #### getShortestPaths

          public List<GraphPath<V,E>> getShortestPaths()

      Get all shortest paths in the graph.
      Returns:
        List of paths

Copyright © 2016. All rights reserved.