Skip to content

Graph Theory

5.1 Definitions

A graph G=(V,E)G = (V, E) consists of a set of vertices VV and a set of edges EV×VE \subseteq V \times V.

  • Simple graph: no loops, no multiple edges.
  • Directed graph (digraph): edges have direction.
  • Weighted graph: edges have weights.

The degree of a vertex vv, deg(v)\deg(v)Is the number of edges incident to vv.

Theorem 5.1 (Handshaking Lemma). vVdeg(v)=2E\sum_{v \in V} \deg(v) = 2|E|.

Proof. Each edge contributes 1 to the degree of each of its two endpoints. \blacksquare

Corollary 5.2. The number of vertices of odd degree is even.

5.2 Paths, Cycles, and Connectivity

A walk is a sequence of vertices where consecutive vertices are adjacent. A path is a walk With no repeated vertices. A cycle is a path that returns to its starting vertex.

A graph is connected if there is a path between every pair of vertices. A connected component Is a maximal connected subgraph.

Theorem 5.3. A graph with nn vertices and more than (n1)(n2)/2(n-1)(n-2)/2 edges is connected.

5.3 Trees

A tree is a connected acyclic graph. A forest is a disjoint union of trees.

Theorem 5.4. For a graph GG with nn vertices, the following are equivalent:

  1. GG is a tree.
  2. GG is connected and has n1n - 1 edges.
  3. GG is acyclic and has n1n - 1 edges.
  4. Between any two vertices, there is exactly one path.

Cayley”s Formula. The number of labelled trees on nn vertices is nn2n^{n-2}.

5.4 Planarity

A graph is planar if it can be drawn in the plane with no edge crossings.

Theorem 5.5 (Euler’s Formula for Planar Graphs). For a connected planar graph drawn in the plane With VV vertices, EE edges, and FF faces:

VE+F=2V - E + F = 2

Proof sketch. Build the graph edge by edge. Starting from a single vertex (V=1V = 1, E=0E = 0, F=1F = 1), The quantity VE+F=2V - E + F = 2 is preserved when adding an edge: if the edge connects two components, EE and VV each increase by 1; if it splits a face, EE and FF each increase by 1. \blacksquare

Corollary 5.6. For a simple planar graph with V3V \geq 3: E3V6E \leq 3V - 6.

Proof. Every face has at least 3 edges on its boundary, and every edge borders at most 2 faces, So 3F2E3F \leq 2E. By Euler’s formula, F=2V+EF = 2 - V + EGiving 3(2V+E)2E3(2 - V + E) \leq 2EI.e., E3V6E \leq 3V - 6. \blacksquare

Corollary 5.7. K5K_5 and K3,3K_{3,3} are not planar.

Proof. K5K_5 has V=5V = 5, E=10E = 10But 10>3(5)6=910 \gt 3(5) - 6 = 9. For K3,3K_{3,3}, V=6V = 6, E=9E = 9. Since K3,3K_{3,3} has no triangles, every face has at least 4 edges, giving 4F2E4F \leq 2ESo FE/2=4.5F \leq E/2 = 4.5. But VE+F=2V - E + F = 2 gives F=26+9=5>4.5F = 2 - 6 + 9 = 5 \gt 4.5. Contradiction. \blacksquare

Theorem 5.8 (Kuratowski’s Theorem). A graph is planar if and only if it does not contain a Subdivision of K5K_5 or K3,3K_{3,3} as a subgraph.

A subdivision of an edge uvuv replaces uvuv with a path uuwwvv through a new vertex ww. A graph HH is a subdivision of GG if HH can be obtained from GG by subdividing edges.

Worked Example. Show that K3,3K_{3,3} is not planar using Euler’s formula.

Solution

K3,3K_{3,3} has V=6V = 6 vertices and E=9E = 9 edges. It is bipartite (partition sizes 3 and 3), so it Contains no triangles. Every face in a planar embedding must therefore be bounded by at least 4 edges, Giving 4F2E4F \leq 2EI.e., F9/2=4.5F \leq 9/2 = 4.5.

But Euler’s formula gives F=EV+2=96+2=5F = E - V + 2 = 9 - 6 + 2 = 5. Since 5>4.55 \gt 4.5No planar embedding Exists. \blacksquare

5.5 Graph Colouring

A proper kk-colouring assigns one of kk colours to each vertex such that adjacent vertices have Different colours. The chromatic number χ(G)\chi(G) is the minimum kk for which a proper kk-colouring Exists.

Theorem 5.9 (Four Colour Theorem). Every planar graph is 4-colourable.

Theorem 5.10 (Five Colour Theorem). Every planar graph is 5-colourable. (Easier to prove.)

