AllPairsDistance - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


GraphTheory

  

AllPairsDistance

  

all-pairs shortest paths in a graph

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

AllPairsDistance(G)

Parameters

G

-

graph

Description

• 

The AllPairsDistance command returns a square matrix A where  is the distance from vertex i to vertex j in the graph G, that is, the length of the shortest path from vertex i to vertex j.  If G is not a weighted graph, then edges have weight 1. If there is no path, then the distance is infinite and .

• 

This procedure is an implementation of the Floyd-Warshall all-pairs shortest path algorithm.  The complexity is  where n is the number of vertices of G.

• 

To compute distances or shortest paths from a single vertex to every other vertex, use either DijkstrasAlgorithm or BellmanFordAlgorithm because they are more efficient.

Examples

(1)

(2)

(3)

(4)

(5)

See Also

BellmanFordAlgorithm

Diameter

DijkstrasAlgorithm

Distance

Trail

 


Download Help Document