Topological sorting
Builds on Directed graphCycleTotal orderPartial orderLinear extension
Definition
Let be a finite directed graph with vertices. A topological sorting of is an enumeration of , each vertex listed exactly once, such that for every edge .
Remarks
Example: let with edges , , and . The order is a topological sorting, since each of the four edges goes from an earlier vertex to a later one. The order is another one, so a topological sorting need not be unique.
Non-example: the graph with edges , and has no topological sorting. In any listing, the cycle has an edge that goes from a later vertex to an earlier one.
A finite directed graph has a topological sorting if and only if it has no directed cycle. For such a graph, the topological sortings are exactly the linear extensions, that is, compatible total orders, of the reachability partial order on . Kahn's algorithm, which repeatedly removes a vertex with no incoming edge, finds one in time .
Reading path
To understand this page from the ground up, read these 6 pages in order. The foundations come first.
Show the path as a graph
- no evidence level
- Cycle concept
- Directed graph concept
- Linear extension concept
- Partial order concept
- Total order concept
- Topological sorting definition
Further reading
About this page
| Tag | GYJM6MR9J9 |
|---|---|
| URI | m2://GYJM6MR9J9 |
| Kind | definition |
| Writing | W0 stub |
| MSC | 05C85, 05C20, 06A06 |
| Defines | Topological sorting |
| Uses | Directed graph, Cycle, Total order, Partial order, Linear extension |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
What links here
No page links to this page yet.