GraphTheory[Distance]
|
Calling Sequence
|
|
Distance(G, s, t)
|
|
Parameters
|
|
G
|
-
|
graph
|
s, t
|
-
|
vertices of the graph
|
|
|
|
|
Description
|
|
•
|
Distance returns the number of edges in the shortest path from s to t. If no such path exists, the output is infinity. The strategy is to use a breadth-first search (BFS).
|
•
|
To find a path from s to t with minimum distance use the ShortestPath command.
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
|
|
Download Help Document
Was this information helpful?