Graphs serve as the foundational mathematical framework for representing, analyzing, and optimizing complex relational structures across computer science and engineering. From network routing and parallel computation to chemical structures and job assignments, this guide explores how discrete graph-theoretic principles are applied to solve real-world system challenges.
At its core, a graph is a mathematical structure consisting of a set of vertices (or nodes) and a set of edges . A mapping function associates each edge in with a pair of vertices from :
Depending on the nature of the relationships being modeled, graphs are classified into several structural variations:
Simple Graph: Multigraph: Digraph:
A --- B A === B A ---> B
| | | / | ^ |
| | | / | | v
C --- D C --- D C <--- DGraphs can exhibit behaviors analogous to algebraic relations in set theory. Consider a simple digraph , where the presence of a directed edge acts as a binary relation on . This relation can be analyzed using standard properties:
The converse (or reversal) of a digraph , denoted or , is constructed by reversing the direction of every edge in . This is crucial in reversing data flow directions or analyzing upstream dependencies in dependency graphs.
The topological importance of a node is often characterized by its degree. In undirected graphs, the degree of a vertex is simply the number of edges incident to it. In digraphs, we split this metric:
Indegree (): The number of directed edges terminating at node .
Outdegree (): The number of directed edges originating from node .
(A) <--- (B) ---> (C)
\ ^
\ /
v /
(D)
Degree Metrics Table:
Node | Indegree | Outdegree | Total Degree
------------------------------------------
A | 1 | 0 | 1
B | 0 | 2 | 2
C | 2 | 0 | 2
D | 1 | 1 | 2Understanding routing path availability and structural vulnerability relies heavily on connectivity definitions.
A subgraph of is a graph where and . If , it is a .
Unilateral Connectivity:
A ---> B ---> C (A can reach C, but C cannot reach A)
Strong Connectivity:
A ---> B ---> C
^ | (Every node can reach every other node)
|_____________|Reachable Set : The set of all nodes reachable via directed paths starting from node .
Node Base : A minimal subset of vertices such that every vertex in the graph is reachable from at least one vertex in .
Properties of a Node Base:
While diagrams are useful for human visualization, computerized graph analysis requires algebraic representations.
For a graph with vertices ordered , the is an Boolean matrix where:
Graph:
(1) ----> (2)
^ /
| /
| v
(4) <== (3) (double edge)
Adjacency Matrix A:
1 2 3 4
1 [ 0 1 0 0 ]
2 [ 0 0 1 0 ]
3 [ 0 0 0 2 ]
4 [ 1 0 0 0 ]To find the number of paths of a specific length between vertices, we use powers of the adjacency matrix. The element in row , column of the matrix represents the exact number of distinct paths (or walks) of length from to .
The path matrix (or reachability matrix) is an Boolean matrix where if there is a path of any length from to , and otherwise. It can be computed using Boolean logical OR operations:
where denotes the -th Boolean product of . Another common representation for tracking actual path counts up to length is:
For an undirected graph with vertices and edges, the incidence matrix is a matrix where:
In physical software implementations, choosing the right representation is critical:
Navigating a graph requires precise terminology to distinguish between different types of traversals:
Walk (can repeat nodes/edges): A -> B -> C -> B -> D
Trail (no repeated edges): A -> B -> C -> D -> B
Simple Path (no repeats): A -> B -> C -> DThe distance metric satisfies the standard properties of metric spaces:
A tree is a connected, undirected simple graph that contains no cycles. A disjoint collection of trees is called a forest.
Free Tree (Undirected): Rooted Tree (Directed):
A [Root]
/ \ O
B C / \
/ \ O O
D E / \ \
O O O [Leaves]An undirected graph with vertices is a tree if and only if it satisfies the following conditions:
There is a unique simple path between any two vertices in .
is connected and has exactly edges:
In a rooted tree, one node is designated as the root, and all edges are implicitly or explicitly directed away from this root:
To systematically visit every node in an ordered rooted tree, three recursive strategies are used:
A wide range of routing and optimization problems rely on finding paths that visit every edge or vertex in a graph.
Eulerian Graph (All degrees even):
A
/ \
B---C
\ /
D
Degree Sequence: [A:2, B:4, C:4, D:2] -> Euler Circuit exists!Unlike Eulerian circuits, determining whether a graph contains a Hamiltonian circuit is an NP-complete problem. However, several sufficient conditions exist:
Dirac's Theorem: If is a simple graph with vertices, and every vertex has a degree satisfying:
A major practical application of Hamilton circuits in hypercubes is the generation of Gray codes (reflected binary codes), where successive binary numbers differ by exactly one bit. This is highly useful for error correction in digital communications and rotary encoders.
In physical design problems, such as printed circuit board (PCB) layouts and microchip routing, we must connect components without crossing wires. This is modeled using planar graphs.
Planar Embedding of K_4:
A A
/|\ / \
/ | \ ===> B---C
/ | \ \ / \
B-- | --C D |
\ | / \ /
\ | / E (Represented cleanly on plane)
DFor any connected planar simple graph, any planar representation divides the plane into distinct regions (including the infinite unbounded outer region). The relationship between regions (), edges (), and vertices () is given by:
These corollaries are useful for proving whether a graph is non-planar:
If is a connected planar simple graph with vertices, then:
If has no cycles of length 3 (e.g., bipartite graphs) and , then:
These inequalities help prove that the complete graph (, which is false) and the complete bipartite utility graph (, which is false) are .
To generalize planarity, we define:
A graph is planar if and only if it does not contain a subgraph that is homeomorphic to (the complete graph on 5 vertices) or (the complete bipartite utility graph).
K_5 (Complete 5-Graph) K_3,3 (Utility Graph)
O O O O (Set 1)
/ | \ | \ / |
O--O--O | X |
\ | / | / \ |
O O O O (Set 2)The theoretical concepts discussed above are directly applied to solve various engineering and computational design problems:
Employees Jobs
[ Alice ] ---- [ Frontend ]
[ Bob ] ---\- [ Backend ]
[ Clara ] ---- [ Database ]In computer networking, Local Area Network (LAN) topologies are modeled and analyzed using graph-theoretic structures:
In parallel computing architectures, processors are represented as vertices, and their physical communication links are represented as edges:
A minimal subset of vertices from which every other vertex in a directed graph is reachable, critical for routing and resource allocation.
Maximal subgraphs in a directed graph where every pair of vertices is mutually reachable along directed paths.
Algebraic matrices used to represent graph topologies and compute the number of paths of length $k$ via matrix multiplication.
Graphs that can be drawn on a 2D plane without intersecting edges, structurally governed by the invariant relation $r = e - v + 2$.
The distinction between visiting every edge exactly once (Eulerian) and visiting every node exactly once (Hamiltonian) in a graph topology.
Test your understanding with 5 questions
Which of the following is NOT a necessary property of a node base $S$ in a directed graph?
A connected planar simple graph has 10 vertices and 15 edges. How many regions does its planar representation divide the plane into?
If $A$ is the adjacency matrix of a graph, what does the entry in row $i$, column $j$ of the matrix $A^3$ represent?
A tree has exactly 100 vertices. How many edges must it contain?
Which type of connectivity in a digraph requires that for any pair of distinct vertices $u$ and $v$, at least one vertex is reachable from the other?
Total Degree: The sum of the indegree and outdegree:
Isolated Node: A vertex with a total degree of zero ().
Null Graph: A graph consisting entirely of isolated nodes ().
Graph Isomorphism: Two graphs and are structurally equivalent (isomorphic) if there exists a bijective function such that:
Isomorphic graphs share identical graph invariants (properties preserved under isomorphism), such as vertex/edge counts and degree sequences.
then contains a Hamilton circuit.
Ore's Theorem: If is a simple graph with vertices, and for every pair of non-adjacent vertices and :
then contains a Hamilton circuit.
6 Modules
6 Modules