Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Mathematics and Algorithms > Graphs & Networks > Paths and Cycles > TopologicalSort >
Mathematica > Visualization and Graphics > Graphs & Networks > Paths and Cycles > TopologicalSort >

TopologicalSort

TopologicalSort[g]
gives a list of vertices of g in topologically sorted order for a directed acyclic graph g.
  • A list of vertices is topologically sorted if u precedes v for each edge .
Find the topological order of vertices:
Find the topological order of vertices:
In[1]:=
Click for copyable input
Out[1]=
TopologicalSort works with directed graphs:
Weighted graphs:
TopologicalSort only works with acyclic graphs:
Works with large graphs:
Sort strongly connected components instead of vertices when there are cycles:
Construct the condensation of g by finding the edges between the components:
Use the topological ordering of the strongly connected components to order the vertices of g:
The new adjacency matrix is block upper triangular:
New in 8
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF