Skip to content
Part IA Michaelmas, Lent Term

Directed Graphs, Paths, and Reachability

Directed Graphs

Definition

A directed graph (or digraph) is a pair (V,E)(V, E) where:

  • VV is a set of vertices (or nodes)
  • E⊆V×VE \subseteq V \times V is a set of edges (or arcs)

Note: A digraph is exactly an endo-relation E:V↛VE : V \nrightarrow V.

Visualisation

Draw each vertex as a point. Draw an arrow from vv to ww iff (v,w)∈E(v, w) \in E.

A directed graph with 4 vertices

Paths

Definition

A path (or walk) in a digraph is a sequence v0,v1,…,vkv_0, v_1, \ldots, v_k such that (vi−1,vi)∈E(v_{i-1}, v_i) \in E for each i=1,…,ki = 1, \ldots, k.

  • The length of the path is kk (the number of edges)
  • A simple path visits no vertex twice
  • A cycle is a path from a vertex back to itself

Path Relation

The path relation E∘∗E^{\circ *} relates vv to ww iff there exists a path from vv to ww:

E∘∗=⋃n≥0E∘nE^{\circ *} = \bigcup_{n \geq 0} E^{\circ n}

where E∘nE^{\circ n} is the nn-fold composite.

Reachability

Definition

Vertex ww is reachable from vertex vv if there is a path from vv to ww.

Equivalently: vE∘∗wv E^{\circ *} w.

Computing Reachability

For an nn-vertex graph, any simple path has length <n< n. Therefore:

E∘∗=⋃k=0n−1E∘kE^{\circ *} = \bigcup_{k=0}^{n-1} E^{\circ k}

This gives an algorithm: compute I∪E∪E2∪⋯∪En−1I \cup E \cup E^2 \cup \cdots \cup E^{n-1}.

Adjacency Matrix Approach

Let MM be the adjacency matrix. Compute:

M∗=I⊕M⊕M2⊕⋯⊕Mn−1M^* = I \oplus M \oplus M^2 \oplus \cdots \oplus M^{n-1}

Then Mij∗=1M^*_{ij} = 1 iff jj is reachable from ii.

Preorders

Definition

A relation RR on AA is a preorder if it is:

  1. Reflexive: ∀a.aRa\forall a. aRa
  2. Transitive: ∀a,b,c.(aRb∧bRc⇒aRc)\forall a, b, c. (aRb \land bRc \Rightarrow aRc)

A preorder is a partial order if it is also antisymmetric: (aRb∧bRa)⇒a=b(aRb \land bRa) \Rightarrow a = b.

Examples

RelationType
≤\leq on R\mathbb{R}Partial order
⊆\subseteq on P(X)\mathcal{P}(X)Partial order
∣\mid (divisibility) on Z+\mathbb{Z}^+Partial order
∣\mid on Z\mathbb{Z}Preorder (not antisymmetric: −1∣1-1 \mid 1 and 1∣−11 \mid -1)
Reachability in a digraphPreorder

Reflexive-Transitive Closure

Definition

The reflexive-transitive closure of RR is the smallest preorder containing RR:

R∘∗=⋂{P:R⊆P,P is a preorder}R^{\circ *} = \bigcap \{P : R \subseteq P, P \text{ is a preorder}\}

Examinable Proof: Characterisation

Theorem: R∘∗R^{\circ *} is the smallest preorder containing RR.

Proof:

Part 1: R∘∗R^{\circ *} is a preorder containing RR.

  • R⊆R∘∗R \subseteq R^{\circ *}: R∘1=RR^{\circ 1} = R, and R∘∗=⋃n≥0R∘nR^{\circ *} = \bigcup_{n \geq 0} R^{\circ n}.
  • Reflexivity: R∘0=id⊆R∘∗R^{\circ 0} = \text{id} \subseteq R^{\circ *}.
  • Transitivity: If aR∘∗ba R^{\circ *} b and bR∘∗cb R^{\circ *} c, there exist paths from aa to bb and bb to cc. Concatenating gives a path from aa to cc.

Part 2: R∘∗R^{\circ *} is the smallest such preorder.

Let PP be any preorder with R⊆PR \subseteq P. We show R∘∗⊆PR^{\circ *} \subseteq P.

By induction on nn: R∘n⊆PR^{\circ n} \subseteq P for all nn.

  • Base (n=0n = 0): R∘0=id⊆PR^{\circ 0} = \text{id} \subseteq P by reflexivity.
  • Step: R∘(n+1)=R∘R∘n⊆P∘P=PR^{\circ (n+1)} = R \circ R^{\circ n} \subseteq P \circ P = P by transitivity.

Thus ⋃nR∘n⊆P\bigcup_n R^{\circ n} \subseteq P.

Transitive Closure

The transitive closure R∘+=⋃n≥1R∘nR^{\circ +} = \bigcup_{n \geq 1} R^{\circ n} is the smallest transitive relation containing RR.


Summary

  • A digraph (V,E)(V, E) is an endo-relation E:V↛VE : V \nrightarrow V
  • Path relation E∘∗E^{\circ *} relates connected vertices
  • R∘∗R^{\circ *} is the reflexive-transitive closure: smallest preorder containing RR
  • Reachability computed via matrix powers M∗M^* up to Mn−1M^{n-1}