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

Online Help

All Products    Maple    MapleSim


GraphTheory

  

ShortestAncestralPath

  

determine shortest ancestral path in digraph

  

ShortestDescendantPath

  

determine shortest descendant path in digraph

 

Calling Sequence

Parameters

Options

Description

Definition

Examples

Compatibility

Calling Sequence

ShortestAncestralPath(G, u, v, opts)

ShortestAncestralPath(G, C, opts)

ShortestDescendantPath(G, u, v, opts)

ShortestDescendantPath(G, C, opts)

Parameters

G

-

graph

u, v

-

vertices of the graph

C

-

list or set of vertices of the graph

opts

-

(optional) one or more options as specified below

Options

• 

avoidvertices=list or set

  

Specifies vertices to avoid in building a path.

  

If vertices are specified here, the resulting path may not be shortest in G.

• 

distance=truefalse

  

Specifies whether to return the distance along with the shortest path.

  

If true, each element of the list output of ShortestPath will be a two-element list, the first element of which is the path and the second of which is the weighted path distance to the common ancestor.

• 

ignoreweights=truefalse

  

Specifies whether to ignore edge weights if present. The default is false.

Description

• 

ShortestAncestralPath(G,u,v) returns a shortest ancestral path of u and v in the directed graph G.

• 

ShortestAncestralPath(G,C) returns a shortest ancestral path of the vertices C in the directed graph G.

• 

ShortestDescendantPath(G,u,v) returns a shortest descendant path of u and v in the directed graph G.

• 

ShortestDescendantPath(G,C) returns a shortest descendant path of the vertices C in the directed graph G.

Definition

• 

A vertex u is a common ancestor of a set C of vertices of G if it is an ancestor of each vertex in C.

• 

If G is a directed graph and u and v are vertices of G, an ancestral path of u and v is a pair (p,q) where p is a directed path from w to u, and q is a directed path from w to v, where w is an ancestor of both u and v.

• 

A shortest ancestral path of u and v is an ancestral path of minimum length over all common ancestors, where the length is defined as the sum of the lengths of the two directed paths from a common ancestor to u and to v respectively.

• 

A descendant path and shortest descendant path is defined analogously for descendants.

Examples

In this example, 1, 2, and 4 are all common ancestors of 5 and 6, but the shortest ancestral path is to vertex 4.

withGraphTheory:

GGraphTheory:-Graph6,1,2,2,3,2,5,3,4,3,6,4,5,4,6

GGraph 1: a directed graph with 6 vertices and 7 arcs

(1)

DrawGraphG,style=tree

ShortestAncestralPathG,5,6

4,5,4,6

(2)

We can however explicitly avoid paths through vertex 4, in which case a path through vertex 2 is chosen.

ShortestAncestralPathG,5,6,avoidvertices=4

2,5,2,3,6

(3)

Compatibility

• 

The GraphTheory[ShortestAncestralPath] and GraphTheory[ShortestDescendantPath] commands were introduced in Maple 2025.

• 

For more information on Maple 2025 changes, see Updates in Maple 2025.

See Also

Ancestors

LowestCommonAncestors

MinimalSpanningTree

SpanningTree