Directed Graphs and Digraphs

Consider a network of one-way streets in a city grid. Even if every intersection is reachable from every other by some undirected path, that doesn't mean you can drive legally between them. One-way restrictions matter. This simple observation is the seed of an entire theory. When edges carry direction, connectivity splits into several genuinely different notions. The combinatorics of "who can reach whom" becomes far richer than in the undirected setting. Directed graphs, or digraphs, model any relationship that is not symmetric. Examples include task dependencies, web links, predator-prey relations, citation networks, precedence constraints in scheduling, and the flow of current through a circuit. Because the relation "there is an edge from uu to vv" need not imply "there is an edge from vv to uu," digraphs support phenomena with no undirected analogue. Most important is the possibility of having no directed cycles at all. This gives rise to directed acyclic graphs (DAGs) and the notion of a topological order. The big picture of this article is that digraph theory develops in exact parallel to undirected graph theory. It replaces single notions with directional pairs. Degree splits into in-degree and out-degree. Connectivity splits into weak and strong connectivity. Components split into weakly and strongly connected components. Each of these directional refinements is a genuine strengthening. Strong connectivity is a strictly stronger condition than weak connectivity. The failure of one to imply the other is exactly what makes digraph theory interesting, rather than a trivial relabeling. This article builds the formal machinery from scratch. It covers the definition of a digraph, in-degree/out-degree, and the directed handshake lemma. It also covers strong connectivity and strongly connected components. It further covers directed acyclic graphs together with the topological sort theorem. Along the way it sets up the vocabulary needed later. This includes reachability, condensation, and strong components. These concepts support Network Flows and Max-Flow Min-Cut and the deeper structural results of Menger's Theorem.

Key takeaways
  • A digraph D=(V,E)D = (V,E) has edges that are ordered pairs (u,v)(u,v), so direction matters and (u,v)≠(v,u)(u,v) \neq (v,u) in general.
  • Every vertex has two separate degree counts: in-degree deg⁡−(v)\deg^-(v) and out-degree deg⁡+(v)\deg^+(v); both sum to ∣E∣|E|.
  • Weak connectivity (connected after forgetting direction) is strictly weaker than strong connectivity (a directed path both ways between every pair).
  • The strongly connected components of any digraph partition its vertices, and contracting each to a point yields a condensation that is always a DAG.
  • A digraph is a DAG if and only if it admits a topological ordering — a linear order in which every edge points forward.
  • Key idea: direction turns one connectivity question into several inequivalent ones, and the acyclic case (DAGs) is exactly the case where a total order compatible with all edges exists.

Where this lives today

Digraphs are the natural model whenever a relationship is asymmetric or has an inherent order. In computer science, task-scheduling systems (build tools like Make, CI/CD pipelines, spreadsheet recalculation engines) represent dependencies as a DAG and use a topological sort to decide a valid execution order — the theorem proved above is literally the correctness argument for these schedulers. Compilers use DAGs for common-subexpression elimination and instruction scheduling. In the web and citation networks, hyperlinks and citations are directed; strongly connected components of the web graph identify tightly interlinked clusters of mutually-referencing pages, and this SCC structure underlies early analyses of "bow-tie" web topology. In biology, gene regulatory networks and metabolic pathways are frequently modeled as digraphs, with feedback loops corresponding to directed cycles and one-way regulatory cascades corresponding to DAG substructures. In operations research and project management, PERT/CPM charts are DAGs whose topological order gives a feasible task sequence, and the longest path in the DAG (critical path) determines minimum project completion time. In cryptography and blockchain, hash-linked structures (e.g., some DAG-based distributed ledgers, as an alternative to strictly linear blockchains) rely on acyclicity to guarantee a consistent causal ordering of transactions. In probability and statistics, Bayesian networks are DAGs encoding conditional independence structure, and the acyclicity theorem underlies the existence of a valid factorization of the joint distribution along a topological order of the variables. Finally, digraph connectivity concepts feed directly into Network Flows and Max-Flow Min-Cut, where directed edge capacities model transportation and communication networks, and into Menger's Theorem, which quantifies strong connectivity in terms of vertex- and edge-disjoint directed paths.

