Section 1 · 9 min read

Graph theory

Degrees and edge counts, connectivity and cut sets, trees and spanning trees, Euler and Hamilton paths, planarity, matchings and covers, and vertex and edge colouring.

On this page
  1. Degrees and edge counts
  2. Connectivity
  3. Trees
  4. Euler and Hamilton
  5. Planarity
  6. Matchings and covers
  7. Colouring
  8. Worked examples
  9. Common traps
  10. Quick revision

Graph theory is the most tested part of discrete mathematics in GATE CS. The syllabus names connectivity, matching and colouring, but questions also use degree counting, trees and Euler's formula as tools. Unless stated otherwise, graphs here are finite, simple and undirected, with nn vertices and mm edges.

Degrees and edge counts

Handshaking lemma. ∑vdeg⁡(v)=2m\sum_v \deg(v) = 2m. So the number of odd degree vertices is even.

Edge count facts:

  • KnK_n has (n2)\binom{n}{2} edges. Ka,bK_{a,b} has abab edges.
  • A kk-regular graph on nn vertices has nk/2nk/2 edges, so nknk must be even.
  • The complement Gˉ\bar G has (n2)−m\binom{n}{2} - m edges. A self-complementary graph has n(n−1)/4n(n-1)/4 edges, so n≡0n \equiv 0 or 1(mod4)1 \pmod 4.
  • Number of labelled simple graphs on nn vertices: 2(n2)2^{\binom{n}{2}}.

Graphic sequences (Havel-Hakimi). A non-increasing sequence d1≥d2≥⋯≥dnd_1 \ge d_2 \ge \dots \ge d_n is the degree sequence of a simple graph iff removing d1d_1 and subtracting 1 from each of the next d1d_1 entries gives a graphic sequence. Repeat until all zeros (graphic) or a negative entry or impossible step appears (not graphic). Quick rejections: odd sum, or some di≥nd_i \ge n.

Connectivity

A graph is connected if every pair of vertices is joined by a path. The maximal connected subgraphs are the components.

Edge bounds:

  • A connected graph needs at least n−1n - 1 edges.
  • A graph with kk components has at least n−kn - k edges and at most (n−k+12)\binom{n - k + 1}{2} edges (one big clique plus k−1k - 1 isolated vertices).
  • If m>(n−12)m > \binom{n-1}{2}, the graph must be connected.
  • If δ(G)≥(n−1)/2\delta(G) \ge (n - 1)/2, the graph is connected.

Cut vertex: removing it increases the number of components. Bridge (cut edge): removing it increases the number of components. An edge is a bridge iff it lies on no cycle.

Vertex connectivity κ(G)\kappa(G): the fewest vertices whose removal disconnects GG or leaves one vertex. Edge connectivity λ(G)\lambda(G): the fewest edges whose removal disconnects GG. Whitney's inequality: κ(G)≤λ(G)≤δ(G).\kappa(G) \le \lambda(G) \le \delta(G). For KnK_n all three equal n−1n - 1. For a tree with at least 2 vertices, κ=λ=1\kappa = \lambda = 1.

Menger's theorem. The maximum number of internally vertex-disjoint paths between two non-adjacent vertices equals the minimum number of vertices separating them (and the edge version holds with edge-disjoint paths and edge cuts).

Trees

A tree is a connected acyclic graph. For a graph on nn vertices, any two of these imply the third: connected, acyclic, m=n−1m = n - 1.

  • Every tree with n≥2n \ge 2 has at least 2 leaves.
  • Between any two vertices there is exactly one path.
  • A forest with kk components has n−kn - k edges.
  • Leaves of a tree: L=2+∑d≥3(d−2) ndL = 2 + \sum_{d \ge 3} (d - 2)\,n_d, where ndn_d is the number of vertices of degree dd.

Counting spanning trees.

  • Cayley's formula: KnK_n has nn−2n^{n-2} spanning trees (number of labelled trees on nn vertices).
  • Ka,bK_{a,b} has ab−1ba−1a^{b-1} b^{a-1} spanning trees.
  • CnC_n has nn spanning trees (drop any one edge).
  • In general, the matrix tree theorem: the count equals any cofactor of the Laplacian L=D−AL = D - A.

Euler and Hamilton

  • A connected graph has an Euler circuit iff every vertex has even degree, and an Euler path (not circuit) iff exactly two vertices have odd degree.
  • A Hamiltonian cycle visits every vertex once. No simple characterization is known. Dirac's sufficient condition: n≥3n \ge 3 and δ(G)≥n/2\delta(G) \ge n/2. Ore's condition: deg⁡u+deg⁡v≥n\deg u + \deg v \ge n for every non-adjacent pair.
  • KnK_n has (n−1)!/2(n-1)!/2 distinct Hamiltonian cycles. Ka,bK_{a,b} is Hamiltonian iff a=b≥2a = b \ge 2.