Theorem 5.11 (Greedy Colouring Bound). χ(G)Δ(G)+1\chi(G) \leq \Delta(G) + 1 where Δ(G)\Delta(G) is the Maximum degree.

Theorem 5.12 (Brooks’ Theorem). If GG is connected and is neither a complete graph nor an odd Cycle, then χ(G)Δ(G)\chi(G) \leq \Delta(G).

Chromatic polynomial. The chromatic polynomial P(G,k)P(G, k) counts the number of proper kk-colourings of GG.

Theorem 5.13. P(G,k)P(G, k) is a polynomial in kk.

Deletion-contraction recurrence. For any edge ee of GG:

P(G,k)=P(Ge,k)P(G/e,k)P(G, k) = P(G - e, k) - P(G / e, k)

Where GeG - e is GG with edge ee deleted, and G/eG / e is GG with ee contracted (its endpoints Merged).

Worked Example. Find the chromatic polynomial of C4C_4 (the 4-cycle).

Solution

Label the vertices of C4C_4 as v1,v2,v3,v4v_1, v_2, v_3, v_4 with edges v1v2v_1v_2, v2v3v_2v_3, v3v4v_3v_4, v4v1v_4v_1.

Pick edge e=v1v2e = v_1v_2.

GeG - e is a path on 4 vertices (a tree): P(Ge,k)=k(k1)3P(G - e, k) = k(k-1)^3.

G/eG / e merges v1v_1 and v2v_2Yielding C3C_3 (triangle): P(C3,k)=k(k1)(k2)P(C_3, k) = k(k-1)(k-2).

Therefore P(C4,k)=k(k1)3k(k1)(k2)=k(k1)[(k1)2(k2)]=k(k1)(k23k+3)P(C_4, k) = k(k-1)^3 - k(k-1)(k-2) = k(k-1)[(k-1)^2 - (k-2)] = k(k-1)(k^2 - 3k + 3).

Checking: P(C4,2)=2(1)(46+3)=2P(C_4, 2) = 2(1)(4 - 6 + 3) = 2 (two 2-colourings: alternating), and P(C4,3)=32(99+3)=18P(C_4, 3) = 3 \cdot 2 \cdot (9 - 9 + 3) = 18. \blacksquare

Worked Example. Find χ(Kn)\chi(K_n) and χ(Km,n)\chi(K_{m,n}).

Solution

KnK_n (complete graph on nn vertices): every pair of vertices is adjacent, so all nn vertices must Receive distinct colours. Hence χ(Kn)=n\chi(K_n) = n.

Km,nK_{m,n} (complete bipartite graph): no two vertices within the same partition are adjacent, so we Can colour all vertices in the first partition with colour 1 and all in the second with colour 2. Hence χ(Km,n)=2\chi(K_{m,n}) = 2 (for m,n1m, n \geq 1).

Worked Example. Find the chromatic polynomial of K3K_3 (triangle).

Solution

Choose a colour for vertex 1: kk choices. Choose a colour for vertex 2 (different from vertex 1): k1k - 1 choices. Choose a colour for vertex 3 (different from both): k2k - 2 choices.

P(K3,k)=k(k1)(k2)P(K_3, k) = k(k-1)(k-2).

Checking: P(K3,2)=210=0P(K_3, 2) = 2 \cdot 1 \cdot 0 = 0 (not 2-colourable, as expected). P(K3,3)=6P(K_3, 3) = 6.

5.6 Euler and Hamilton Paths

An Euler path visits every edge exactly once. An Euler circuit is an Euler path that starts And ends at the same vertex.

Theorem 5.14. A connected graph has an Euler circuit if and only if every vertex has even degree. It has an Euler path (but not circuit) if and only if exactly two vertices have odd degree.

Proof (sufficiency). If every vertex has even degree, start at any vertex and follow edges, never Reusing an edge. Since all degrees are even, the walk can only terminate at the starting vertex, Forming a circuit CC. If CC uses all edges, we are done. Otherwise, remove CC‘s edges; each Remaining component has all vertices of even degree (each lost an even number of incident edges). By induction, each component has an Euler circuit. Splicing these circuits into CC at shared Vertices yields an Euler circuit of the full graph. \blacksquare

Worked Example. Does K2,3K_{2,3} have an Euler circuit? An Euler path?

Solution

K2,3K_{2,3} has 5 vertices. The two vertices in the first partition each have degree 3 (connected to All three in the second partition). The three vertices in the second partition each have degree 2.

Vertices of odd degree: two (each of degree 3). Since exactly two vertices have odd degree, K2,3K_{2,3} has an Euler path (starting at one odd-degree vertex, ending at the other) but not an Euler circuit.

A Hamilton path visits every vertex exactly once. A Hamilton circuit is a Hamilton path that Returns to the start.

