Is there any efficient algorithm to find shortest distance between all pairs of vertices?
The graph is:
- Sparse (each vertex has either 2 or 3 edge)
Since Floyd-Warshall algorithm and Johnson's algorithm are best for finding shortest path for every pairs but:
- Johnson's algorithm works on directed
- Floyd-Warshall algorithm is best for dense graphs
I couldn't find any algo that is efficient for above graph conditions.