Graph Theory

⚡ Key Takeaways

Graph theory studies graphs — collections of objects (vertices) connected pairwise by relations (edges). One-line statement: a graph G=(V,E)G=(V,E) encodes which pairs of a set are related. Key result in words: deep structure (connectivity, colorability, planarity, matchings, flows) follows from simple combinatorial axioms. Applies in computer science, networks, chemistry, operations research, and discrete optimization. Founded by Leonhard Euler in 1736 with the Königsberg bridges problem; matured in the 19th–20th centuries.

💡 The Core Insight

Almost any system of pairwise relations can be abstracted to a graph, and once abstracted, the same combinatorial tools apply regardless of the original domain. The structure of a graph is governed by local data (vertex degrees, neighborhoods) that constrains global properties (connectivity, cycles, colorability). The art of graph theory is translating a question — "Can we schedule these exams?", "Is this network robust?", "Can this molecule exist?" — into a statement about vertices and edges, then exploiting universal theorems.

Formal Statement

DefinitionGraph

A (simple, undirected) graph is an ordered pair G=(V,E)G=(V,E) where:

  • VV is a finite nonempty set of vertices (also nodes),
  • E⊆(V2)E \subseteq \binom{V}{2} is a set of edges, each an unordered pair {u,v}\{u,v\} of distinct vertices.

We write n=∣V∣n = |V| for the order and m=∣E∣m = |E| for the size. Two vertices joined by an edge are adjacent; an edge is incident to its endpoints. Variants:

  • A multigraph allows multiple edges between the same pair.
  • A graph with loops allows edges {v,v}\{v,v\}.
  • A directed graph (digraph) uses ordered pairs E⊆V×VE \subseteq V\times V (arcs).
  • A weighted graph assigns w:E→Rw:E\to\mathbb{R}.
DefinitionDegree

The degree deg⁡(v)\deg(v) of a vertex vv is the number of edges incident to it. In a simple graph,

1
deg⁡(v)=∣{u∈V:{u,v}∈E}∣.\quad \deg(v) = |\{u \in V : \{u,v\}\in E\}|.

Derivation hint: count neighbors directly; each adjacency contributes exactly one to the count. The minimum and maximum degrees are δ(G)=min⁡vdeg⁡(v)\delta(G)=\min_v \deg(v) and Δ(G)=max⁡vdeg⁡(v)\Delta(G)=\max_v \deg(v).

TheoremHandshaking Lemma

For any finite graph G=(V,E)G=(V,E),

2
∑v∈Vdeg⁡(v)=2m.\quad \sum_{v\in V} \deg(v) = 2m.

Derivation hint: each edge has two endpoints, so summing degrees double-counts every edge. A corollary: the number of vertices of odd degree is even.

3
∣{v:deg⁡(v) odd}∣≡0(mod2).\quad \big|\{v : \deg(v)\text{ odd}\}\big| \equiv 0 \pmod 2.

Derivation hint: split the sum in [2] into odd- and even-degree parts; the total is even, the even part is even, so the odd part has even cardinality.

DefinitionAdjacency Matrix

For V={v1,…,vn}V=\{v_1,\dots,v_n\}, the adjacency matrix A=(aij)A=(a_{ij}) is the n×nn\times n matrix with