Ask the tutor: How does the source-removal algorithm for topological sorting change if the digraph is allowed to have parallel edges or self-loops?

DefinitionDirected graph (digraph)

A directed graph (or digraph) is a pair D=(V,E)D = (V, E) where VV is a finite set of vertices and E⊆V×VE \subseteq V \times V is a set of directed edges (or arcs), each written as an ordered pair (u,v)(u,v) with u,v∈Vu,v \in V. For an edge e=(u,v)e = (u,v), we call uu the tail and vv the head; we say ee goes from uu to vv, and that vv is an out-neighbor of uu while uu is an in-neighbor of vv. Unless stated otherwise, we forbid loops (u=uu=u pairs are allowed to be excluded by convention; we exclude them here) and treat EE as a set, so no parallel edges (repeated identical ordered pairs) occur. A digraph satisfying these two restrictions is called a simple digraph; this is the default object of study here. The in-degree deg⁡−(v)\deg^-(v) is the number of edges with head vv; the out-degree deg⁡+(v)\deg^+(v) is the number of edges with tail vv. A directed walk from uu to vv is a sequence u=v0,v1,…,vk=vu = v_0, v_1, \dots, v_k = v with (vi−1,vi)∈E(v_{i-1}, v_i) \in E for each ii. A directed path is a directed walk with all viv_i distinct. A directed cycle is a directed walk with k≥1k \geq 1, v0=vkv_0 = v_k, and v0,…,vk−1v_0, \dots, v_{k-1} distinct. The underlying (undirected) graph of DD, denoted G(D)G(D), has the same vertex set and an undirected edge {u,v}\{u,v\} whenever (u,v)∈E(u,v) \in E or (v,u)∈E(v,u) \in E. DD is weakly connected if G(D)G(D) is connected. DD is strongly connected if for every ordered pair u,v∈Vu, v \in V there is a directed path from uu to vv. A directed acyclic graph (DAG) is a digraph containing no directed cycle.

Intuition

Picture a city where every street is one-way. The underlying map (ignoring arrows) might be a single connected grid, so you can always get from any corner to any other if you're allowed to walk against traffic. But driving legally is a different question: strong connectivity asks whether, respecting every arrow, you can still drive from any corner to any other and back. A single one-way street sealing off a neighborhood's only exit can keep the map weakly connected while destroying strong connectivity entirely. This distinction is the heart of the subject. In-degree and out-degree separately track how much traffic converges on and diverges from an intersection; a source vertex (deg⁡−=0\deg^- = 0) is an on-ramp with no way in, a sink (deg⁡+=0\deg^+=0) is a dead end. When a digraph has no directed cycles at all — a DAG — its vertices can be arranged left to right on a line so every arrow points rightward, exactly like a valid schedule of tasks respecting prerequisites.

Figure
A digraph that is weakly but not strongly connected: no directed path returns from dd to aa
a b c d underlying graph is connected; no edge points back toward a
Figure
A DAG with a valid topological order a,b,c,d,ea,b,c,d,e left to right
a b c d e extra edges still point rightward
TheoremDirected handshake lemma

Let D=(V,E)D = (V,E) be a digraph. Then

∑v∈Vdeg⁡+(v)=∑v∈Vdeg⁡−(v)=∣E∣.\sum_{v \in V} \deg^+(v) = \sum_{v \in V} \deg^-(v) = |E|.
Proof

(Double counting.) Consider the set of pairs

S={(v,e):v∈V, e∈E, v is the tail of e}.S = \{ (v, e) : v \in V,\ e \in E,\ v \text{ is the tail of } e \}.

We count ∣S∣|S| two ways. First, group by vertex vv: for fixed vv, the number of edges ee with tail vv is by definition deg⁡+(v)\deg^+(v). Since every edge has exactly one tail, each edge ee contributes to SS exactly once, paired with its unique tail. Summing over all vertices,

