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

Online Help

All Products    Maple    MapleSim


GraphTheory

  

LowestCommonAncestors

  

determine lowest common ancestors of digraph vertices

  

LowestCommonDescendants

  

determine lowest common descendants of digraph vertices

 

Calling Sequence

Parameters

Options

Description

Definition

Examples

Compatibility

Calling Sequence

LowestCommonAncestors(G, u, v, opts)

LowestCommonAncestors(G, C, opts)

LowestCommonDescendants(G, u, v, opts)

LowestCommonDescendants(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

• 

distance=truefalse

  

Specifies whether to return the distance along with the common ancestor.

  

If true, the output of the command will be a two-element list, the first element of which is the ancestor vertex and the second of which is a list of distances from the input vertices to the common ancestor.

Description

• 

LowestCommonAncestors(G,u,v) returns a set of the lowest common ancestors of the vertices u and v in the directed graph G.

• 

LowestCommonAncestors(G,C) returns a set of the lowest common ancestors of the vertices in C in the directed graph G.

• 

LowestCommonDescendants(G,u,v) returns a set of the lowest common descendants of the vertices u and v in the directed graph G.

• 

LowestCommonDescendants(G,C) returns a set of the lowest common descendants of the vertices in 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.

• 

A vertex u is a lowest common ancestor of a set C of vertices of G if it is a common ancestor of C and if none of its children are common ancestors of C

• 

A common descendant and lowest common descendant are defined analogously to common ancestor and lowest common ancestor, substituting descendant for ancestor.

Examples

In this example, 1, 3, and 5 are all common ancestors of 6 and 8, but the lowest common ancestor is 5.

withGraphTheory:

GGraph8,1,2,1,3,3,4,3,5,5,6,5,7,7,8

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

(1)

DrawGraphG,style=tree

LowestCommonAncestorsG,6,8

5

(2)

In a general directed graph, there will not be a unique lowest common ancestor.

GGraphTheory:-Graph5,1,2,1,3,2,4,2,5,3,4,3,5,vertexpositions=0,1,1,2,1,0,2,2,2,0

GGraph 2: a directed graph with 5 vertices and 6 arcs

(3)

DrawGraphG

LowestCommonAncestorsG,4,5

2,3

(4)

Compatibility

• 

The GraphTheory[LowestCommonAncestors] and GraphTheory[LowestCommonDescendants] commands were introduced in Maple 2025.

• 

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

See Also

Ancestors

MinimalSpanningTree

ShortestAncestralPath

SpanningTree