GraphUtilities`
GraphUtilities`

GraphPath

As of Version 10, all the functionality of the GraphUtilities package is built into the Wolfram System. »

GraphPath[g,start,end]

finds a shortest path between vertices start and end in graph g.

Details and Options

Examples

open allclose all

Basic Examples  (2)

This defines a small directed graph:

This finds the shortest path from vertex 1 to vertex 3:

This finds the shortest path from vertex 1 to vertex 3, ignoring the edge weights:

GraphPath has been superseded by FindShortestPath:

Options  (1)

Method  (1)

This defines a small graph:

Because of the negative edge weight, the Dijkstra algorithm cannot be applied:

The BellmanFord algorithm works:

This defines a small graph with a negative cycle:

The Dijkstra algorithm does not work for negative edge weights:

The BellmanFord algorithm detects a negative weight cycle:

The default algorithm for graphs with negative edge weights is BellmanFord:

Properties & Relations  (1)

This defines a small directed graph:

This finds the shortest path from vertex 1 to 3:

This finds the distance of this path, taking into account the edge weights:

This finds the distance of this path, ignoring the edge weights:

Possible Issues  (1)

This defines a small directed graph:

If there are negative edge weights, the "Dijkstra" method cannot be used:

This finds the shortest path from vertex 1 to vertex 3 using the "BellmanFord" method:

Interactive Examples  (1)

This shows how to travel from vertex 1 to 7 through the shortest path:

Wolfram Research (2007), GraphPath, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/GraphPath.html.

Text

Wolfram Research (2007), GraphPath, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/GraphPath.html.

CMS

Wolfram Language. 2007. "GraphPath." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/GraphPath.html.

APA

Wolfram Language. (2007). GraphPath. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/GraphPath.html

BibTeX

@misc{reference.wolfram_2024_graphpath, author="Wolfram Research", title="{GraphPath}", year="2007", howpublished="\url{https://reference.wolfram.com/language/GraphUtilities/ref/GraphPath.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_graphpath, organization={Wolfram Research}, title={GraphPath}, year={2007}, url={https://reference.wolfram.com/language/GraphUtilities/ref/GraphPath.html}, note=[Accessed: 21-November-2024 ]}