Graph Fundamentals: Connectivity, Trees, Planarity & Colorings
A graph is a set of vertices and edges — connectivity, trees, planarity, and colorability are the foundational properties that determine what computations are feasible on graph-structured data. Understanding these properties rigorously is the prerequisite for spectral methods, random graphs, and graph neural networks.
Concepts
A graph $G = (V, E)$ with $|V| = 6$ vertices and $|E| = 7$ edges. Colors show connected components. Toggle views.
A graph is the mathematical model for any system of objects and relationships — social networks, road maps, molecular bonds, dependency graphs in software. The same three questions recur in all of them: which objects are reachable from a given starting point, how can the graph be partitioned into coherent subsets, and what is the minimum-cost structure that preserves connectivity?
Graphs and Their Representations
A graph consists of a vertex set with and an edge set with . In an undirected graph, edges are unordered pairs ; in a directed graph (digraph), edges are ordered pairs .
The degree of vertex is . The handshaking lemma states:
since each edge contributes to two degrees. The degree sequence lists degrees in non-increasing order. For directed graphs, in-degree and out-degree are tracked separately.
The adjacency matrix has if . For undirected graphs is symmetric. The degree matrix is diagonal with . Alternatively, the adjacency list representation stores for each vertex, using space versus for the matrix.
The adjacency list is more space-efficient, but the matrix representation is chosen because it exposes algebraic structure: counts walks of length from to , the eigenvalues of reveal expansion and clustering, and matrix-vector products implement one step of message passing over the entire graph simultaneously. This is why the Laplacian — not an edge list — sits at the core of spectral clustering and graph neural networks.
Paths, Connectivity, and Components
A path from to is a sequence of distinct vertices with . A cycle is a closed path (, ). A graph is connected if a path exists between every pair of vertices; otherwise the vertex set partitions into connected components.
A bridge is an edge whose removal disconnects the graph. An articulation point is a vertex whose removal disconnects the graph. Both can be found in time via a single DFS using Tarjan's low-link values: define over DFS tree children and back-edge neighbors.
For directed graphs, strongly connected components (SCCs) are maximal subsets where every vertex reaches every other. Tarjan's SCC algorithm finds all SCCs in using DFS with a stack and low-link tracking. The SCCs form a DAG (the condensation) whose topological sort gives a processing order for dynamic programming on graphs.
Trees and Spanning Trees
A tree is a connected acyclic graph. Any two of the following three conditions imply the third: (1) is connected, (2) is acyclic, (3) . Trees have exactly edges and a unique path between any two vertices.
A spanning tree of is a subgraph that is a tree containing all vertices. Spanning trees can be found by BFS or DFS in ; minimum spanning trees use Kruskal's or Prim's algorithms in .
Cayley's formula counts labeled trees: the number of distinct labeled trees on vertices is . This follows from the Prüfer sequence bijection — every labeled tree corresponds uniquely to a sequence in , and there are such sequences.
Graph Coloring
A proper -coloring assigns one of colors to each vertex so that no adjacent vertices share a color. The chromatic number is the minimum for which a proper coloring exists.
Greedy coloring processes vertices in some order and assigns the smallest available color. This gives where is the maximum degree. Brooks' theorem strengthens this: for any connected graph that is neither a complete graph nor an odd cycle, .
The four-color theorem (Appel and Haken, 1976) states every planar graph satisfies . Determining is NP-complete for ; even approximating it within a factor of is NP-hard.
Matchings and Hall's Theorem
A matching is a set of edges with no shared vertices. A perfect matching covers every vertex. In bipartite graphs , Hall's theorem characterizes when a perfect matching from into exists: for every subset , the neighborhood satisfies .
König's theorem states that in bipartite graphs, the size of the maximum matching equals the size of the minimum vertex cover (a set of vertices covering all edges). This is a rare case where a combinatorial min-max identity holds and can be computed in polynomial time.
Maximum matching is found via augmenting paths: a path from an unmatched vertex to another unmatched vertex alternating between unmatched and matched edges. Augmenting along such a path increases the matching size by 1. The Hopcroft-Karp algorithm finds a maximum bipartite matching in by finding all shortest augmenting paths simultaneously.
Worked Example
Connected components and spanning tree via BFS. Take the graph with edges , leaving vertex 6 isolated. BFS from vertex 1 visits using the queue: start with 1, enqueue neighbors 2 and 3, visit them — the BFS spanning tree has edges . Restarting BFS from vertex 4 discovers component with spanning edge . Vertex 6 forms a singleton component. Total: 3 connected components, 2 spanning tree edges (matching within each component).
Verifying Hall's condition and finding a maximum matching. Consider the bipartite graph with , , and edges -1, -2, -2, -3, -3. Check Hall's condition: , ; , ; , . Hall's condition holds, so a perfect matching exists. Start with matching . Vertex is unmatched; augmenting path -2: extend to . Vertex is unmatched; try -3: augmenting path -3, giving — a perfect matching.
Chromatic number of the Petersen graph. The Petersen graph has 10 vertices, 15 edges, and is 3-regular (). Brooks' theorem gives . Greedy coloring: begin with an outer 5-cycle -2-3-4-5-1. Color 1 with color A, 2 with B, 3 with A, 4 with B, 5 with C (forced since 5 is adjacent to both 1=A and 4=B). The inner pentagram vertices connect across the cycle; working through the adjacencies shows all three colors are needed and no 2-coloring is possible (the graph is not bipartite — it contains odd cycles). Thus , matching Brooks' bound exactly.
Connections
Where Your Intuition Breaks
The four-color theorem guarantees planarity implies 4-colorability, and König's theorem guarantees bipartite matching is polynomial — but these two cases might give the wrong impression that existence results in combinatorics come with efficient algorithms. For general graphs, computing the chromatic number requires exponential time; 3-colorability of planar graphs is NP-complete. The tractability gap runs through graph theory: Hall's condition characterizes which bipartite graphs have perfect matchings in polynomial time, but determining whether a general graph has a Hamiltonian cycle — a superficially similar connectivity question — is NP-complete. The structure of the problem (bipartite vs. general, matching vs. Hamiltonicity) determines tractability in ways that are not predictable from the problem's surface appearance.
The spectrum of the adjacency matrix encodes global graph properties. The largest eigenvalue satisfies , and for regular graphs exactly. More importantly, the second smallest eigenvalue of the Laplacian satisfies if and only if is connected — this algebraic connectivity (Fiedler value) measures how robustly connected the graph is. Spectral graph theory, developed in the next lesson, makes this the foundation for clustering and network analysis.
Graph coloring is the prototypical NP-complete problem. Deciding whether (3-colorability) is NP-complete, making it one of Karp's original 21 NP-complete problems. This hardness propagates across combinatorics and theoretical computer science: register allocation in compilers, frequency assignment in wireless networks, and exam scheduling all reduce to graph coloring. Understanding that the problem is easy for special graph classes (bipartite graphs are 2-colorable, chordal graphs are greedy-colorable in polynomial time) while hard in general is a recurring theme in combinatorial optimization.
There is a fundamental gap between graph-theoretic guarantees and computational tractability. The four-color theorem guarantees every planar graph is 4-colorable, yet no efficient algorithm computes the chromatic number of a general graph — the problem remains NP-complete even for planar graphs (3-colorability of planar graphs is NP-complete). Similarly, Hall's theorem guarantees a perfect matching exists in bipartite graphs satisfying the Hall condition, but computing a maximum matching in general (non-bipartite) graphs requires Edmonds' blossom algorithm, which handles odd cycles through a significantly more complex augmentation strategy. The gap between existence proofs and efficient algorithms is a central concern throughout combinatorics.
Enjoying these notes?
Get new lessons delivered to your inbox. No spam.