Planarity

For a connected planar graph with ff faces (including the outer face), Euler's formula is n−m+f=2.n - m + f = 2. With kk components it becomes n−m+f=k+1n - m + f = k + 1.

Consequences for simple planar graphs with n≥3n \ge 3:

  • m≤3n−6m \le 3n - 6.
  • If there is no triangle, m≤2n−4m \le 2n - 4.
  • Some vertex has degree at most 5.

K5K_5 (m=10>9m = 10 > 9) and K3,3K_{3,3} (m=9>8m = 9 > 8, triangle free) are not planar. Kuratowski: a graph is planar iff it has no subdivision of K5K_5 or K3,3K_{3,3}.

Matchings and covers

A matching is a set of edges with no shared endpoint. A perfect matching covers every vertex, so it needs nn even and has n/2n/2 edges.

Quantity Symbol Meaning
Matching number ν(G)\nu(G) largest matching
Vertex cover number β(G)\beta(G) fewest vertices touching every edge
Independence number α(G)\alpha(G) largest set of pairwise non-adjacent vertices
Edge cover number ρ(G)\rho(G) fewest edges touching every vertex (no isolated vertices)

Key relations:

  • Gallai: α+β=n\alpha + \beta = n. If there are no isolated vertices, ν+ρ=n\nu + \rho = n.
  • Always ν≤β\nu \le \beta (each matched edge needs its own cover vertex) and β≤2ν\beta \le 2\nu.
  • Konig: in a bipartite graph, ν=β\nu = \beta.
  • Hall: a bipartite graph with parts X,YX, Y has a matching saturating XX iff ∣N(S)∣≥∣S∣|N(S)| \ge |S| for every S⊆XS \subseteq X.
  • Every kk-regular bipartite graph (k≥1k \ge 1) has a perfect matching.

Standard counts:

  • Perfect matchings in K2kK_{2k}: (2k−1)(2k−3)⋯3⋅1=(2k)!2kk!(2k-1)(2k-3)\cdots 3 \cdot 1 = \dfrac{(2k)!}{2^k k!}.
  • Perfect matchings in Kk,kK_{k,k}: k!k!.
  • ν(Pn)=⌊n/2⌋\nu(P_n) = \lfloor n/2 \rfloor, ν(Cn)=⌊n/2⌋\nu(C_n) = \lfloor n/2 \rfloor, α(Cn)=⌊n/2⌋\alpha(C_n) = \lfloor n/2 \rfloor, β(Cn)=⌈n/2⌉\beta(C_n) = \lceil n/2 \rceil.

Colouring

A proper vertex colouring gives adjacent vertices different colours. The fewest colours needed is the chromatic number χ(G)\chi(G).

Bounds and facts:

  • χ(G)≥ω(G)\chi(G) \ge \omega(G) (size of the largest clique) and χ(G)≥n/α(G)\chi(G) \ge n / \alpha(G).
  • χ(G)≤Δ(G)+1\chi(G) \le \Delta(G) + 1 (greedy colouring). Brooks: χ≤Δ\chi \le \Delta unless GG is a complete graph or an odd cycle.
  • χ(G)≤2\chi(G) \le 2 iff GG is bipartite iff GG has no odd cycle.
  • Four colour theorem: every planar graph has χ≤4\chi \le 4.
Graph χ\chi
KnK_n nn
CnC_n, nn even / odd 2 / 3
Tree, n≥2n \ge 2 2
Ka,bK_{a,b} 2
Wheel WnW_n (cycle CnC_n plus hub), nn even / odd 3 / 4
Petersen graph 3

Chromatic polynomial P(G,k)P(G, k) counts proper colourings with at most kk colours:

  • KnK_n: k(k−1)⋯(k−n+1)k(k-1)\cdots(k-n+1).
  • Any tree on nn vertices: k(k−1)n−1k(k-1)^{n-1}.
  • CnC_n: (k−1)n+(−1)n(k−1)(k-1)^n + (-1)^n (k-1).
  • Deletion-contraction: P(G,k)=P(G−e,k)−P(G/e,k)P(G, k) = P(G - e, k) - P(G / e, k).

Edge colouring. The chromatic index χ′(G)\chi'(G) is Δ\Delta or Δ+1\Delta + 1 (Vizing). Bipartite graphs have χ′=Δ\chi' = \Delta (Konig). χ′(Kn)=n−1\chi'(K_n) = n - 1 for even nn and nn for odd nn.

Worked examples

Worked example 1: Faces of a planar graph