Theorem 5.15 (Dirac’s Theorem). If GG is a simple graph with n3n \geq 3 vertices and deg(v)n/2\deg(v) \geq n/2 for every vertex, then GG has a Hamilton circuit.

Theorem 5.16 (Ore’s Theorem). If GG is a simple graph with n3n \geq 3 vertices and deg(u)+deg(v)n\deg(u) + \deg(v) \geq n for every pair of non-adjacent vertices u,vu, vThen GG has a Hamilton Circuit.

Note that Dirac’s theorem is a corollary of Ore’s theorem.

Worked Example. Does K2,3K_{2,3} have a Hamilton circuit?

Solution

K2,3K_{2,3} has 5 vertices. A Hamilton circuit must visit all 5 vertices and return. Label the Partitions as A=a1,a2A = \\{a_1, a_2\\} and B=b1,b2,b3B = \\{b_1, b_2, b_3\\}. Any cycle in a bipartite graph alternates Between the two partitions. A Hamilton cycle would alternate between AA and BBRequiring A=B|A| = |B|. But A=23=B|A| = 2 \neq 3 = |B|So no Hamilton circuit exists.

However, K2,3K_{2,3} does have Hamilton paths (e.g., a1,b1,a2,b2,b3a_1, b_1, a_2, b_2, b_3 — wait, this doesn’t Alternate properly). Actually, in K2,3K_{2,3} edges only exist between AA and BB. A path must alternate A,B,A,B,A, B, A, B, \ldots or B,A,B,A,B, A, B, A, \ldots. A Hamilton path visits all 5 vertices, so it has the Form a,b,a,b,aa, b, a, b, a (length 5, starting and ending in AA) or b,a,b,a,bb, a, b, a, b (length 5, starting And ending in BB). The first requires 3 vertices from AABut A=2|A| = 2. The second requires 3 Vertices from BBAnd B=3|B| = 3. So a Hamilton path exists: e.g., b1,a1,b2,a2,b3b_1, a_1, b_2, a_2, b_3.

Worked Example. Let GG have vertices 1,2,3,4,5\\{1, 2, 3, 4, 5\\} and edges 12,23,34,45,51,13,3512, 23, 34, 45, 51, 13, 35. Does GG have an Euler circuit or Euler path?

Solution

Degrees: deg(1)=3\deg(1) = 3, deg(2)=2\deg(2) = 2, deg(3)=4\deg(3) = 4, deg(4)=2\deg(4) = 2, deg(5)=3\deg(5) = 3. Two vertices (1 and 5) have odd degree. Since exactly two vertices have odd degree, GG has an Euler Path (starting at 1, ending at 5) but no Euler circuit.

One Euler path: 123453151 \to 2 \to 3 \to 4 \to 5 \to 3 \to 1 \to 5. All 7 edges are used exactly once. ✓

Algorithm (Hierholzer’s). To find an Euler circuit: start at any vertex, follow unused edges Until returning to the start. If unused edges remain, find a vertex on the current circuit with Unused edges, find a subtour, and splice it in. Repeat until all edges are used.

:::caution Common Pitfall Determining whether a graph has a Hamilton path/circuit is NP-complete , whereas Euler Paths/circuits can be determined in polynomial time using the degree condition. Do not confuse the two.

5.7 Matching Theory

A matching MM in a graph G=(V,E)G = (V, E) is a set of pairwise disjoint edges (no two share an Endpoint). A vertex is matched if it is an endpoint of an edge in MM; otherwise it is unmatched. A perfect matching covers every vertex.

Theorem 5.17 (Hall’s Marriage Theorem, 1935). Let G=(V,E)G = (V, E) be a bipartite graph with Partitions XX and YY. There exists a matching that covers every vertex in XX if and only if for Every subset SXS \subseteq X

N(S)S|N(S)| \geq |S|

Where N(S) = \\{y \in Y : \exists\, x \in S\; \mathrm{with{}\; xy \in E\\} is the neighbourhood of SS.

Proof (necessity). If a matching covers XXEach xSx \in S is matched to a distinct yN(S)y \in N(S) So N(S)S|N(S)| \geq |S|.

Proof (sufficiency by induction on X|X|). Base case X=1|X| = 1: Hall’s condition gives N(x)1|N(\\{x\\})| \geq 1 So xx has a neighbour, and we can match xx to it.

Inductive step. Consider two cases.

Case 1: For every nonempty proper subset SXS \subsetneq X, N(S)>S|N(S)| \gt |S|. Pick any edge xyxy. In G=Gx,yG' = G - \\{x, y\\}Hall’s condition still holds (removing one element from each side preserves the Strict inequality). By the induction hypothesis, XxX \setminus \\{x\\} can be matched in GG'. Adding xyxy Gives the desired matching.

Case 2: There exists a nonempty proper TXT \subsetneq X with N(T)=T|N(T)| = |T|. Match TT to N(T)N(T) By the induction hypothesis. In G=G(TN(T))G'' = G - (T \cup N(T))For any SXTS \subseteq X \setminus T NG(S)=NG(ST)N(T)N_{G''}(S) = N_G(S \cup T) \setminus N(T)So

NG(S)=NG(ST)N(T)STT=S|N_{G''}(S)| = |N_G(S \cup T)| - |N(T)| \geq |S \cup T| - |T| = |S|

Where the inequality uses Hall’s condition on STS \cup T in GG. By the induction hypothesis, XTX \setminus T can be matched in GG''. Combining with the matching on TT gives the result. \blacksquare

Worked Example. Let X=a,b,c,dX = \\{a, b, c, d\\} and Y=1,2,3,4,5Y = \\{1, 2, 3, 4, 5\\} with edges aa1,21,2; bb1,21,2; cc2,32,3; dd3,4,53,4,5. Does a matching covering XX exist?

Solution

Check Hall’s condition for every subset SXS \subseteq X:

  • S=1|S| = 1: each vertex has at least 1 neighbour. ✓
  • S=2|S| = 2: N(a,b)=1,2N(\\{a, b\\}) = \\{1, 2\\}, N=2|N| = 2. N(a,c)=1,2,3N(\\{a, c\\}) = \\{1, 2, 3\\}, N=3|N| = 3. Similarly all pairs have N2|N| \geq 2. ✓
  • S=3|S| = 3: N(a,b,c)=1,2,3N(\\{a, b, c\\}) = \\{1, 2, 3\\}, N=3|N| = 3. N(a,c,d)=1,2,3,4,5N(\\{a, c, d\\}) = \\{1, 2, 3, 4, 5\\}, N=5|N| = 5. All triples have N3|N| \geq 3. ✓
  • S=4|S| = 4: N(X)=1,2,3,4,5N(X) = \\{1, 2, 3, 4, 5\\}, N=54|N| = 5 \geq 4. ✓

Hall’s condition is satisfied, so a matching exists. One such matching: aa11, bb22 cc33, dd44.

5.8 Network Flows

A flow network is a directed graph G=(V,E)G = (V, E) with a source ssA sink ttAnd a capacity function c:ER0c : E \to \mathbb{{'}R{}'}_{\geq 0}. A flow f:ER0f : E \to \mathbb{{'}R{}'}_{\geq 0} Satisfies:

  1. Capacity constraint: 0f(e)c(e)0 \leq f(e) \leq c(e) for all eEe \in E.
  2. Flow conservation: for all vVs,tv \in V \setminus \\{s, t\\} \sum_{e\; \mathrm{into{}\; v} f(e) = \sum_{e\; \mathrm{out\; of{}\; v} f(e).

The value of a flow is |f| = \sum_{e\; \mathrm{out\; of{}\; s} f(e) - \sum_{e\; \mathrm{into{}\; s} f(e).

An s-t cut (S,T)(S, T) partitions VV into SS (containing ss) and TT (containing tt). The capacity of the cut is c(S,T)=uS,vTc(uv)c(S, T) = \sum_{u \in S, v \in T} c(uv).

Theorem 5.18 (Max-Flow Min-Cut Theorem). In any flow network, the maximum value of a flow from ss to tt equals the minimum capacity of an ss-tt cut.

Proof sketch. Let ff^* be a maximum flow. Define the residual graph GfG_f with the same Vertices and residual capacity cf(uv)=c(uv)f(uv)c_f(uv) = c(uv) - f(uv) for forward edges and cf(vu)=f(uv)c_f(vu) = f(uv) For backward edges. Let SS be the set of vertices reachable from ss in GfG_{f^*} via edges with Positive residual capacity. Since ff^* is maximum, tSt \notin S (otherwise we could augment the Flow). The cut (S,VS)(S, V \setminus S) has capacity exactly f|f^*| (all forward edges are saturated, All backward edges have zero flow). Therefore f=c(S,VS)|f^*| = c(S, V \setminus S) \geq minimum cut Capacity f\geq |f^*|Giving equality. \blacksquare

Theorem 5.19 (Integrality Theorem). If all capacities are integers, there exists a maximum flow Where every f(e)f(e) is an integer.

Corollary 5.20. If all capacities are integers, the maximum flow value is an integer.

The Ford—Fulkerson method repeatedly finds augmenting paths in the residual graph and pushes Flow along them. When capacities are integers, each augmentation increases the flow by at least 1, Guaranteeing termination.

:::