∣S∣=∑v∈Vdeg⁡+(v).|S| = \sum_{v \in V} \deg^+(v).

Second, group by edge ee: for each e∈Ee \in E, there is exactly one vertex vv (its tail) with (v,e)∈S(v,e) \in S, so each edge contributes exactly one pair. Hence

∣S∣=∣E∣.|S| = |E|.

Combining the two counts gives ∑vdeg⁡+(v)=∣E∣\sum_{v} \deg^+(v) = |E|. The identical argument applied to heads instead of tails (using deg⁡−(v)\deg^-(v), the number of edges with head vv) gives ∑vdeg⁡−(v)=∣E∣\sum_v \deg^-(v) = |E|. ■\blacksquare

∎
TheoremStrongly connected components partition the vertex set

Let D=(V,E)D = (V,E) be a digraph. Define a relation ∼\sim on VV by u∼vu \sim v if and only if there is a directed path from uu to vv and a directed path from vv to uu (with the convention that every vertex has a trivial length-0 path to itself). Then ∼\sim is an equivalence relation on VV, and its equivalence classes — the strongly connected components (SCCs) of DD — partition VV. Moreover, if D∗D^* (the condensation of DD) is the digraph whose vertices are the SCCs of DD, with an edge from SCC AA to SCC BB (A≠BA \neq B) whenever some edge of DD goes from a vertex in AA to a vertex in BB, then D∗D^* is a directed acyclic graph.

Proof

Equivalence relation. We check the three properties directly. Reflexive: for any v∈Vv \in V, the length-0 walk from vv to vv is a directed path (vacuously, with no edges), so v∼vv \sim v. Symmetric: if u∼vu \sim v, then by definition there is a directed path from uu to vv and one from vv to uu; this is a symmetric statement in u,vu,v, so v∼uv \sim u. Transitive: suppose u∼vu \sim v and v∼wv \sim w. Then there are directed paths P1:u→vP_1: u \to v, P2:v→wP_2: v \to w, P3:v→uP_3: v \to u, P4:w→vP_4: w \to v. Concatenating the walk P1P_1 followed by P2P_2 gives a directed walk from uu to ww (walks may repeat vertices, so concatenation of two walks is always a walk); every directed walk from uu to ww contains a directed path from uu to ww as a subsequence (delete a chord: if a vertex repeats in the walk, excise the loop between the repetitions and repeat until all vertices are distinct — this terminates since the walk is finite and each excision strictly shortens it). Hence a directed path u→wu \to w exists. Symmetrically, concatenating P4P_4 then P3P_3 gives a directed walk from ww to uu, and hence a directed path w→uw \to u. Thus u∼wu \sim w. Since ∼\sim is an equivalence relation on the finite set VV, its equivalence classes partition VV (this is the standard fact that equivalence classes of an equivalence relation partition the underlying set — every element lies in its own class, and two classes are either equal or disjoint by transitivity and symmetry).

Condensation is acyclic. Suppose toward a contradiction that D∗D^* contains a directed cycle

A0→A1→A2→⋯→Ak−1→A0,k≥1,A_0 \to A_1 \to A_2 \to \cdots \to A_{k-1} \to A_0, \qquad k \geq 1,

