Close
Close window
IsReachable - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

GraphTheory

IsReachable

determine if there is a path between two vertices

Calling Sequence

IsReachable(G, u, v)

IsReachable(G, u, v, opts)

Parameters

G

-

graph

u, v

-

vertices of the graph

opts

-

(optional) one or more options as specified below

Options

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.

Description

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 .

Definition

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.

Examples

>

withGraphTheory:

>

C6CycleGraph6

C6Graph 1: an undirected graph with 6 vertices and 6 edges

(1)
>

IsReachableC6,1,5

true

(2)
>

ShortestPathC6,1,5

1,6,5

(3)

With the following example we see that the reachability relation is not symmetric for directed graphs.

>

DP4GraphA,B,C,D,A,B,B,C,C,D

DP4Graph 2: a directed graph with 4 vertices and 3 arcs

(4)
>

IsReachableDP4,A,D

true

(5)
>

ShortestPathDP4,A,D

A,B,C,D

(6)
>

IsReachableDP4,D,A

false

(7)

Compatibility

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 .


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /