GraphTheory
Ancestors
list ancestors of a given vertex
Descendants
list descendants of a given vertex
Calling Sequence
Parameters
Options
Description
Definition
Examples
Compatibility
Ancestors(G, v)
Ancestors(G, v, opts)
Descendants(G, v)
Descendants(G, v, opts)
G
-
graph
v
vertex of the graph
opts
(optional) one or more options as specified below
output=one of graph or list
Specifies whether the result should be a list of vertices reachable from v or the subgraph induced by the vertices reachable from v. The default is list.
Ancestors(G,v) returns a list of all ancestors of v in G, that is, vertices in G from which v is reachable.
Descendants returns a list of all descendants of v in G, that is, vertices in G which are reachable from the vertex v.
Note that the input vertex v is excluded from the output, even if the graph contains a loop including v.
To produce an actual spanning tree of vertices reachable from v, see SpanningTree or MinimalSpanningTree.
If G is a directed graph and there exists a directed path in G from u to v, then u is said to be an ancestor of v, and v is said to be descendant of u.
withGraphTheory:
C6≔CycleGraph6,directed
C6≔Graph 1: a directed graph with 6 vertices and 6 arcs
DrawGraphC6
AncestorsC6,6
1,2,3,4,5
AncestorsC6,6,output=graph
Graph 2: a directed graph with 5 vertices and 4 arcs
T≔Graph5,1,2,1,4,2,3,4,5
T≔Graph 3: a directed graph with 5 vertices and 4 arcs
DrawGraphT
AncestorsT,4
1
DescendantsT,4
5
The GraphTheory[Ancestors] and GraphTheory[Descendants] commands were introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
LowestCommonAncestors
MinimalSpanningTree
ShortestAncestralPath
SpanningTree
Download Help Document