where A0,…,Ak−1A_0, \dots, A_{k-1} are distinct SCCs of DD (distinct because a directed cycle in D∗D^*, as a digraph, is defined to have distinct vertices among A0,…,Ak−1A_0,\dots,A_{k-1}). By definition of the condensation's edges, for each ii there exist vertices ai∈Aia_i \in A_i, ai′∈Ai+1  ka_i' \in A_{i+1 \bmod k} with (ai,ai′)∈E(a_i, a_i') \in E. Also, since Ai+1A_{i+1} is a single SCC, any two of its vertices are ∼\sim-equivalent, so there is a directed path inside DD from ai′a_i' to any other chosen vertex of Ai+1A_{i+1}, in particular to ai+1a_{i+1} (the vertex we use to leave Ai+1A_{i+1} next). Chaining these edges and paths together over i=0,1,…,k−1i = 0, 1, \dots, k-1 produces a directed walk in DD starting and ending in A0A_0, and passing through at least one vertex of every AiA_i. If k≥2k \geq 2, this walk visits a vertex of A0A_0 (say a0a_0 or the return point in A0A_0) and later a vertex of A1A_1, and eventually returns to A0A_0: extracting the sub-walk from a vertex x∈A0x \in A_0 back to a vertex y∈A0y \in A_0 that passes through A1A_1 gives directed walks x→yx \to y and, by reflexivity/symmetry within A0A_0's own internal connectivity (a directed path from yy back to xx exists since x,y∈A0x, y \in A_0 are ∼\sim-equivalent), a directed walk y→xy \to x. But we also get, by the same chaining restricted to just two indices, directed walks from a representative of A0A_0 to a representative of A1A_1 and — going the rest of the way around the cycle — back from that representative of A1A_1 to the representative of A0A_0. Converting each directed walk to a directed path as in the transitivity argument above, this shows A0∼A1A_0 \sim A_1 in the vertex sense, i.e., the representative vertices are mutually reachable, forcing A0A_0 and A1A_1 to be the same SCC. This contradicts A0≠A1A_0 \neq A_1. (The case k=1k=1, a self-loop A0→A0A_0 \to A_0 in D∗D^*, is excluded by definition since condensation edges are only drawn between distinct SCCs.) Either way we reach a contradiction, so D∗D^* has no directed cycle: it is a DAG. ■\blacksquare

∎
TheoremTopological ordering characterizes DAGs

Let D=(V,E)D = (V,E) be a digraph with ∣V∣=n|V| = n. Then DD is a directed acyclic graph if and only if there exists a bijection (topological order) σ:V→{1,2,…,n}\sigma : V \to \{1, 2, \dots, n\} such that for every edge (u,v)∈E(u,v) \in E, σ(u)<σ(v)\sigma(u) < \sigma(v).

Proof

We prove both directions.

(⇐\Leftarrow) If a topological order exists, DD is acyclic. Suppose for contradiction DD has a directed cycle v0→v1→⋯→vk−1→v0v_0 \to v_1 \to \cdots \to v_{k-1} \to v_0 with k≥1k \geq 1 and v0,…,vk−1v_0, \dots, v_{k-1} distinct. Since (v0,v1),(v1,v2),…,(vk−2,vk−1)(v_0,v_1), (v_1,v_2), \dots, (v_{k-2},v_{k-1}) are all edges, applying the defining property of σ\sigma repeatedly gives

σ(v0)<σ(v1)<σ(v2)<⋯<σ(vk−1).\sigma(v_0) < \sigma(v_1) < \sigma(v_2) < \cdots < \sigma(v_{k-1}).

But (vk−1,v0)(v_{k-1}, v_0) is also an edge, so σ(vk−1)<σ(v0)\sigma(v_{k-1}) < \sigma(v_0). Combining, σ(v0)<σ(vk−1)<σ(v0)\sigma(v_0) < \sigma(v_{k-1}) < \sigma(v_0), a contradiction (strict inequality cannot hold with itself). Hence no directed cycle exists, and DD is acyclic.

(⇒\Rightarrow) If DD is acyclic, a topological order exists. We argue by strong induction on n=∣V∣n = |V|. Base case n=0n = 0: the empty bijection trivially satisfies the (vacuous) condition. Inductive step: Assume every acyclic digraph on fewer than nn vertices has a topological order, and let DD be acyclic with ∣V∣=n≥1|V| = n \geq 1. Claim: DD has a vertex ss with deg⁡−(s)=0\deg^-(s) = 0 (a source). Proof of claim: Suppose not — every vertex has in-degree at least 11. Build a sequence by picking any starting vertex u0u_0, and having chosen uiu_i, since deg⁡−(ui)≥1\deg^-(u_i) \geq 1 there is an edge (ui+1,ui)∈E(u_{i+1}, u_i) \in E for some ui+1u_{i+1}; continue backward this way to define u0,u1,u2,…u_0, u_1, u_2, \dots indefinitely (this is always possible since every vertex has an in-edge). Since VV is finite, by the pigeonhole principle some vertex repeats among u0,u1,…,unu_0, u_1, \dots, u_n (that is n+1n+1 terms drawn from nn possible vertices): there exist 0≤i<j≤n0 \le i < j \le n with ui=uju_i = u_j. The edges (uj,uj−1),(uj−1,uj−2),…,(ui+1,ui)(u_{j}, u_{j-1}), (u_{j-1}, u_{j-2}), \dots, (u_{i+1}, u_i) then form a directed cycle ui=uj→uj−1→⋯→ui+1→uiu_i = u_j \to u_{j-1} \to \cdots \to u_{i+1} \to u_i (after discarding any earlier repeats within this segment to make vertices distinct, which is possible by the same excision argument used above, and the segment is nonempty since i<ji<j). This contradicts acyclicity of DD. This proves the claim. Now let ss be a source of DD, and let D′=D−sD' = D - s be the digraph obtained by deleting ss and all edges incident to it. D′D' is acyclic: any directed cycle in D′D' would also be a directed cycle in DD (it uses only edges of DD that were already present), contradicting acyclicity of DD. Also D′D' has n−1n - 1 vertices. By the inductive hypothesis, D′D' has a topological order σ′:V∖{s}→{1,…,n−1}\sigma' : V \setminus \{s\} \to \{1, \dots, n-1\}. Define σ:V→{1,…,n}\sigma : V \to \{1, \dots, n\} by σ(s)=1\sigma(s) = 1 and σ(v)=σ′(v)+1\sigma(v) = \sigma'(v) + 1 for v≠sv \neq s. This is a bijection onto {1,…,n}\{1,\dots,n\} since σ′\sigma' is a bijection onto {1,…,n−1}\{1,\dots,n-1\} and 11 is used exactly once (by ss). Check the ordering condition on every edge (u,v)∈E(u,v) \in E:

  • If u=su = s: since ss has in-degree 00, u≠su \ne s's constraint is irrelevant here we need σ(s)<σ(v)\sigma(s) < \sigma(v), i.e. 1<σ(v)1 < \sigma(v), which holds since v≠sv \ne s (no edge from ss to ss, as DD is simple/loop-free) forces σ(v)=σ′(v)+1≥2>1\sigma(v) = \sigma'(v)+1 \geq 2 > 1.
  • If u≠su \neq s: then also v≠sv \neq s, because ss has in-degree 00 so no edge has head ss. Both u,v≠su,v \neq s means (u,v)(u,v) is an edge of D′D' too (it survives deletion of ss), so σ′(u)<σ′(v)\sigma'(u) < \sigma'(v) by the inductive hypothesis, hence σ(u)=σ′(u)+1<σ′(v)+1=σ(v)\sigma(u) = \sigma'(u)+1 < \sigma'(v)+1 = \sigma(v).

In both cases σ(u)<σ(v)\sigma(u) < \sigma(v), completing the induction. ■\blacksquare

∎

Worked examples

Example 1 (degree sums and a strong-component computation). Let D=(V,E)D = (V,E) with V={1,2,3,4,5}V = \{1,2,3,4,5\} and

E={(1,2),(2,3),(3,1),(3,4),(4,5),(5,4)}.E = \{(1,2), (2,3), (3,1), (3,4), (4,5), (5,4)\}.

Degrees. Compute in/out-degree at each vertex directly by scanning EE:

vvdeg⁡+(v)\deg^+(v)deg⁡−(v)\deg^-(v)
11 (to 2)1 (from 3)
21 (to 3)1 (from 1)
32 (to 1, to 4)1 (from 2)
41 (to 5)2 (from 3, from 5)
51 (to 4)1 (from 4)

Sum of out-degrees: 1+1+2+1+1=61+1+2+1+1 = 6. Sum of in-degrees: 1+1+1+2+1=61+1+1+2+1=6. Both equal ∣E∣=6|E| = 6, confirming the Directed handshake lemma numerically. Strong components. Vertices 1,2,31,2,3 form a directed cycle 1→2→3→11 \to 2 \to 3 \to 1, so any two of them are mutually reachable: {1,2,3}\{1,2,3\} is (contained in) one SCC. Vertices 4,54,5 satisfy 4→5→44 \to 5 \to 4, a 2-cycle, so {4,5}\{4,5\} is (contained in) one SCC. Is there a path from {1,2,3}\{1,2,3\} back from {4,5}\{4,5\}? The only edge leaving {4,5}\{4,5\} would have to originate at 44 or 55; but 44's only out-edge goes to 55, and 55's only out-edge goes to 44 — both stay inside {4,5}\{4,5\}. So there is no directed path from 44 or 55 back to 1,2,31,2,3, even though 3→43 \to 4 exists in the other direction. Hence the SCCs are exactly

{1,2,3},{4,5}.\{1,2,3\}, \quad \{4,5\}.

The condensation D∗D^* has two vertices, A={1,2,3}A = \{1,2,3\} and B={4,5}B=\{4,5\}, with a single edge A→BA \to B (induced by (3,4)(3,4)) and no edge B→AB \to A. This is indeed acyclic, consistent with the theorem.

Example 2 (topological sort via repeated source removal, non-trivial ties). Let DD have vertices {a,b,c,d,e,f}\{a,b,c,d,e,f\} and edges

E={(a,c),(a,d),(b,d),(c,e),(d,e),(d,f),(e,f)}.E = \{(a,c), (a,d), (b,d), (c,e), (d,e), (d,f), (e,f)\}.

Check acyclicity informally first: draw out-degrees/in-degrees.

vvin-edgesout-edges
aanonec,dc, d
bbnonedd
ccaaee
dda,ba, be,fe, f
eec,dc, dff
ffd,ed, enone

Step 1. Sources (in-degree 00): aa and bb. The construction in the theorem's proof only requires finding one source at each stage; there can be several. Pick aa (the choice is not unique — this is expected, since topological orders need not be unique). Assign σ(a)=1\sigma(a) = 1. Delete aa and its edges (a,c),(a,d)(a,c),(a,d). Updated in-degrees: cc: was 11 (from aa), now 00. dd: was 22 (from a,ba,b), now 11 (from bb only). b,e,fb, e, f unchanged: bb still 00, ee still 22, ff still 22. Step 2. Sources now: bb and cc. Pick bb. Assign σ(b)=2\sigma(b) = 2. Delete edge (b,d)(b,d). Now dd's in-degree drops from 11 to 00. Step 3. Sources now: cc and dd. Pick cc. Assign σ(c)=3\sigma(c) = 3. Delete edge (c,e)(c,e). ee's in-degree drops from 22 to 11 (only dd remains). Step 4. Sources now: only dd. Assign σ(d)=4\sigma(d) = 4. Delete edges (d,e),(d,f)(d,e), (d,f). ee's in-degree drops to 00; ff's in-degree drops from 22 to 11 (only ee remains). Step 5. Sources now: only ee. Assign σ(e)=5\sigma(e) = 5. Delete edge (e,f)(e,f). ff's in-degree drops to 00. Step 6. Only ff remains. Assign σ(f)=6\sigma(f) = 6. Resulting topological order: a,b,c,d,e,fa, b, c, d, e, f with σ\sigma exactly this rank. Verify every edge points forward: (a,c)(a,c): 1<31<3 ✓. (a,d)(a,d): 1<41<4 ✓. (b,d)(b,d): 2<42<4 ✓. (c,e)(c,e): 3<53<5 ✓. (d,e)(d,e): 4<54<5 ✓. (d,f)(d,f): 4<64<6 ✓. (e,f)(e,f): 5<65<6 ✓. All seven edges point forward, confirming DD is acyclic and this σ\sigma is a valid topological order — and note that choosing bb before aa in Step 1 would have produced a different, equally valid order, illustrating non-uniqueness.

CounterexampleDropping acyclicity breaks the topological order theorem

The forward direction of the theorem (existence of topological order ⇒\Rightarrow acyclic) is unconditional and cannot fail; the content that needs a hypothesis is the converse: acyclicity is necessary for a topological order to exist, and if we instead try to assert "every digraph has a topological order" by dropping the acyclicity hypothesis, it fails immediately. Take D=({x,y},{(x,y),(y,x)})D = (\{x,y\}, \{(x,y),(y,x)\}), a 22-cycle. Suppose a topological order σ\sigma existed. From edge (x,y)(x,y) we'd need σ(x)<σ(y)\sigma(x) < \sigma(y); from edge (y,x)(y,x) we'd need σ(y)<σ(x)\sigma(y) < \sigma(x). These cannot both hold for real numbers σ(x),σ(y)\sigma(x), \sigma(y), so no such σ\sigma exists. Indeed DD contains the directed cycle x→y→xx \to y \to x, so it is not acyclic — exactly the situation the theorem excludes. This shows the acyclicity hypothesis in the theorem is not a technical nicety but the exact dividing line: any directed cycle, no matter how short, obstructs the existence of a topological order, because traversing the cycle forces a strictly increasing then strictly decreasing chain of labels that returns to its start.

Scope, edge cases & common traps

SituationWhat to watch for
Weakly vs. strongly connectedA digraph can be weakly connected with every vertex having in-degree ≥1\geq 1 and out-degree ≥1\geq 1, yet still fail to be strongly connected (Example 1's condensation edge A→BA \to B persists).
Loops and parallel edgesThe definitions above assume a simple digraph (no loops, no parallel edges); if loops are allowed, a single loop at vv is itself a directed cycle and blocks DD from being a DAG.
Uniqueness of topological orderTopological orders are generally not unique (Example 2); uniqueness holds iff the DAG's condensation-free structure is a total order, i.e. every pair of vertices is comparable via a directed path.
Condensation vs. original graphThe condensation D∗D^* is always acyclic regardless of whether DD itself is acyclic; do not confuse "DD is a DAG" with "D∗D^* is a DAG" — the latter is a theorem true for every digraph.
In-degree 00 verticesA DAG can have more than one source (Example 2 had two: a,ba,b); it can also have exactly one, or in degenerate cases (single isolated vertex) trivially one.

The mathematician behind it

Origins · 1 minLeonhard Euler and how this was discovered
LE
Leonhard Euler
1707–1783 · Königsberg bridges and the birth of graph theory

Euler's 1736 resolution of the Seven Bridges of Königsberg problem is usually cited as the origin of graph theory, though he worked with undirected multigraphs, not digraphs in the modern sense. The formal study of directed graphs — degree sequences with direction, strong connectivity, and topological ordering — crystallized much later, in the twentieth century, driven by operations research, computer science (scheduling and dependency analysis), and the theory of tournaments and relations, with foundational contributions from Claude Berge, Frank Harary, and others who systematized digraph terminology alongside the classical undirected theory.

History
- 1736 — Euler solves the Königsberg bridges problem, launching graph-theoretic reasoning (undirected).
- 1892 — Poincaré's work on dynamical systems implicitly uses directed structure (orbits, flows) though not yet as "digraphs."
- 1950s — Systematic digraph terminology (in/out-degree, strong connectivity) formalized alongside operations research and network flow theory (Ford, Fulkerson).
- 1962 — Harary, Norman, and Cartwright's Structural Models gives a comprehensive treatment of digraphs for social-network and systems modeling.
- 1972 — Tarjan publishes a linear-time algorithm for strongly connected components, cementing digraph SCC theory as computationally central.
Is a digraph just a graph where I remember which way each edge "was drawn"?

Not quite — it's a genuinely different combinatorial object. In an undirected graph, an edge {u,v}\{u,v\} is a single unordered pair, and the graph is fully described once you know which unordered pairs are edges. In a digraph, (u,v)(u,v) and (v,u)(v,u) are both potentially present, independently of each other, giving up to twice as many possible edges on the same vertex set (before excluding loops). This means digraphs can encode information — like "uu points to vv but not vice versa," or mutual edges in both directions — that has no direct undirected analogue, which is exactly why connectivity, degree, and cycle notions all need directional refinements.

Why does strong connectivity require paths in both directions rather than just one?

Because the goal is to capture mutual reachability, the digraph analogue of "you can get from any vertex to any other," which for undirected graphs is symmetric automatically. If we only required a path from uu to vv for some fixed order of every pair (say, always uu before vv alphabetically), we would not get a meaningful notion of connectivity — the "requirement" would depend on an arbitrary labeling rather than the graph's structure. Requiring both directions for every ordered pair is precisely what makes strong connectivity well-defined independent of vertex labels, and it is what allows the strong-components relation ∼\sim to be proven an equivalence relation.

Can a DAG have more than one topological order?

Yes, and this is the typical case rather than an exception, as Example 2 demonstrates. Uniqueness of the topological order holds exactly when the DAG has a directed path between every pair of vertices in some order — i.e., when the reachability relation is a total order on VV — because then no two vertices are "incomparable" and free to be swapped. Whenever the source-removal construction in the proof encounters more than one available source (in-degree-0 vertex) at some stage, different choices yield different valid orders, so multiplicity of sources at any stage is a certificate of non-uniqueness.

How do I check whether a digraph is a DAG in practice?

Run the repeated-source-removal procedure from the theorem's proof (this is essentially Kahn's algorithm): repeatedly find a vertex of current in-degree 00, output it, and delete it along with its outgoing edges, updating in-degrees. If this process removes all nn vertices, the digraph is acyclic and the output order is a valid topological order. If at some point no in-degree-00 vertex remains but vertices are still undeleted, those remaining vertices necessarily lie on a directed cycle, so the digraph is not a DAG. This gives both a correctness certificate and, in the failing case, a witness to non-acyclicity.

What's the difference between the condensation being acyclic and the original digraph being acyclic?

These are different claims with different scopes. The condensation of any digraph DD — even one packed with directed cycles — is always acyclic, because by construction distinct strongly connected components cannot have paths going both ways between them (otherwise they'd have been merged into one SCC). The original digraph DD being acyclic is a much stronger, restrictive condition: it forces every strongly connected component of DD to be a single vertex with no self-loop, since any SCC with ≥2\geq 2 vertices or with a self-loop already contains a directed cycle. So "DD is a DAG" is equivalent to "every SCC of DD is a single vertex," while "the condensation of DD is a DAG" is unconditionally true.

Does every digraph have a source vertex (in-degree 0)?

No — only acyclic digraphs are guaranteed to have one, and this was exactly the key lemma used inductively in the topological-order proof. A digraph containing a directed cycle can have every vertex with in-degree at least 11; indeed the simplest counterexample is the 22-cycle x→y→xx \to y \to x, where both deg⁡−(x)=1\deg^-(x) = 1 and deg⁡−(y)=1\deg^-(y) = 1, so no source exists. The proof of the source-lemma is itself a proof by contradiction using the pigeonhole principle: assuming no source exists lets you walk backwards forever along in-edges, and finiteness of VV forces a repeated vertex, which yields a directed cycle.

How does strong connectivity relate to Menger's Theorem and network flows?

Strong connectivity is the qualitative, yes/no version of a question that Menger's Theorem and Network Flows and Max-Flow Min-Cut make quantitative. Once you know a digraph is strongly connected, natural follow-up questions are: how many vertex-disjoint or edge-disjoint directed paths connect a given pair u,vu,v, and how many edges (or vertices) must be deleted to destroy all directed paths from uu to vv? Menger's theorem answers this by equating the maximum number of disjoint paths to the minimum size of a separating cut, and max-flow min-cut generalizes this further by attaching capacities to edges, turning "how many disjoint paths" into "how much flow can be pushed," with strong connectivity as the base case ensuring at least one path exists between every pair.

Before this

Where this leads