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
LowestCommonAncestors(G, u, v, opts)
LowestCommonAncestors(G, C, opts)
LowestCommonDescendants(G, u, v, opts)
LowestCommonDescendants(G, C, opts)
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
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.
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.
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.
In this example, 1, 3, and 5 are all common ancestors of 6 and 8, but the lowest common ancestor is 5.
with⁡GraphTheory:
G≔Graph⁡8,1,2,1,3,3,4,3,5,5,6,5,7,7,8
G≔Graph 1: a directed graph with 8 vertices and 7 arcs
DrawGraph⁡G,style=tree
LowestCommonAncestors⁡G,6,8
5
In a general directed graph, there will not be a unique lowest common ancestor.
G≔GraphTheory:-Graph⁡5,1,2,1,3,2,4,2,5,3,4,3,5,vertexpositions=0,1,1,2,1,0,2,2,2,0
G≔Graph 2: a directed graph with 5 vertices and 6 arcs
DrawGraph⁡G
LowestCommonAncestors⁡G,4,5
2,3
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
Download Help Document