Math 2.0

Combinatorics Definition

Topological sorting

Builds on Directed graphCycleTotal orderPartial orderLinear extension

Definition

Let G=(V,E)G = (V, E) be a finite directed graph with nn vertices. A topological sorting of GG is an enumeration v1,v2,…,vnv_1, v_2, \dots, v_n of VV, each vertex listed exactly once, such that i<ji < j for every edge (vi,vj)∈E(v_i, v_j) \in E.

Remarks

Example: let V={a,b,c,d}V = \set{a, b, c, d} with edges a→ba \to b, a→ca \to c, b→db \to d and c→dc \to d. The order a,b,c,da, b, c, d is a topological sorting, since each of the four edges goes from an earlier vertex to a later one. The order a,c,b,da, c, b, d is another one, so a topological sorting need not be unique.

Non-example: the graph with edges a→ba \to b, b→cb \to c and c→ac \to a has no topological sorting. In any listing, the cycle a→b→c→aa \to b \to c \to a 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 VV. Kahn's algorithm, which repeatedly removes a vertex with no incoming edge, finds one in time O(n+∣E∣)O(n + \abs{E}).

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
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Cycle concept
  2. Directed graph concept
  3. Linear extension concept
  4. Partial order concept
  5. Total order concept
  6. Topological sorting definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Topological_sorting
About this page
TagGYJM6MR9J9
URIm2://GYJM6MR9J9
Kinddefinition
WritingW0 stub
MSC05C85, 05C20, 06A06
DefinesTopological sorting
UsesDirected graph, Cycle, Total order, Partial order, Linear extension
Changed3 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.