TopologicSort - Maple Help

GraphTheory

 TopologicSort
 compute topological order

 Calling Sequence TopologicSort(G)

Parameters

 G - acyclic directed graph

Options

 • output = one of default or permutation
 When output=permutation, returns a list of integers representing the permutation to Vertices(G) to obtain the topological order. When output=default, a list of the actual vertices is returned.

Description

 • The TopologicSort command returns a linear ordering of vertices of an acyclic digraph that is consistent with the arcs of the digraph.  This means a vertex u precedes a vertex v if there is an arc from u to v. The output is a list.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{DG}≔\mathrm{Digraph}\left(\left\{\left[a,b\right],\left[a,d\right],\left[b,d\right],\left[c,a\right],\left[c,b\right],\left[c,d\right]\right\}\right):$
 > $\mathrm{IsAcyclic}\left(\mathrm{DG}\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{TopologicSort}\left(\mathrm{DG}\right)$
 $\left[{c}{,}{a}{,}{b}{,}{d}\right]$ (2)

Compatibility

 • The GraphTheory[TopologicSort] command was updated in Maple 2021.
 • The output option was introduced in Maple 2021.