Graph Theory
Graphs and their terminology, the famous families $K_n, C_n, W_n, Q_n, K_{m,n}$, bipartite graphs, and Euler & Hamiltonian paths.
6.1 Graph Terminology
Vocabulary you must know
- Adjacent vertices: $u, v$ adjacent iff $\{u, v\} \in E$.
- Incident: edge $e = \{u,v\}$ is incident with $u$ and with $v$.
- Loop: edge from $v$ to itself.
- Multi-edge: two edges with the same endpoints.
- Degree $\deg(v)$: number of edges incident to $v$. Loops contribute 2.
- Isolated vertex: degree 0.
- Pendant vertex: degree 1.
- Neighborhood $N(v)$: set of vertices adjacent to $v$.
- Path: sequence of vertices $v_0, v_1, \ldots, v_k$ with each consecutive pair an edge.
- Cycle: a path that returns to its start with no repeated vertices except endpoints.
- Connected: there's a path between every pair.
- Connected component: maximal connected subgraph.
- Cut vertex / bridge: removal disconnects the graph.
6.2 Types of graphs
| Type | Directed? | Multi-edges? | Loops? |
|---|---|---|---|
| Simple graph | No | No | No |
| Multigraph | No | Yes | No |
| Pseudograph | No | Yes | Yes |
| Simple directed graph | Yes | No | No |
| Directed multigraph | Yes | Yes | Yes |
Handshaking Lemma
Why: each edge contributes 2 to the degree sum (one for each endpoint). For directed graphs, $\sum \deg^+(v) = \sum \deg^-(v) = |E|$.
Corollary: even number of odd-degree vertices
Since the sum is even, and even-degree contributions add to even, the odd-degree contributions must also sum to even — which only happens if there's an even count of them.
Bounds from degree
Let $G$ have $v$ vertices, $e$ edges, max degree $M$ and min degree $m$: $$\dfrac{2e}{v} \geq m, \quad \dfrac{2e}{v} \leq M.$$ The left side is the average degree; it lies between $m$ and $M$. Proof by the handshake lemma.
6.4 Some Common Graphs
$K_n$ — complete graph on $n$ vertices
Every pair of distinct vertices is connected. Every vertex has degree $n-1$, so by handshake $|E| = n(n-1)/2$.
(Example: $K_4$, 4 vertices, 6 edges, each degree 3.)
$C_n$ — cycle graph on $n$ vertices
Vertices in a single closed loop: $v_1 - v_2 - \cdots - v_n - v_1$. Every vertex has degree 2; $|E| = n$.
$C_5$: 5 vertices, 5 edges.
$W_n$ — wheel graph
$C_n$ plus a "hub" vertex connected to all $n$ cycle vertices. Hub has degree $n$; rim vertices have degree 3. Total vertices: $n+1$. Total edges: $n + n = 2n$.
$W_5$: cycle $C_5$ + hub. 6 vertices, 10 edges.
$Q_n$ — $n$-cube (hypercube)
Vertices: all $n$-bit binary strings ($2^n$ of them). Two vertices adjacent iff they differ in exactly one bit. Each vertex has degree $n$; total edges $= n\cdot 2^{n-1}$.
$Q_3$: 8 vertices, each degree 3, $|E| = 12$.
$K_{m,n}$ — complete bipartite graph
Two parts of sizes $m, n$; every left vertex connected to every right vertex. $|E| = mn$. Degrees: left vertices have degree $n$, right have degree $m$.
$K_{2,2}$: 4 vertices, 4 edges.
Summary table
| Graph | $|V|$ | $|E|$ | Each degree |
|---|---|---|---|
| $K_n$ | $n$ | $\binom{n}{2} = n(n-1)/2$ | $n-1$ |
| $C_n$ | $n$ | $n$ | $2$ |
| $W_n$ | $n+1$ | $2n$ | hub: $n$, rim: $3$ |
| $Q_n$ | $2^n$ | $n\cdot 2^{n-1}$ | $n$ |
| $K_{m,n}$ | $m+n$ | $mn$ | left $n$, right $m$ |
6.5 Bipartite Graphs
Characterization theorem
Algorithmic check: BFS from any vertex, alternating colours. If you hit a conflict, the graph contains an odd cycle.
Which standard graphs are bipartite?
- $K_n$: bipartite iff $n \leq 2$. (For $n \geq 3$ it contains a triangle, an odd cycle.)
- $C_n$: bipartite iff $n$ is even.
- $W_n$: never bipartite (the hub + two adjacent rim vertices form a triangle).
- $Q_n$: always bipartite. Partition by parity of bit count.
- $K_{m,n}$: always bipartite (by construction).
Edge bound for bipartite simple graphs
Claim. If $G$ is a bipartite simple graph with $v$ vertices and $e$ edges, then $e \leq v^2/4$.
Proof. Let $|V_1| = a, |V_2| = b = v - a$. The maximum number of edges (achieved by $K_{a,b}$) is $ab$. By AM–GM, $ab \leq ((a+b)/2)^2 = v^2/4$. ∎
Hall's Marriage Theorem (perfect matchings)
6.6a Euler Paths & Circuits
Euler circuit: an Euler path that starts and ends at the same vertex.
Existence (Euler's theorem)
• an Euler circuit $\iff$ every vertex has even degree;
• an Euler path (non-circuit) $\iff$ exactly two vertices have odd degree (and you must start at one and end at the other).
The Seven Bridges of Königsberg
Modeling the four landmasses as vertices and the seven bridges as edges, you get a multigraph with degrees $(3, 3, 3, 5)$ — all odd. Four odd-degree vertices means no Euler path exists. Hence the citizens couldn't do it.
Example. Does $K_5$ have an Euler circuit?
$K_5$: every vertex has degree 4 (even). So yes — an Euler circuit exists. (You can verify by drawing the star pentagram.)
Example. Does $K_4$ have an Euler circuit?
$K_4$: every vertex has degree 3 (odd). Four odd-degree vertices → no Euler path or circuit.
For directed graphs
An Euler circuit exists $\iff$ graph is connected (in the underlying undirected sense) and $\deg^+(v) = \deg^-(v)$ for every vertex.
6.6b Hamiltonian Paths & Cycles
Hamiltonian cycle: a Hamiltonian path that returns to the start.
No simple characterization!
Unlike Euler paths, there's no easy degree-based test. Deciding Hamiltonicity is NP-complete.
Sufficient (but not necessary) conditions
Ore (1960). If $\deg(u) + \deg(v) \geq n$ for every nonadjacent pair $u, v$, then $G$ has a Hamiltonian cycle. (Generalises Dirac.)
Which standard graphs are Hamiltonian?
- $K_n$ ($n \geq 3$): always Hamiltonian.
- $C_n$: trivially Hamiltonian (the cycle itself).
- $W_n$: Hamiltonian (go around the rim).
- $Q_n$ ($n \geq 1$): Hamiltonian. Construction via Gray code.
- $K_{m,n}$ with $m = n$: Hamiltonian. With $m \neq n$: not Hamiltonian (any cycle in a bipartite graph has even length and must alternate sides; needs $m = n$).
Euler vs. Hamilton at a glance
| Visits each… | Easy test? | |
|---|---|---|
| Euler path/circuit | edge once | YES — count odd-degree vertices |
| Hamilton path/cycle | vertex once | NO — NP-complete in general |
Interactive Graph Sandbox
Click in the empty canvas space to create vertices. Hold Shift and drag from one vertex to another to draw edges. Hover and press Backspace or Delete to delete vertices/edges.
Graph Properties
Problem Bank — Graph Theory
Drawn from DPP 18, homework worksheets, and midterm papers. Solve each on paper using formal definitions and Handshaking arguments before checking the solution.
Determine the number of vertices $|V|$ and edges $|E|$ in the following standard graph families: (a) $K_n$, (b) $C_n$, (c) $W_n$, (d) $K_{m,n}$, (e) $Q_n$. Justify the edge counts.
Goal: Find and mathematically justify the vertex and edge counts for standard graph families.
Step-by-Step Derivation:
- (a) Complete Graph $K_n$:
- Vertices: By definition, $K_n$ has $n$ vertices.
- Edges: Every pair of vertices is connected by a unique edge. The number of ways to choose 2 vertices from $n$ is: $$|E| = \binom{n}{2} = \frac{n(n-1)}{2}$$
- (b) Cycle Graph $C_n$ ($n \geq 3$):
- Vertices: By definition, $C_n$ has $n$ vertices.
- Edges: The vertices are arranged in a closed loop, where $v_i$ connects to $v_{i+1}$ (and $v_n$ connects to $v_1$). This forms exactly $n$ edges.
- (c) Wheel Graph $W_n$ ($n \geq 3$):
- Vertices: Consists of a cycle $C_n$ of $n$ rim vertices plus a single central hub vertex. Thus, $|V| = n + 1$.
- Edges: Consists of the $n$ edges forming the rim cycle, plus $n$ "spoke" edges connecting the hub to each of the $n$ rim vertices. Thus, $|E| = 2n$.
- (d) Complete Bipartite Graph $K_{m,n}$:
- Vertices: The vertex set is partitioned into two disjoint subsets of sizes $m$ and $n$. Thus, $|V| = m + n$.
- Edges: Every vertex in the first partition connects to every vertex in the second partition. This yields $|E| = m \cdot n$.
- (e) Hypercube Graph $Q_n$:
- Vertices: Vertices are represented by binary strings of length $n$. Since there are $2$ options ($0$ or $1$) for each of the $n$ bits, $|V| = 2^n$.
- Edges: Two vertices are adjacent if their binary strings differ in exactly $1$ bit. Thus, each vertex has exactly $n$ neighbors (making the graph $n$-regular). By the Handshaking Lemma: $$2|E| = \sum_{v \in V} \deg(v) = n \cdot |V| = n \cdot 2^n \implies |E| = n \cdot 2^{n-1}$$
∎
For what values of $n$ are these graphs bipartite: (a) $K_n$, (b) $C_n$, (c) $W_n$, (d) $Q_n$? Justify your answers.
Goal: Determine the bipartiteness condition for each graph family using the characterization that a graph is bipartite if and only if it contains no odd-length cycles.
Step-by-Step Analysis:
- (a) Complete Graph $K_n$: If $n \geq 3$, $K_n$ contains a triangle ($C_3$, which is an odd cycle). Thus, it cannot be bipartite. For $n=1$ (no edges) and $n=2$ (a single edge, no cycles), the graph contains no odd cycles. Condition: Bipartite iff $n \leq 2$.
- (b) Cycle Graph $C_n$: $C_n$ contains a single cycle of length $n$. If $n$ is odd, it is an odd cycle, so it is not bipartite. If $n$ is even, it contains no odd cycles, so it is bipartite. Condition: Bipartite iff $n$ is even.
- (c) Wheel Graph $W_n$: For any wheel graph, any two adjacent vertices on the rim form a triangle ($C_3$) with the central hub vertex. Since $C_3$ is an odd cycle, $W_n$ always contains an odd cycle. Condition: Never bipartite for any $n \geq 3$.
- (d) Hypercube Graph $Q_n$:
Let the vertices be represented by binary strings of length $n$. Partition the vertices into:
- $V_1$: strings containing an even number of 1s
- $V_2$: strings containing an odd number of 1s
∎
Find the degree sequence of: (a) $K_4$, (b) $C_4$, (c) $W_4$, (d) $K_{2,3}$, (e) $Q_3$, (f) $K_{m,n}$, (g) $K_n$. List in non-increasing order.
Goal: Calculate the degree sequence for each specified graph.
Step-by-Step Derivation:
- (a) $K_4$: Every vertex in a complete graph on $n$ vertices has degree $n-1$. $$\text{Degree sequence: } (3, 3, 3, 3)$$
- (b) $C_4$: Every vertex in a cycle has exactly 2 neighbors. $$\text{Degree sequence: } (2, 2, 2, 2)$$
- (c) $W_4$: Consists of a central hub (connected to all 4 rim vertices, degree 4) and 4 rim vertices (each connected to 2 rim neighbors and the hub, degree 3). $$\text{Degree sequence: } (4, 3, 3, 3, 3)$$
- (d) $K_{2,3}$: Bipartite graph. The 2 vertices in the first partition connect to 3 vertices $\implies$ degree 3. The 3 vertices in the second partition connect to 2 vertices $\implies$ degree 2. $$\text{Degree sequence: } (3, 3, 2, 2, 2)$$
- (e) $Q_3$: Every vertex in $Q_3$ is 3-regular because there are 3 bits to flip. $$\text{Degree sequence: } (3, 3, 3, 3, 3, 3, 3, 3)$$
- (f) $K_{m,n}$: Consists of $m$ vertices of degree $n$, and $n$ vertices of degree $m$. $$\text{Degree sequence: } (\underbrace{n, \dots, n}_{m \text{ times}}, \underbrace{m, \dots, m}_{n \text{ times}}) \quad \text{sorted in non-increasing order}$$
- (g) $K_n$: A complete graph of size $n$ has every vertex connected to all other $n-1$ vertices. $$\text{Degree sequence: } (n-1, n-1, \dots, n-1) \quad \text{of length } n$$
∎
For each degree sequence, determine the number of edges and construct a simple graph realizing it:
(a) $4, 3, 3, 2, 2$ (b) $5, 2, 2, 2, 2, 1$.
Goal: Compute the edge count using the Handshaking Lemma and construct a simple graph for each degree sequence.
Step-by-Step Derivation:
- (a) Sequence: $4, 3, 3, 2, 2$:
- Calculate edge count $|E|$: By the Handshaking Lemma, $\sum \deg(v) = 2|E|$: $$4 + 3 + 3 + 2 + 2 = 14 \implies 2|E| = 14 \implies |E| = 7$$
- Construction: Let the vertices be $\{A, B, C, D, E\}$ with target degrees $4, 3, 3, 2, 2$. Since $A$ has degree 4, it must connect to all other 4 vertices: $$\text{Edges: } \{A, B\}, \{A, C\}, \{A, D\}, \{A, E\}$$ The remaining degrees required are $B: 2, C: 2, D: 1, E: 1$. Connect $B$ to $C$ (both now need 1 more edge) and $B$ to $D$ (D is fully satisfied). Connect $C$ to $E$ (both are now satisfied). $$\text{Additional Edges: } \{B, C\}, \{B, D\}, \{C, E\}$$ This gives a total of 7 edges. Verifying degrees: $\deg(A)=4, \deg(B)=3, \deg(C)=3, \deg(D)=2, \deg(E)=2$.
- (b) Sequence: $5, 2, 2, 2, 2, 1$:
- Calculate edge count $|E|$: $$5 + 2 + 2 + 2 + 2 + 1 = 14 \implies 2|E| = 14 \implies |E| = 7$$
- Construction: Let the vertices be $\{H, A, B, C, D, E\}$ with target degrees $5, 2, 2, 2, 2, 1$. Since $H$ has degree 5, it connects to all other 5 vertices: $$\text{Edges: } \{H, A\}, \{H, B\}, \{H, C\}, \{H, D\}, \{H, E\}$$ The remaining degrees required are $A: 1, B: 1, C: 1, D: 1, E: 0$. Vertex $E$ is already satisfied (degree 1). We add 2 more edges to satisfy the remaining vertices: connect $A$ to $B$, and $C$ to $D$. $$\text{Additional Edges: } \{A, B\}, \{C, D\}$$ Verifying degrees: $\deg(H)=5, \deg(A)=2, \deg(B)=2, \deg(C)=2, \deg(D)=2, \deg(E)=1$.
∎
Let $m$ and $M$ be the minimum and maximum degrees in a simple graph $G$. Prove that $m \leq \dfrac{2e}{v} \leq M$.
Goal: Formally prove that the average degree $\frac{2e}{v}$ is bounded by the minimum and maximum degrees of the graph.
Proof:
- Let $V = \{v_1, v_2, \dots, v_v\}$ be the vertex set of the graph. By definition, for every vertex $v_i \in V$, its degree satisfies: $$m \leq \deg(v_i) \leq M$$
- Summing this inequality over all $v$ vertices: $$\sum_{i=1}^v m \leq \sum_{i=1}^v \deg(v_i) \leq \sum_{i=1}^v M$$ $$v \cdot m \leq \sum_{i=1}^v \deg(v_i) \leq v \cdot M$$
- By the Handshaking Lemma, the sum of all vertex degrees is equal to twice the number of edges: $$\sum_{i=1}^v \deg(v_i) = 2e$$
- Substitute $2e$ into the inequality: $$v \cdot m \leq 2e \leq v \cdot M$$
- Since $v > 0$, we divide the entire inequality by $v$: $$m \leq \frac{2e}{v} \leq M$$
Thus, the bounds hold. ∎
For which values of $n$ are $K_n, C_n, W_n, Q_n$ regular? When is $K_{m,n}$ regular? Find $|V|$ of a 4-regular graph with 10 edges.
Goal: Determine the regularity conditions for standard graph families and compute the vertex count of a 4-regular graph with 10 edges.
Step-by-Step Analysis:
- Regularity of Families:
- $K_n$ is $(n-1)$-regular for all $n \geq 1$.
- $C_n$ is 2-regular for all $n \geq 3$.
- $W_n$ consists of a hub of degree $n$ and rim vertices of degree 3. For $W_n$ to be regular, we must have $n=3$. $W_3$ is isomorphic to $K_4$, which is 3-regular. Thus, $W_n$ is regular only if $n=3$.
- $Q_n$ is $n$-regular for all $n \geq 1$.
- $K_{m,n}$ is regular if and only if $m=n$ (it is then $n$-regular).
- Calculation for 4-regular graph with $e=10$: Let $v = |V|$ be the number of vertices. Since the graph is 4-regular, the degree of every vertex is 4. Applying the Handshaking Lemma: $$4v = 2e \implies 4v = 2(10) = 20 \implies v = 5$$
Conclusion: The vertex count for the 4-regular graph with 10 edges is 5 (realized by $K_5$). ∎
Show that for a bipartite simple graph with $v$ vertices and $e$ edges, $e \leq v^2/4$.
Goal: Prove that the number of edges $e$ in any simple bipartite graph on $v$ vertices is at most $v^2/4$.
Proof:
- Let $G = (V, E)$ be a simple bipartite graph. By definition, the vertex set can be partitioned into two disjoint subsets $V_1$ and $V_2$ of sizes $k$ and $v-k$, respectively, such that all edges connect a vertex in $V_1$ to a vertex in $V_2$.
- The maximum possible number of edges in a simple bipartite graph is achieved when every vertex in $V_1$ is connected to every vertex in $V_2$ (a complete bipartite graph $K_{k, v-k}$): $$e \leq k(v-k)$$
- We maximize the function $f(k) = k(v-k)$ over the real numbers. Using the Arithmetic Mean-Geometric Mean (AM-GM) inequality: $$\sqrt{k(v-k)} \leq \frac{k + (v-k)}{2} = \frac{v}{2}$$
- Squaring both sides of the inequality: $$k(v-k) \leq \frac{v^2}{4}$$
- Since $e \leq k(v-k)$, we conclude: $$e \leq \frac{v^2}{4}$$
This completes the proof. ∎
Prove that every undirected graph has an even number of vertices of odd degree.
Goal: Prove that the number of vertices with odd degree in an undirected graph must be even.
Proof:
- Let $G = (V, E)$ be an undirected graph. Partition the vertex set $V$ into two disjoint sets:
- $V_e$: vertices with even degrees
- $V_o$: vertices with odd degrees
- Apply the Handshaking Lemma: $$\sum_{v \in V} \deg(v) = 2e$$
- Split the sum into the two partitioned sets: $$\sum_{v \in V_e} \deg(v) + \sum_{v \in V_o} \deg(v) = 2e$$
- Analyze the parities:
- The right-hand side $2e$ is even.
- The sum $\sum_{v \in V_e} \deg(v)$ is a sum of even integers, which must be even.
- Rearranging the terms: $$\sum_{v \in V_o} \deg(v) = 2e - \sum_{v \in V_e} \deg(v)$$ Since the difference of two even numbers is even, the sum $\sum_{v \in V_o} \deg(v)$ must be even.
- The sum $\sum_{v \in V_o} \deg(v)$ consists entirely of odd integers. A sum of odd integers is even if and only if it contains an even number of terms. Thus, the cardinality of $V_o$ must be even.
This completes the proof. ∎
Prove that a simple graph $G$ is bipartite if and only if it contains no cycles of odd length.
Goal: Prove the bidirectional equivalence between a graph being bipartite and having no odd cycles.
Proof:
- $(\Rightarrow)$ Assume $G$ is bipartite: Let $V_1, V_2$ be the bipartition of $V$. Suppose $G$ contains a cycle $C = v_0, v_1, v_2, \dots, v_k, v_0$. Without loss of generality, let $v_0 \in V_1$. Because edges only connect $V_1$ to $V_2$, the cycle path must alternate partitions: - $v_1 \in V_2$ - $v_2 \in V_1$ In general, $v_i \in V_1$ if $i$ is even, and $v_i \in V_2$ if $i$ is odd. Since $\{v_k, v_0\}$ is an edge and $v_0 \in V_1$, we must have $v_k \in V_2$, which requires $k$ to be odd. The cycle length is $k+1$. Since $k$ is odd, $k+1$ is even. Thus, all cycles in $G$ must be of even length, and no odd cycles can exist.
- $(\Leftarrow)$ Assume $G$ has no odd cycles: Assume without loss of generality that $G$ is connected. Choose an arbitrary vertex $v_0 \in V$. For each $u \in V$, let $d(u)$ be the length of the shortest path from $v_0$ to $u$. Partition $V$ into two sets: - $V_1 = \{u \in V : d(u) \text{ is even}\}$ - $V_2 = \{u \in V : d(u) \text{ is odd}\}$ Suppose for contradiction that two adjacent vertices $x$ and $y$ lie in the same set, say $V_1$. Let $P_x$ and $P_y$ be the shortest paths from $v_0$ to $x$ and $y$, respectively. Let $z$ be the last common vertex on these paths. The path from $z$ to $x$ has length $d(x) - d(z)$, and the path from $z$ to $y$ has length $d(y) - d(z)$. Combining these paths with the edge $\{x, y\}$ forms a cycle of length: $$(d(x) - d(z)) + (d(y) - d(z)) + 1 = d(x) + d(y) - 2d(z) + 1$$ Since $d(x)$ and $d(y)$ are both even, their sum is even. Thus, the cycle length is $\text{even} - \text{even} + 1 = \text{odd}$. This contradicts the assumption that $G$ has no odd cycles. Thus, no adjacent vertices lie in the same set, proving $G$ is bipartite.
∎
The Königsberg bridges multigraph has four vertices with degrees $(3, 3, 3, 5)$. Prove why there is no Euler path.
Goal: Formally prove that the Königsberg bridges multigraph lacks an Euler path.
Proof:
- Euler Path Condition: An undirected connected multigraph contains an Euler path if and only if it has exactly $0$ or $2$ vertices of odd degree.
- Count odd-degree vertices: The degrees of the four vertices representing the landmasses are: $$\{3, 3, 3, 5\}$$ All four vertices have odd degree.
- Since the number of odd-degree vertices is 4 (which is greater than 2), the graph fails the condition.
Conclusion: No Euler path exists in the Königsberg bridges multigraph. ∎
Does the complete graph $K_5$ have an Euler circuit? An Euler path? Justify.
Goal: Determine the existence of Euler circuits/paths in $K_5$.
Step-by-Step Analysis:
- Verify connectedness: $K_5$ is a complete graph, which is connected.
- Verify degrees: In $K_5$, every vertex is connected to all other 4 vertices. Thus: $$\deg(v) = 4 \quad \text{for all } v \in V$$
- Apply Euler's theorems: - A connected graph has an Euler circuit if and only if every vertex has an even degree. Since $4$ is even, an Euler circuit exists. - Since every Euler circuit is also a valid Euler path, an Euler path also exists.
∎
Does the complete graph $K_4$ have an Euler circuit? An Euler path? Justify.
Goal: Analyze the existence of Euler circuits/paths in $K_4$.
Step-by-Step Analysis:
- Check degrees: In $K_4$, each vertex is connected to all other 3 vertices. Thus: $$\deg(v) = 3 \quad \text{for all } v \in V$$
- Count odd-degree vertices: All 4 vertices have odd degrees.
- Apply Euler's conditions: - An Euler path requires exactly 0 or 2 vertices of odd degree. Since $K_4$ has 4, no Euler path exists. - An Euler circuit requires all vertices to have even degrees. Since they are odd, no Euler circuit exists.
∎
For what values of $m$ and $n$ does the complete bipartite graph $K_{m,n}$ contain a Hamiltonian cycle?
Goal: Identify the conditions on $m$ and $n$ for $K_{m,n}$ to have a Hamiltonian cycle.
Proof:
- Let $V_1, V_2$ be the bipartition of $K_{m,n}$ with $|V_1| = m$ and $|V_2| = n$. A Hamiltonian cycle must visit every vertex in $V_1 \cup V_2$ exactly once and return to the starting vertex.
- Any path or cycle in a bipartite graph must alternate between partitions: $$v_1 \to v_2 \to v_3 \to v_4 \to \dots \to v_1$$ where $v_1, v_3, \dots \in V_1$ and $v_2, v_4, \dots \in V_2$.
- To form a closed cycle that alternates partitions, the cycle must visit an equal number of vertices in $V_1$ and $V_2$. Because the cycle must be Hamiltonian (visiting *all* vertices), the size of the partitions must be equal: $$m = n$$
- To avoid trivial paths (like $K_{1,1}$ which is a single edge with no cycles), we also require $m, n \geq 2$.
Conclusion: $K_{m,n}$ contains a Hamiltonian cycle if and only if $m = n \geq 2$. ∎
Prove that the hypercube graph $Q_n$ has a Hamiltonian cycle for all $n \geq 2$.
Goal: Prove the existence of a Hamiltonian cycle in $Q_n$ for $n \geq 2$.
Proof:
- Gray Code Correspondence: A Hamiltonian cycle in $Q_n$ corresponds to a cyclic sequence of all $2^n$ binary strings of length $n$ such that adjacent strings differ in exactly 1 bit. Such a sequence is a Reflected Gray Code.
- Inductive Construction:
We prove the existence of such a code by induction on $n \geq 2$.
- Base Case ($n=2$): $Q_2$ is a cycle $C_4$. The cycle sequence is: $$00 \to 01 \to 11 \to 10 \to 00$$ Adjacent strings differ in 1 bit, and the last differs from the first in 1 bit.
- Inductive Step: Assume $Q_{n-1}$ has a Hamiltonian cycle represented by the sequence $G_{n-1} = (g_1, g_2, \dots, g_{2^{n-1}})$. We construct a sequence $G_n$ of length $2^n$ for $Q_n$: $$G_n = (0g_1, 0g_2, \dots, 0g_{2^{n-1}}, 1g_{2^{n-1}}, 1g_{2^{n-1}-1}, \dots, 1g_1)$$ - The first half consists of $G_{n-1}$ prefixed by $0$. Adjacent elements differ in 1 bit. - The second half consists of $G_{n-1}$ in reverse order prefixed by $1$. Adjacent elements differ in 1 bit. - The transition from $0g_{2^{n-1}}$ to $1g_{2^{n-1}}$ is a change in 1 bit (the first bit). - The transition from the end $1g_1$ to the start $0g_1$ is a change in 1 bit (the first bit).
∎
Describe how to find the number of connected components of a graph algorithmically and analyze its time complexity.
Goal: Formulate an algorithm using traversals (BFS/DFS) to count the connected components of a graph.
Step-by-Step Algorithm:
- Initialize a boolean array `visited` of size $|V|$ to `false` for all vertices. Initialize a counter `components = 0`.
- For each vertex $v \in V$: - If `visited[v]` is `false`: - Increment `components` by 1. - Start a BFS or DFS traversal originating at $v$. - During the traversal, mark every reached vertex $u$ as `visited[u] = true`.
- Return `components` as the total number of connected components.
Complexity Analysis: - Each vertex is visited exactly once when checking the loop or during traversal. - In the adjacency list representation, each edge is examined exactly twice (once from each endpoint). - The total time complexity is $O(|V| + |E|)$. ∎
Prove that in a tree with $|V| \geq 2$, every internal (non-leaf) vertex is a cut vertex.
Goal: Prove that removing any non-leaf vertex from a tree disconnects the graph.
Proof:
- Let $T = (V, E)$ be a tree. A tree is a connected, acyclic graph. A crucial property of trees is that for any two vertices $x, y \in V$, there exists a unique simple path between them.
- Let $v$ be an internal vertex of $T$. By definition, an internal vertex has a degree of at least 2. Let $u$ and $w$ be two distinct neighbors of $v$ in $T$.
- Since $u$ and $w$ are adjacent to $v$, the unique path between $u$ and $w$ in $T$ must be $u - v - w$. If there were another path between $u$ and $w$ that did not pass through $v$, the combination of these two paths would form a cycle, contradicting the acyclic property of trees.
- If we remove vertex $v$ to form the subgraph $T - \{v\}$, the path $u - v - w$ is destroyed. Since this path was unique, no path between $u$ and $w$ remains in $T - \{v\}$.
- Thus, $T - \{v\}$ is disconnected, which by definition makes $v$ a cut vertex.
This completes the proof. ∎
Four students $S_1, S_2, S_3, S_4$ have project preferences: $S_1: \{P_1, P_2\}$, $S_2: \{P_2, P_3\}$, $S_3: \{P_3, P_4\}$, $S_4: \{P_1, P_4\}$. Prove whether a perfect matching exists.
Goal: Use Hall's Marriage Theorem to verify the existence of a perfect matching.
Step-by-Step Analysis:
- Let $S = \{S_1, S_2, S_3, S_4\}$ and $P = \{P_1, P_2, P_3, P_4\}$. We check Hall's Condition: for every subset $A \subseteq S$, its neighborhood $|N(A)| \geq |A|$.
- Evaluate all subsets $A$ of $S$: - Size 1: Each student prefers at least 2 projects, so $|N(A)| \geq 2 \geq 1$ for all singletons. ✓ - Size 2: - $\{S_1, S_2\} \to N = \{P_1, P_2, P_3\}$, size $3 \geq 2$ ✓ - $\{S_2, S_3\} \to N = \{P_2, P_3, P_4\}$, size $3 \geq 2$ ✓ - $\{S_3, S_4\} \to N = \{P_1, P_3, P_4\}$, size $3 \geq 2$ ✓ - $\{S_1, S_4\} \to N = \{P_1, P_2, P_4\}$, size $3 \geq 2$ ✓ - $\{S_1, S_3\} \to N = \{P_1, P_2, P_3, P_4\}$, size $4 \geq 2$ ✓ - $\{S_2, S_4\} \to N = \{P_1, P_2, P_3, P_4\}$, size $4 \geq 2$ ✓ - Size 3: Any subset of size 3 contains neighbors spanning all 4 projects (size $4 \geq 3$). ✓ - Size 4: $N(S) = \{P_1, P_2, P_3, P_4\}$, size $4 \geq 4$. ✓
- Since the condition holds for all subsets, a perfect matching exists.
- Matching construction: - Match $S_1 \to P_1$ - Match $S_2 \to P_2$ - Match $S_3 \to P_3$ - Match $S_4 \to P_4$
Conclusion: A perfect matching exists. ∎
If preferences change to $S_1: \{P_1\}$, $S_2: \{P_1\}$, $S_3: \{P_2, P_3\}$, $S_4: \{P_4\}$, determine if a perfect matching exists. Justify.
Goal: Determine the existence of a perfect matching for the updated preferences.
Step-by-Step Analysis:
- We test Hall's Condition on the subset $A = \{S_1, S_2\} \subseteq S$.
- Find the neighborhood of $A$: $$N(A) = N(S_1) \cup N(S_2) = \{P_1\} \cup \{P_1\} = \{P_1\}$$
- Compare sizes: $$|A| = 2, \quad |N(A)| = 1$$ Here, $|N(A)| < |A|$, which violates Hall's Condition.
- Intuitively, both students $S_1$ and $S_2$ only prefer project $P_1$. Since $P_1$ can only be assigned to one student, it is impossible to satisfy both.
Conclusion: No perfect matching exists because Hall's Condition is violated. ∎
- Memorize the 5 families: $K_n, C_n, W_n, Q_n, K_{m,n}$ — vertex/edge counts and degrees.
- Handshake lemma is a quick way to derive edge counts or check feasibility of degree sequences.
- Bipartite test: 2-colourable $\iff$ no odd cycle.
- Euler: count odd-degree vertices. 0 → circuit, 2 → path, else neither.
- Hamilton: no easy test; use Dirac ($\deg \geq n/2$) or Ore ($\deg(u) + \deg(v) \geq n$) as sufficient.
- $K_{m,n}$ Hamilton iff $m = n$; bipartite cycle alternates, must have $m = n$.