Graph theory provides the mathematical language to model connections, flows, and structural relationships across computer networks, physical infrastructures, and logical dependencies. This module explores how entities connect, how reachability is mathematically determined, and the structural properties that define robust network topologies.
A graph is formally defined as an ordered pair:
where is a non-empty set of vertices (or nodes), and is a set of edges (or connections). A mapping function associates each edge in with a pair of vertices from .
Undirected Edge Directed Edge
(Bidirectional) (Unidirectional)
u --------- v u ---------> vThe degree of a vertex measures its local connectivity:
For simple directed graphs, the edge set can be analyzed as a binary relation on the set :
The converse (or reversal/dual) of a digraph , denoted , is obtained by reversing the direction of every edge:
Evaluating how information traverses a graph requires formal distinctions between different types of node-edge sequences.
Walk (General sequence of nodes & edges)
└─► Trail (No edge is repeated)
└─► Simple Path (No vertex is repeated)Reachability is a binary relation: a vertex is reachable from (denoted ) if there exists a directed path starting at and terminating at . Reachability is reflexive (via a path of length 0) and transitive, but not necessarily symmetric or antisymmetric.
The reachable set of a node in a digraph is the set of all vertices reachable from :
A node base for a digraph is a minimal subset of vertices such that every vertex in is reachable from at least one vertex in .
Node Base S: Minimum set of launching points to span the entire graph.
[ s1 ] ───► ( v1 ) ───► ( v2 )
[ s2 ] ───► ( v3 )The structural integrity of a graph is determined by its connectivity. We define connectivity differently depending on whether edges are directed.
Connectivity Hierarchy in Digraphs
┌────────────────────────┐
│ Strongly Connected │ (Mutual reachability)
└───────────┬────────────┘
│ (implies)
▼
┌────────────────────────┐
│ Unilaterally Connected │ (One-way reachability)
└───────────┬────────────┘
│ (implies)
▼
┌────────────────────────┐
│ Weakly Connected │ (Connected when undirected)
└────────────────────────┘ (u) ─── [ Bridge Edge ] ─── (v)
/ \ / \
(a)---(b) (c)---(d)While graphical visualizations are useful for small systems, computer algorithms process graphs using algebraic matrices.
For a graph with vertices, the adjacency matrix is an matrix where:
Graph: Adjacency Matrix A:
(1) ───► (2) 1 2 3
│ │ 1 [ 0 1 1 ]
▼ ▼ 2 [ 0 0 1 ]
(3) ◄─────┘ 3 [ 0 0 0 ]The entry of the matrix power represents the exact number of walks of length from vertex to vertex .
The path matrix (or reachability matrix) is an Boolean matrix where if there is a path of any length from to , and otherwise. It is calculated using Boolean joins and powers:
where denotes the Boolean product . Alternatively, we can count paths using real arithmetic:
For an undirected graph with vertices and edges, the incidence matrix is a matrix where:
Modern software systems select graph representations based on edge density:
| Feature | Adjacency Matrix | Adjacency List | | :--- | :--- | :--- | | Space Complexity | | | | Edge Lookup () | | | | | Dense graphs () | Sparse graphs () |
To compute reachability programmatically, we can traverse the graph using depth-first search (DFS). The following Python implementation demonstrates how to find the reachable set for a given vertex:
def get_reachable_set(adj_list, start_node):
"""
Computes the reachable set R(start_node) using Depth-First Search.
:param adj_list: Dict representing the adjacency list (e.g., {1: [2, 3], 2: [3], 3: []})
:param start_node: The node from which reachability is computed
:return: A set of all reachable nodes
"""
visited = set()
def dfs(node):
visited.add(node)
for neighbor in adj_list.get(node, []):
if neighbor not in visited:
dfs(neighbor)
dfs(start_node)
return visited
# Example Usage:
# Graph: 1 -> 2 -> 3; 1 -> 3
graph = {
1: [2, 3],
2: [3],
A tree is a connected, undirected simple graph that contains no cycles. A disjoint collection of trees is called a forest.
Tree (Acyclic, Connected) Non-Tree (Contains Cycle)
( Root ) ( Root )
/ \ / \
(A) (B) (A) ── (B)
/ \ / \
(C) (D) (C) (D)In a rooted tree, one vertex is designated as the root, and all edges are directed away from it:
Tree traversals recursively visit every node in an ordered rooted tree exactly once:
( Root )
/ \
[Left] [Right]Certain classes of paths and structural constraints have historical and practical importance in discrete mathematics.
K_5 (Nonplanar) K_3,3 (Nonplanar Utility)
(1) (A) (B) (C)
/ | \ │ \ / │ \ / │
(2)─┼─┼─(5) │ X │ X │
\ │ │ / │ / \ │ / \ │
(3)─(4) (X) (Y) (Z)A graph is planar if it can be drawn in a single plane such that no two edges intersect except at their common endpoints.
For any connected planar simple graph, the relationship between the number of vertices , edges , and bounded regions (faces) is constant:
Using these corollaries, we can mathematically prove that certain graphs cannot be drawn on a plane:
Two graphs are homeomorphic if they can both be obtained from the same graph by a sequence of elementary subdivisions (inserting a vertex of degree 2 into an existing edge).
A walk is a general sequence of alternating vertices and edges; a trail restricts this sequence to unique edges, while a simple path requires all vertices to be unique.
Directed graphs display levels of connectivity: weak (disregarding direction), unilateral (one-way reachability between any pair), and strong (mutual reachability).
The minimal subset of vertices in a directed graph from which all other vertices can be reached, containing all isolated and zero-indegree nodes.
Using Boolean matrix multiplication of the adjacency matrix to systematically compute the path matrix and path counts of various lengths.
An invariant for connected planar graphs relating vertices, edges, and regions: r = e - v + 2, bounding the density of edges.
Test your understanding with 5 questions
In a directed graph G, which of the following best defines a unilaterally connected graph?
Which of the following conditions must be satisfied by a node base S of a directed graph G?
Consider a connected planar simple graph with v >= 3 vertices. If this graph has no cycles of length 3 (such as a bipartite graph), what is the maximum number of edges e it can have?
Let A be the n x n adjacency matrix of a simple graph. What does the (i, j)-th entry of the matrix B_n = A + A^2 + ... + A^n represent?
A simple graph G has 10 vertices. According to Dirac's Theorem, what is the minimum degree that every vertex must have to guarantee that G has a Hamilton circuit?
6 Modules
6 Modules