A connected planar simple graph has 10 vertices, each of degree 3. How many faces does a planar drawing have?

  1. m=10⋅3/2=15m = 10 \cdot 3 / 2 = 15.
  2. f=2−n+m=2−10+15=7f = 2 - n + m = 2 - 10 + 15 = 7.

Sanity check: 15≤3⋅10−6=2415 \le 3 \cdot 10 - 6 = 24.

Worked example 2: Matching versus cover in a non-bipartite graph

Find ν\nu, β\beta, α\alpha for the cycle C7C_7.

  1. α(C7)=3\alpha(C_7) = 3: pick alternate vertices; a fourth would sit next to one of them.
  2. Gallai: β=7−3=4\beta = 7 - 3 = 4.
  3. ν(C7)=3\nu(C_7) = 3: 7 vertices allow at most 3 disjoint edges.

Here ν=3<β=4\nu = 3 < \beta = 4. Konig's equality fails because C7C_7 has an odd cycle.

Worked example 3: Chromatic polynomial of a small graph

Count proper colourings with kk colours of the "triangle with a pendant": vertices a,b,ca, b, c form a triangle and dd is joined only to cc.

  1. Triangle: k(k−1)(k−2)k(k-1)(k-2) ways.
  2. dd must avoid the colour of cc: k−1k - 1 ways.
  3. P=k(k−1)2(k−2)P = k(k-1)^2(k-2). With k=3k = 3: 3⋅4⋅1=123 \cdot 4 \cdot 1 = 12.

The polynomial is zero at k=2k = 2, matching χ=3\chi = 3.

Worked example 4: Edges forcing connectivity

What is the smallest mm such that every simple graph with 9 vertices and mm edges is connected?

The densest disconnected graph is K8K_8 plus an isolated vertex, with (82)=28\binom{8}{2} = 28 edges. So any graph with 2929 edges is connected. Answer: 29.

Worked example 5: Hall's condition

Students s1,s2,s3,s4s_1, s_2, s_3, s_4 list acceptable projects: s1:{A,B}s_1: \{A, B\}, s2:{A}s_2: \{A\}, s3:{A,B}s_3: \{A, B\}, s4:{C,D}s_4: \{C, D\}. Can every student get a distinct project?

Take S={s1,s2,s3}S = \{s_1, s_2, s_3\}. N(S)={A,B}N(S) = \{A, B\}, which has 2 elements, fewer than 3. Hall's condition fails, so no such assignment exists. The maximum matching has size 3 (for example s2As_2A, s1Bs_1B, s4Cs_4C).

Common traps

  • Using m≤3n−6m \le 3n - 6 to prove a graph is planar. It is only a necessary condition.
  • Forgetting the outer face in Euler's formula.
  • Applying Konig's theorem (ν=β\nu = \beta) to non-bipartite graphs.
  • Assuming high minimum degree makes κ\kappa large. Two K4K_4s sharing a vertex have δ=3\delta = 3 but κ=1\kappa = 1.
  • Counting perfect matchings of K2kK_{2k} as (2k)!/2k(2k)!/2^k, forgetting that the order of the kk pairs does not matter.
  • Wheel chromatic numbers: WnW_n with an odd rim needs 4 colours, not 3.
  • Treating χ=2\chi = 2 as "is a tree". Any bipartite graph with an edge has χ=2\chi = 2.

Quick revision

  • ∑deg⁡=2m\sum \deg = 2m; odd degree vertices come in even numbers.
  • kk components: n−k≤m≤(n−k+12)n - k \le m \le \binom{n-k+1}{2}.
  • κ≤λ≤δ\kappa \le \lambda \le \delta.
  • Trees: m=n−1m = n - 1, at least 2 leaves, nn−2n^{n-2} labelled trees.
  • Euler circuit: connected and all degrees even. Euler path: exactly 0 or 2 odd vertices.
  • Planar: n−m+f=2n - m + f = 2, m≤3n−6m \le 3n - 6, triangle free m≤2n−4m \le 2n - 4.
  • α+β=n\alpha + \beta = n; ν+ρ=n\nu + \rho = n (no isolated vertices); bipartite ν=β\nu = \beta.
  • Perfect matchings: K2kK_{2k} has (2k−1)!!(2k-1)!!; Kk,kK_{k,k} has k!k!.
  • χ≤Δ+1\chi \le \Delta + 1; bipartite iff no odd cycle iff χ≤2\chi \le 2.
  • P(Cn,k)=(k−1)n+(−1)n(k−1)P(C_n, k) = (k-1)^n + (-1)^n(k-1); tree: k(k−1)n−1k(k-1)^{n-1}.

Further reading

Test this section