Ancestors - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


GraphTheory

  

Ancestors

  

list ancestors of a given vertex

  

Descendants

  

list descendants of a given vertex

 

Calling Sequence

Parameters

Options

Description

Definition

Examples

Compatibility

Calling Sequence

Ancestors(G, v)

Ancestors(G, v, opts)

Descendants(G, v)

Descendants(G, v, opts)

Parameters

G

-

graph

v

-

vertex of the graph

opts

-

(optional) one or more options as specified below

Options

• 

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.

Description

• 

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.

Definition

• 

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.

Examples

> 

with⁡GraphTheory:

> 

C6≔CycleGraph⁡6,directed

C6≔Graph 1: a directed graph with 6 vertices and 6 arcs

(1)
> 

DrawGraph⁡C6

> 

Ancestors⁡C6,6

1,2,3,4,5

(2)
> 

Ancestors⁡C6,6,output=graph

Graph 2: a directed graph with 5 vertices and 4 arcs

(3)
> 

T≔Graph⁡5,1,2,1,4,2,3,4,5

T≔Graph 3: a directed graph with 5 vertices and 4 arcs

(4)
> 

DrawGraph⁡T

> 

Ancestors⁡T,4

1

(5)
> 

Descendants⁡T,4

5

(6)

Compatibility

• 

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