TopologicalSort

TopologicalSort[g]

gives a list of vertices of g in topologically sorted order for a directed acyclic graph g.

TopologicalSort[{vw,}]

uses rules vw to specify the graph g.

Details

  • A list of vertices is topologically sorted if u precedes v for each edge uv.

Examples

open allclose all

Basic Examples  (1)

Find the topological order of vertices:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Scope  (6)

Applications  (1)

See Also

AcyclicGraphQ  VertexReplace  Sort

Introduced in 2010
(8.0)
| Updated in 2015
(10.3)