4
aij={1{vi,vj}∈E,0otherwise.\quad a_{ij} = \begin{cases} 1 & \{v_i,v_j\}\in E,\\ 0 & \text{otherwise.}\end{cases}

Derivation hint: read off adjacency as a 0/1 incidence indicator; for simple graphs AA is symmetric with zero diagonal. The number of walks of length kk from viv_i to vjv_j equals the (i,j)(i,j) entry of AkA^k:

5
(walks of length k from i to j)=(Ak)ij.\quad (\text{walks of length }k\text{ from }i\text{ to }j) = (A^k)_{ij}.

Derivation hint: induct on kk; matrix multiplication sums over all intermediate vertices, exactly enumerating concatenations of a walk of length k−1k-1 with one edge.

DefinitionConnectivity and Paths

A walk is an alternating sequence of vertices and edges; a path is a walk with no repeated vertex; a cycle is a closed path. GG is connected if every pair of vertices is joined by a path. A maximal connected subgraph is a connected component. The distance d(u,v)d(u,v) is the length of a shortest uu–vv path (or ∞\infty).

Why It Holds / Derivation

ProofHandshaking Lemma

We prove equation [2]. 1. Consider the set of incidences I={(v,e):v∈V, e∈E, v is an endpoint of e}I = \{(v,e) : v\in V,\ e\in E,\ v \text{ is an endpoint of } e\}. 2. Count ∣I∣|I| by vertices. For each vertex vv, the number of incidences involving vv is exactly deg⁡(v)\deg(v) (one per incident edge). Hence ∣I∣=∑v∈Vdeg⁡(v)|I| = \sum_{v\in V}\deg(v). 3. Count ∣I∣|I| by edges. Each edge e={u,w}e=\{u,w\} has exactly two endpoints, contributing exactly 22 incidences. Hence ∣I∣=2∣E∣=2m|I| = 2|E| = 2m. 4. Equating the two counts: ∑vdeg⁡(v)=2m\sum_v \deg(v) = 2m. ■\blacksquare

∎
ProofWalk-Counting Formula

We prove [5] by induction on kk. 1. Base k=1k=1: (A1)ij=aij(A^1)_{ij}=a_{ij} counts the walks of length 1 (single edges) from ii to jj. True. 2. Inductive step: Assume (Ak−1)iℓ(A^{k-1})_{i\ell} counts walks of length k−1k-1 from ii to ℓ\ell. A walk of length kk from ii to jj is a walk of length k−1k-1 from ii to some intermediate vertex ℓ\ell, followed by an edge {ℓ,j}\{\ell,j\}. 3. Summing over all valid ℓ\ell:

6
(Ak)ij=∑ℓ=1n(Ak−1)iℓ aℓj.\quad (A^k)_{ij} = \sum_{\ell=1}^{n} (A^{k-1})_{i\ell}\, a_{\ell j}.

Derivation hint: this is the definition of matrix multiplication Ak=Ak−1AA^k = A^{k-1}A; each term counts (walks to ℓ\ell) × (edge ℓ→j\ell\to j). 4. The right side counts exactly all length-kk walks, completing the induction. ■\blacksquare

∎
mathematician · Leonhard Euler | 1707–1783

Euler launched graph theory in 1736 by solving the Seven Bridges of Königsberg: could a citizen cross each of the city's seven bridges exactly once and return home? Euler abstracted the four landmasses into vertices and the bridges into edges, then showed the walk is impossible because more than two vertices had odd degree. This established the principle — still central — that the answer depends only on the abstract incidence structure, not on geometry. Euler also gave the polyhedral formula V−E+F=2V-E+F=2, foundational to planar graph theory and topology. His genius was recognizing that a physical puzzle reduces to a counting argument over degrees.

Building Intuition

🧠 Intuition

Think of a graph as a "relationship diagram." Vertices are entities; an edge means "these two are directly linked." Almost every property has a tangible reading:

  • Degree = popularity / number of direct connections.
  • Connected = you can travel between any two points.
  • Path = a route with no backtracking through the same place.
  • Cycle = a round trip returning to start.
  • Bipartite = the entities split into two camps, with links only between camps (think jobs vs. applicants).
  • Tree = a minimally connected network — remove any edge and it falls apart; add any edge and you create a loop.

The handshaking lemma is just "at a party, the total number of handshake-ends is twice the number of handshakes." The adjacency-matrix power trick says "to count kk-step journeys, multiply the one-step map by itself kk times" — propagation of reachability through repeated composition.

Figure
A simple graph with five vertices, showing degrees and a highlighted cycle
a b c d e deg(a)=2 gold = 4-cycle b–c–e–d–b

Worked Examples

ExampleVerifying the Handshaking Lemma

Given: A graph on V={a,b,c,d,e}V=\{a,b,c,d,e\} with edges {a,b},{b,c},{a,d},{d,b},{c,e},{e,d}\{a,b\},\{b,c\},\{a,d\},\{d,b\},\{c,e\},\{e,d\}. So m=6m=6.

Step 1 — compute degrees.

  • aa: edges {a,b},{a,d}\{a,b\},\{a,d\} → deg⁡(a)=2\deg(a)=2
  • bb: edges {a,b},{b,c},{d,b}\{a,b\},\{b,c\},\{d,b\} → deg⁡(b)=3\deg(b)=3
  • cc: edges {b,c},{c,e}\{b,c\},\{c,e\} → deg⁡(c)=2\deg(c)=2
  • dd: edges {a,d},{d,b},{e,d}\{a,d\},\{d,b\},\{e,d\} → deg⁡(d)=3\deg(d)=3
  • ee: edges {c,e},{e,d}\{c,e\},\{e,d\} → deg⁡(e)=2\deg(e)=2

Step 2 — sum degrees. 2+3+2+3+2=122+3+2+3+2 = 12.

Step 3 — check against 2m2m. 2m=2⋅6=122m = 2\cdot 6 = 12. ✓

Step 4 — odd-degree count. Odd-degree vertices: b,db,d → exactly 22, which is even, consistent with [3].

∑vdeg⁡(v)=12=2m,#odd-degree=2 (even)\boxed{\sum_v \deg(v) = 12 = 2m,\quad \#\text{odd-degree} = 2 \text{ (even)}}
ExampleCounting walks via matrix powers

Given: A path graph P3P_3 on vertices 1 ⁣− ⁣2 ⁣− ⁣31\!-\!2\!-\!3 with adjacency matrix

7
A=(010101010).\quad A = \begin{pmatrix} 0&1&0\\ 1&0&1\\ 0&1&0 \end{pmatrix}.

Derivation hint: entry 1 marks each adjacent pair; vertex 2 is the center adjacent to both ends.

Step 1 — square AA.

8
A2=(101020101).\quad A^2 = \begin{pmatrix} 1&0&1\\ 0&2&0\\ 1&0&1 \end{pmatrix}.

Derivation hint: multiply A⋅AA\cdot A; (A2)22=2(A^2)_{22}=2 since vertex 2 reaches itself via 2→1→22\to1\to2 and 2→3→22\to3\to2.

Step 2 — interpret entries. Number of length-2 walks from vertex 1 to vertex 3 is (A2)13=1(A^2)_{13}=1 (the walk 1→2→31\to2\to3). Number of length-2 closed walks at center vertex 2 is (A2)22=2(A^2)_{22}=2.

Step 3 — total closed length-2 walks =tr(A2)=1+2+1=4=2m= \mathrm{tr}(A^2) = 1+2+1 = 4 = 2m (each edge traversed forward+back gives 2 closed walks; m=2m=2 edges → 4). ✓

length-2 walks 1→3=1,tr(A2)=4=2m\boxed{\text{length-2 walks }1\to3 = 1,\quad \mathrm{tr}(A^2)=4=2m}

Common Misconceptions

⚠️ Common mistake

"A walk, path, trail, and cycle are the same thing." They are not:

  • Walk: vertices/edges may repeat.
  • Trail: no repeated edge (vertices may repeat).
  • Path: no repeated vertex (hence no repeated edge).
  • Cycle/Circuit: closed; a cycle additionally has no repeated internal vertex.

Confusing these breaks theorems: an Eulerian trail uses every edge once; a Hamiltonian path uses every vertex once. These are vastly different in difficulty — Eulerian existence is decided instantly by degree parity, while Hamiltonicity is NP-complete.

CounterexampleDegree sequence does not determine the graph

Two graphs can have identical degree sequences yet not be isomorphic. Consider degree sequence (2,2,2,2,2,2)(2,2,2,2,2,2) on six vertices:

  • Graph A: a single 6-cycle C6C_6.
  • Graph B: two disjoint triangles C3+C3C_3 + C_3.

Both have every vertex of degree 2 and satisfy [2] (∑deg⁡=12=2m\sum\deg = 12 = 2m, m=6m=6). But C6C_6 is connected while 2C32C_3 is not — they are not isomorphic. Hence the degree sequence is a necessary but not sufficient invariant for graph identity.

Connections

connection

Graph theory connects to many areas:

  • <span class="wiki-link-missing">Linear Algebra</span>: the adjacency and Laplacian Matrix turn graph questions into eigenvalue problems (spectral graph theory); eigenvalues bound connectivity, expansion, and colorability.
  • <span class="wiki-link-missing">Topology</span>: planar graphs and the Euler characteristic V−E+F=2V-E+F=2 link to surfaces and embeddings; graph minors relate to topological structure.
  • <span class="wiki-link-missing">Combinatorics</span>: enumeration (counting trees via Cayley's Formula), extremal results (Turán-type theorems), and Ramsey theory all live here.
  • <a class="wiki-link" href="/wiki/probability-theory">Probability Theory</a>: random graphs G(n,p)G(n,p) exhibit sharp threshold phenomena and underlie network science.
  • <span class="wiki-link-missing">Computational Complexity</span>: many canonical NP-complete problems (Hamiltonian cycle, graph coloring, clique) are graph problems; others (shortest path, max flow) are polynomial.
  • <span class="wiki-link-missing">Group Theory</span>: the automorphism group of a graph and Cayley graphs bridge algebra and combinatorics.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1736 — Euler solves the Seven Bridges of Königsberg, founding graph theory and characterizing Eulerian walks via degree parity.
- 1750 — Euler states the polyhedral formula V−E+F=2V-E+F=2, later central to planar graphs.
- 1847 — Gustav Kirchhoff applies tree-counting to electrical networks (Kirchhoff's matrix-tree theorem).
- 1852 — Francis Guthrie poses the Four Color Problem (can every planar map be colored with four colors?).
- 1857 — Arthur Cayley studies trees while enumerating chemical isomers; later proves nn−2n^{n-2} labeled trees.
- 1936 — Dénes Kőnig publishes the first textbook on graph theory, consolidating the field.
- 1930 — Kazimierz Kuratowski characterizes planar graphs by forbidden subgraphs K5K_5 and K3,3K_{3,3}.
- 1956 — Edsger Dijkstra (pub. 1959) and contemporaries develop shortest-path and max-flow (Ford–Fulkerson, 1956) algorithms, launching algorithmic graph theory.
- 1976 — Appel and Haken prove the Four Color Theorem with computer assistance — the first major theorem requiring a computer.
- 1983–2004 — Robertson and Seymour's Graph Minors project proves every minor-closed family is characterized by finitely many forbidden minors.

Subtleties & Limits

open-problem

Several deep questions remain partly open or computationally hard:

  • Graph Isomorphism: is there a polynomial-time algorithm to decide whether two graphs are isomorphic? Babai (2015) gave a quasi-polynomial algorithm, but its exact complexity status (P vs NP-intermediate) is unresolved.
  • Hamiltonicity & the Traveling Salesman: deciding whether a Hamiltonian cycle exists is NP-complete; no efficient characterization analogous to Eulerian degree-parity is known.
  • Reconstruction Conjecture (Kelly–Ulam, 1942): is every graph on ≥3\ge 3 vertices uniquely determined (up to isomorphism) by its multiset of vertex-deleted subgraphs? Still open.
  • Chromatic number bounds: while χ(G)≤Δ(G)+1\chi(G)\le \Delta(G)+1 always holds (and Brooks's theorem refines it), computing χ\chi exactly is NP-hard, and structural conjectures (e.g., Hadwiger's conjecture relating χ\chi to minors) remain unproven in general.

See Also

Trees and Forests · Planar Graphs · Matching Theory · Eulerian and Hamiltonian Paths · Laplacian Matrix · Kuratowski's Theorem · Cayley's Formula · Network Flows