Directed Graphs, Paths, and Reachability
Directed Graphs
Definition
A directed graph (or digraph) is a pair where:
- is a set of vertices (or nodes)
- is a set of edges (or arcs)
Note: A digraph is exactly an endo-relation .
Visualisation
Draw each vertex as a point. Draw an arrow from to iff .
Paths
Definition
A path (or walk) in a digraph is a sequence such that for each .
- The length of the path is (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 relates to iff there exists a path from to :
where is the -fold composite.
Reachability
Definition
Vertex is reachable from vertex if there is a path from to .
Equivalently: .
Computing Reachability
For an -vertex graph, any simple path has length . Therefore:
This gives an algorithm: compute .
Adjacency Matrix Approach
Let be the adjacency matrix. Compute:
Then iff is reachable from .
Preorders
Definition
A relation on is a preorder if it is:
- Reflexive:
- Transitive:
A preorder is a partial order if it is also antisymmetric: .
Examples
| Relation | Type |
|---|---|
| on | Partial order |
| on | Partial order |
| (divisibility) on | Partial order |
| on | Preorder (not antisymmetric: and ) |
| Reachability in a digraph | Preorder |
Reflexive-Transitive Closure
Definition
The reflexive-transitive closure of is the smallest preorder containing :
Examinable Proof: Characterisation
Theorem: is the smallest preorder containing .
Proof:
Part 1: is a preorder containing .
- : , and .
- Reflexivity: .
- Transitivity: If and , there exist paths from to and to . Concatenating gives a path from to .
Part 2: is the smallest such preorder.
Let be any preorder with . We show .
By induction on : for all .
- Base (): by reflexivity.
- Step: by transitivity.
Thus .
Transitive Closure
The transitive closure is the smallest transitive relation containing .
Summary
- A digraph is an endo-relation
- Path relation relates connected vertices
- is the reflexive-transitive closure: smallest preorder containing
- Reachability computed via matrix powers up to