GraphTheory
IsReachable
determine if there is a path between two vertices
Calling Sequence
Parameters
Options
Description
Definition
Examples
Compatibility
IsReachable(G, u, v)
IsReachable(G, u, v, opts)
G
-
graph
u, v
vertices of the graph
opts
(optional) one or more options as specified below
distance=integer or infinity
Specifies that the output should be limited to vertices reachable from v in the specified number of steps. Default is infinity.
IsReachable(G, u, v) returns a true when the vertex v is reachable from u in the graph G.
To produce an actual path (or directed path when G is directed) from u to v, use BellmanFordAlgorithm, DijkstrasAlgorithm, or ShortestPath.
To find all vertices reachable from u, use Reachable.
If G is an undirected graph, a vertex w is said to be reachable from a vertex v if there exists a path in G between v and w. This is true if and only if they are in the same connected component.
If G is a directed graph, a vertex w is said to be reachable from a vertex v if there exists a directed path in G from v to w.
withGraphTheory:
C6≔CycleGraph6
C6≔Graph 1: an undirected graph with 6 vertices and 6 edges
IsReachableC6,1,5
true
ShortestPathC6,1,5
1,6,5
With the following example we see that the reachability relation is not symmetric for directed graphs.
DP4≔GraphA,B,C,D,A,B,B,C,C,D
DP4≔Graph 2: a directed graph with 4 vertices and 3 arcs
IsReachableDP4,A,D
ShortestPathDP4,A,D
A,B,C,D
IsReachableDP4,D,A
false
The GraphTheory[IsReachable] command was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
The GraphTheory[IsReachable] command was updated in Maple 2025.
The distance option was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
BellmanFordAlgorithm
DijkstrasAlgorithm
Reachable
ShortestPath
Download Help Document