Agent Work: HW3: Graph Algorithms
Claude Sonnet 4.6 · COMP 182: Algorithmic Thinking
COMP 182: Algorithmic Thinking
Homework 3: Graphs
---
Problem 1: Understanding Graph-theoretic Definitions and Terminology [29 pts]
1.1 Degree Sequences [7 pts]
The *degree sequence* of a graph is the sequence of the degrees of the nodes of the graph in non-increasing order.
What is the degree sequence of:
- K_4?
- C_5?
- K_{m,n}?
1.2 Planar Graphs [4 pts]
Graph g is *planar* if it can be drawn on the plane such that no two edges intersect other than at their endpoints.
Which of the graphs K_2, K_3, K_4, and K_5 are planar? (Reminder: K_n is the complete graph on n nodes.)
Draw the planar ones to demonstrate your answer.
1.3 Course Prerequisites [9 pts]
Consider the following set of CS course prerequisites (COMP 140, MATH 111, MATH 211, and ELEC 220 have no prerequisites):
| Course | Prerequisites |
|---|---|
| MATH 112 | MATH 111 |
| COMP 182 | COMP 140, MATH 211 |
| COMP 215 | COMP 182 |
| COMP 310 | COMP 215 |
| STAT 310 | MATH 112, MATH 211 |
| COMP 311 | COMP 182 |
| COMP 382 | COMP 182, STAT 310 |
| COMP 321 | ELEC 220, COMP 215 |
| COMP 410 | COMP 321, COMP 310, COMP 311 |
(a) Draw a precedence graph that models the courses and their prerequisites. Here, add edges for direct prerequisites only.
(b) Is the graph acyclic? Does it make sense for it to be cyclic? Explain.
(c) For the courses above, what is the smallest number of semesters it would take a student to take all of the courses in the table? Assume that all courses are offered in every semester. More generally, for an arbitrary precedence graph that captures course prerequisites, how would you compute the minimum number of semesters it would take a student to take all of the courses?
1.4 Matchings [9 pts]
A *matching* on graph g = (V, E) is a subset of g's edges such that no two edges have a node in common. A *perfect matching* is a matching where every node is incident with at least one edge in the matching. The *size* of a matching is the number of edges in it.
(a) Give an example of a graph with at least 5 nodes that has a matching of size 2.
(b) Give an example of a graph with at least 5 nodes that has no matching of size 2.
(c) What is the size of a perfect matching (if one exists) for a graph that has n nodes (assume n is even)?
---
Problem 2: Graph-theoretic Problem Formulation [21 pts]
Formulate each of the problems as a graph-theoretic problem. Explicitly describe the input and output.
2.1 Jury Selection [7 pts]
Given a city with n individuals, we need to select m of them for jury duty such that no two of them know each other. Assume we have knowledge about the city and who knows whom.
2.2 Student Groups [7 pts]
Luay wants to divide the students in COMP 182 into as few groups as possible such that in each group every two students like each other (every student must belong to exactly one group). Assume that Luay knows who likes whom in the class.
2.3 Course Scheduling [7 pts]
The computer science department wants to schedule (i.e., assign time slots) the Fall 2023 courses so that no two courses that have at least one student in common are scheduled at overlapping times.
Assumptions: 1. The department knows which students will be taking each of the courses 2. There is a fixed set of k time slots available to schedule courses 3. The department wants to use as few slots as possible (to avoid conflict with other departments and to help with classroom scheduling)
---
Problem 3: Proving Graph-theoretic Results [50 pts]
3.1 Bipartite Bit Vector Graph [10 pts]
We define B_n = (V, E) as the graph whose nodes correspond to all bit vectors of size n such that there is an edge between two nodes if their bit vectors differ in one bit.
For example, B_2 contains four nodes {00, 01, 10, 11} and 4 edges {{00, 01}, {00, 10}, {01, 11}, {10, 11}}.
Prove that B_n is bipartite for an arbitrary n >= 2.
3.2 Bridges and Even Degrees [10 pts]
Let g = (V, E) be a graph. Edge e in E is called a *bridge* if the graph g' = (V, E \ {e}) has more connected components than g.
Prove that if the degrees of all nodes in g are even, then g does not contain a bridge.
3.3 Edge Coloring and Hamiltonian Circuits [10 pts]
Let g = (V, E) be a graph. We say that f : E -> {1, 2, ..., k} is a *k-coloring of the edges* of g if for every two edges e_1 and e_2 that share a node in common we have f(e_1) != f(e_2).
A simple circuit in a graph g that passes through every node of the graph exactly once is called a *Hamiltonian circuit* (Definition 2 in Section 10.5 in the textbook).
Prove that if the degree of each node in g is 3 and g has a Hamiltonian circuit, then there exists a 3-coloring of g's edges.
3.4 Cartesian Product Graphs [20 pts]
An *Euler circuit* in a graph g is a simple circuit that contains every edge of g (Definition 1 in Section 10.5 in the textbook).
Let g_1 = (V_1, E_1) and g_2 = (V_2, E_2) be two connected graphs (reminder: no parallel edges or self loops). We define the *Cartesian Product graph* C = (V_C, E_C) of the two graphs as follows:
- V_C = V_1 x V_2
- E_C = {{(u, x), (v, y)} : {u, v} in E_1 OR {x, y} in E_2}
Prove or disprove each of the following:
(a) If g_1 and g_2 both contain Hamiltonian circuits, then C contains a Hamiltonian circuit.
(b) If g_1 and g_2 both contain Euler circuits, then C contains an Euler circuit.
*Hint: You might find Theorems 1 and 2 in Section 10.5 in the textbook helpful.*
# COMP182 Homework 3
## Student Responses
<!-- Write your solutions below. Add sections for each problem as needed. -->
<!-- Use proper mathematical notation where applicable. -->
[Your solutions here]
COMP182 Homework 3
Student Responses
---
Problem 1: Understanding Graph-theoretic Definitions and Terminology
1.1 Degree Sequences
K_4 (complete graph on 4 nodes): Every node is connected to all other 3 nodes, so each node has degree 3. Degree sequence: [3, 3, 3, 3]
C_5 (cycle on 5 nodes): Every node is connected to exactly its two neighbors in the cycle, so each node has degree 2. Degree sequence: [2, 2, 2, 2, 2]
K_{m,n} (complete bipartite graph): K_{m,n} has two disjoint sets: m nodes (call them the "left" set) each connected to all n nodes on the right, and n nodes (the "right" set) each connected to all m nodes on the left.
- Each left-set node has degree n.
- Each right-set node has degree m.
Assuming n ≥ m, the degree sequence (non-increasing order) is: [n, n, ..., n (m times), m, m, ..., m (n times)]
If m > n, swap the roles of m and n above to get [m, ..., m (n times), n, ..., n (m times)].
---
1.2 Planar Graphs
K_2: Two nodes with one edge. Trivially planar (no crossings possible).
Drawing: A --- B
K_3: Three nodes forming a triangle. Planar. Drawing:
A
/ \
B---CK_4: Planar. Place three nodes A, B, C as a triangle, and place D inside the triangle, connecting D to each of A, B, C. All 6 edges are drawn without crossings. Drawing:
A
/|\
/ | \
B--D--C
\ /
\ /
(B-C edge on bottom)Edges: {A,B}, {A,C}, {B,C} (triangle), {A,D}, {B,D}, {C,D} (D inside) — no crossings.
K_5: Not planar. Proof by Euler's formula: For a connected planar simple graph, V - E + F = 2. K_5 has V = 5, E = 10, so F = 2 - 5 + 10 = 7 faces. However, every face must be bounded by at least 3 edges, and each edge borders exactly 2 faces, so 3F ≤ 2E, giving 3(7) = 21 ≤ 2(10) = 20, a contradiction. Therefore K_5 is not planar.
Summary: K_2, K_3, and K_4 are planar; K_5 is not.
---
1.3 Course Prerequisites
(a) Precedence Graph
Nodes represent courses. A directed edge A → B means "A is a direct prerequisite for B."
Edges (direct prerequisites only):
- MATH 111 → MATH 112
- COMP 140 → COMP 182
- MATH 211 → COMP 182
- COMP 182 → COMP 215
- COMP 215 → COMP 310
- MATH 112 → STAT 310
- MATH 211 → STAT 310
- COMP 182 → COMP 311
- COMP 182 → COMP 382
- STAT 310 → COMP 382
- ELEC 220 → COMP 321
- COMP 215 → COMP 321
- COMP 321 → COMP 410
- COMP 310 → COMP 410
- COMP 311 → COMP 410
Diagram (text representation):
MATH 111 ---> MATH 112 ---> STAT 310 ---> COMP 382
^ ^
MATH 211 ---> COMP 182 --------+ |
| |--------> COMP 311 --------+
| |
+-------> COMP 215 --> COMP 310 --> COMP 410
\ ^
ELEC 220 --------------------------> COMP 321 ----------+
|
COMP 140 -> COMP 182 (already shown above) COMP 311 ^(b) Is the graph acyclic?
Yes, the graph is acyclic (it is a directed acyclic graph, or DAG).
It makes sense for it to be acyclic. If there were a directed cycle, it would mean some course A has (directly or transitively) itself as a prerequisite, making it impossible to ever take course A. In any real course-scheduling scenario, prerequisites must form an acyclic structure so that students can actually complete all courses.
(c) Minimum number of semesters
Assign each course a "level" equal to the length of the longest prerequisite chain ending at that course (counting courses in the chain):
- Level 1 (no prerequisites): COMP 140, MATH 111, MATH 211, ELEC 220
- Level 2: MATH 112 (needs MATH 111), COMP 182 (needs COMP 140, MATH 211)
- Level 3: COMP 215 (needs COMP 182), STAT 310 (needs MATH 112, MATH 211), COMP 311 (needs COMP 182)
- Level 4: COMP 310 (needs COMP 215), COMP 321 (needs ELEC 220, COMP 215), COMP 382 (needs COMP 182, STAT 310)
- Level 5: COMP 410 (needs COMP 321, COMP 310, COMP 311)
The minimum number of semesters is 5.
General algorithm: For an arbitrary precedence DAG, compute the minimum number of semesters by finding the length of the longest path in the DAG. This can be done by: 1. Perform a topological sort of the DAG. 2. For each node v in topological order, set level(v) = 1 + max(level(u)) over all direct prerequisites u of v; set level(v) = 1 if v has no prerequisites. 3. The minimum number of semesters = max level(v) over all nodes v.
This works because the level of a course equals the minimum semester in which it can first be taken, and the maximum level is the semester when the last course is completed.
---
1.4 Matchings
(a) Graph with ≥ 5 nodes and a matching of size 2
Let G = (V, E) be the path graph P_5 with V = {1, 2, 3, 4, 5} and edges {1,2}, {2,3}, {3,4}, {4,5}.
The set M = {{1,2}, {3,4}} is a matching of size 2: edges {1,2} and {3,4} share no node.
(b) Graph with ≥ 5 nodes and no matching of size 2
Let G be the star graph K_{1,4} with nodes {c, 1, 2, 3, 4} and edges {c,1}, {c,2}, {c,3}, {c,4} (node c is the center).
Every edge in G is incident to c. Therefore, any two edges in G share the node c. No two edges are disjoint, so the maximum matching has size 1—there is no matching of size 2.
(c) Size of a perfect matching for a graph with n nodes (n even)
If a perfect matching exists, its size is n/2.
Reasoning: In a perfect matching, every node must be incident to at least one matching edge. Since each edge covers exactly 2 nodes and no two matching edges share a node, n/2 edges are needed to cover all n nodes. Moreover, n/2 edges can cover exactly n nodes, so the size of any perfect matching is exactly n/2.
---
Problem 2: Graph-theoretic Problem Formulation
2.1 Jury Selection
Graph: Construct an undirected graph G = (V, E) where:
- V = the set of n individuals in the city
- {u, v} ∈ E if and only if individuals u and v know each other
Input: Graph G and integer m.
Output: A subset S ⊆ V with |S| = m such that no two nodes in S are adjacent in G (i.e., S is an independent set of size m).
This is the Independent Set problem: find m individuals such that no two of them know each other, which corresponds to finding an independent set of size m in the "acquaintance graph."
---
2.2 Student Groups
Graph: Construct an undirected graph G = (V, E) where:
- V = the set of students in COMP 182
- {u, v} ∈ E if and only if students u and v like each other
Input: Graph G.
Output: A partition of V into the minimum number of subsets (groups) such that each subset is a clique in G (every pair of students in the group like each other).
This is the minimum clique cover problem. Equivalently, it is the graph coloring problem on the complement graph G' = (V, E'): form G' by placing an edge {u,v} in E' whenever {u,v} ∉ E (students who do NOT like each other). A proper coloring of G' assigns the same color only to students who are mutually non-adjacent in G', i.e., who all like each other—forming a clique in G. The minimum number of groups equals the chromatic number χ(G').
---
2.3 Course Scheduling
Graph: Construct an undirected graph G = (V, E) where:
- V = the set of courses offered in Fall 2023
- {u, v} ∈ E if and only if courses u and v have at least one student in common (i.e., they conflict)
Input: Graph G and integer k (number of available time slots).
Output: A proper coloring of V using the minimum number of colors, where each color represents a time slot. A coloring is proper if no two adjacent nodes (conflicting courses) receive the same color.
This is the graph coloring problem: the minimum number of time slots needed equals the chromatic number χ(G) of the conflict graph. Each color class (set of courses with the same color/slot) contains only mutually non-conflicting courses that can be scheduled simultaneously.
---
Problem 3: Proving Graph-theoretic Results
3.1 Bipartite Bit Vector Graph
Claim: B_n is bipartite for all n ≥ 2.
Proof:
We explicitly construct a bipartition of V.
For any bit vector v ∈ V, let wt(v) denote the number of 1-bits in v (its Hamming weight). Define:
- L = {v ∈ V : wt(v) is even}
- R = {v ∈ V : wt(v) is odd}
Clearly L and R are disjoint and L ∪ R = V (every bit vector has either even or odd Hamming weight), so (L, R) is a partition of V.
Claim: Every edge in E_n connects a node in L to a node in R.
Let {u, v} ∈ E_n. By definition of B_n, u and v differ in exactly one bit position. Flipping one bit either:
- Changes a 0 to a 1: wt increases by 1, changing its parity.
- Changes a 1 to a 0: wt decreases by 1, changing its parity.
In either case, wt(u) and wt(v) have opposite parity. Therefore, one of u, v is in L (even parity) and the other is in R (odd parity).
Since every edge in E_n connects a node in L to a node in R, B_n is bipartite with bipartition (L, R). □
---
3.2 Bridges and Even Degrees
Claim: If the degrees of all nodes in g are even, then g does not contain a bridge.
Proof:
It suffices to prove the claim for connected graphs, since each connected component of g inherits the even-degree property, and any bridge must lie within some connected component.
Assume g is connected with all even degrees.
By Euler's theorem (Theorem 2 in Section 10.5): a connected graph has an Euler circuit if and only if every vertex has even degree. Since all degrees in g are even, g has an Euler circuit—a closed walk that traverses every edge of g exactly once.
Suppose for contradiction that e = {u, v} is a bridge in g. Then g' = g - e has two connected components: C_u (containing u) and C_v (containing v), with the only edge between them in g being e.
Consider the Euler circuit EC of g, starting at some vertex s. EC traverses every edge exactly once. At some point, EC traverses e. Say EC goes from u to v via e (the direction is symmetric).
- After traversing e, the circuit is at v ∈ C_v and must eventually return to s.
- Case 1 (s ∈ C_u): After arriving at v, the circuit must reach s ∈ C_u. But the only edge between C_u and C_v is e, which has already been used. EC cannot reuse edges—contradiction.
- Case 2 (s ∈ C_v): Before traversing e (going u → v), the circuit must have reached u ∈ C_u from s ∈ C_v at some earlier step. But the only edge between C_v and C_u is e, and we haven't used it yet (we're about to use it). So to reach C_u from C_v, the circuit would have to use e going v → u, then later use e again going u → v—but that means e is used twice, contradicting the Euler circuit property.
In both cases we reach a contradiction. Therefore, no bridge exists in g. □
---
3.3 Edge Coloring and Hamiltonian Circuits
Claim: If every node in g has degree 3 and g has a Hamiltonian circuit, then there exists a 3-coloring of g's edges.
Proof:
Step 1: n must be even.
Since every node has degree 3, the sum of all degrees is 3n. By the handshaking lemma, 3n = 2|E|. Since the right side is even, 3n must be even. Since gcd(3, 2) = 1, n must be even.
Step 2: Partition edges into H and M.
Let H = (v_1, v_2, \ldots, v_n, v_1) be a Hamiltonian circuit in g. Let E_H = {e_1, e_2, \ldots, e_n} denote the edges of H, where e_i = {v_i, v_{i+1}} for i < n and e_n = {v_n, v_1}.
Since every node has degree 3 in g and the Hamiltonian circuit accounts for exactly 2 edges at each node (entering and leaving), each node has exactly one edge in E \ E_H. Thus M = E \ E_H is a perfect matching (no two edges of M share a node).
Step 3: Define the 3-coloring f : E → {1, 2, 3}.
- For each e_i ∈ E_H: assign f(e_i) = 1 if i is odd, f(e_i) = 2 if i is even.
- For each e ∈ M: assign f(e) = 3.
Step 4: Verify f is a valid 3-coloring.
We must show that any two edges sharing a node receive different colors.
(i) Two edges both in E_H sharing a node: Adjacent edges in H are e_i and e_{i+1} (sharing v_{i+1}), or e_n and e_1 (sharing v_1).
- e_i and e_{i+1}: one has odd index and one has even index, so they receive colors 1 and 2 (different). ✓
- e_n and e_1: since n is even, f(e_n) = 2 and f(e_1) = 1—different colors. ✓
(ii) Two edges both in M sharing a node: M is a perfect matching, so no two edges in M share a node. There are no such pairs. ✓
(iii) One edge from E_H and one from M sharing a node: Every edge in E_H receives color 1 or 2; every edge in M receives color 3. Since {1, 2} ∩ {3} = ∅, these edges always receive different colors. ✓
Therefore f is a valid 3-coloring of the edges of g. □
---
3.4 Cartesian Product Graphs
Recall: C = (V_C, E_C) where V_C = V_1 × V_2 and {(u,x),(v,y)} ∈ E_C iff {u,v} ∈ E_1 OR {x,y} ∈ E_2.
(a) Hamiltonian Circuits — TRUE
Claim: If g_1 and g_2 both contain Hamiltonian circuits, then C contains a Hamiltonian circuit.
Proof:
Let H_1 = (u_1, u_2, \ldots, u_n, u_1) be a Hamiltonian circuit of g_1, and H_2 = (x_1, x_2, \ldots, x_m, x_1) be a Hamiltonian circuit of g_2.
We construct a Hamiltonian circuit of C using a boustrophedon (snake) traversal of the n × m node grid:
Traverse the rows in alternating directions:
- Row i (odd): (u_i, x_1) → (u_i, x_2) → ··· → (u_i, x_m) [left to right]
- Row i (even): (u_i, x_m) → (u_i, x_{m-1}) → ··· → (u_i, x_1) [right to left]
- Transition from row i to row i+1: jump from the last node of row i to the first node of row i+1.
- Closing edge: after row n, return to (u_1, x_1).
Validity of each edge type:
*Intra-row edge* (within row i, moving from (u_i, x_j) to (u_i, x_{j±1})): The condition requires {u_i, u_i} ∈ E_1 (impossible, self-loop) OR {x_j, x_{j±1}} ∈ E_2. The latter holds because consecutive nodes in H_2 are adjacent in g_2 by definition of a Hamiltonian circuit. ✓
*Inter-row transition* (from last node of row i to first node of row i+1):
- If i is odd: jump from (u_i, x_m) to (u_{i+1}, x_m). Requires {u_i, u_{i+1}} ∈ E_1 OR {x_m, x_m} ∈ E_2. The first holds since consecutive nodes in H_1 are adjacent. ✓
- If i is even: jump from (u_i, x_1) to (u_{i+1}, x_1). Requires {u_i, u_{i+1}} ∈ E_1. ✓
*Closing edge* (from the end of row n back to (u_1, x_1)):
- If n is odd: closing edge is from (u_n, x_m) to (u_1, x_1). Requires {u_n, u_1} ∈ E_1 (true, closing edge of H_1) OR {x_m, x_1} ∈ E_2 (true, closing edge of H_2). ✓
- If n is even: closing edge is from (u_n, x_1) to (u_1, x_1). Requires {u_n, u_1} ∈ E_1. ✓
Coverage: Each of the n rows contributes exactly m nodes, and each node (u_i, x_j) appears exactly once in the traversal. The total count is n × m = |V_C|. The traversal starts and ends at (u_1, x_1), forming a closed circuit.
Therefore C has a Hamiltonian circuit. □
---
(b) Euler Circuits — TRUE
Claim: If g_1 and g_2 both contain Euler circuits, then C contains an Euler circuit.
We use the criterion (Theorem 2, Section 10.5): a connected graph has an Euler circuit if and only if every vertex has even degree.
Step 1: Compute the degree of each node in C.
For node (u, x) ∈ V_C, its neighbors are all (v, y) such that {u,v} ∈ E_1 OR {x,y} ∈ E_2 (with (v,y) ≠ (u,x)). By inclusion-exclusion:
$$\deg_C(u,x) = |\{(v,y) : \{u,v\} \in E_1\}| + |\{(v,y) : \{x,y\} \in E_2\}| - |\{(v,y) : \{u,v\} \in E_1 \text{ and } \{x,y\} \in E_2\}|$$
$$= \deg_1(u) \cdot |V_2| + |V_1| \cdot \deg_2(x) - \deg_1(u) \cdot \deg_2(x)$$
(Note: (u,x) itself is excluded from the neighbor count since self-loops do not exist in g_1 or g_2.)
Step 2: Show all degrees in C are even.
Since g_1 has an Euler circuit, all degrees in g_1 are even: deg_1(u) is even for all u. Similarly, deg_2(x) is even for all x. Therefore:
- deg_1(u) · |V_2| is even (product with an even factor).
- |V_1| · deg_2(x) is even (product with an even factor).
- deg_1(u) · deg_2(x) is even (product of two even numbers).
Thus deg_C(u, x) = even + even − even = even for every (u, x) ∈ V_C.
Step 3: Show C is connected.
Let (u, x) and (v, y) be any two nodes in V_C. Since g_1 is connected, there exists a path u = u_0, u_1, \ldots, u_k = v in g_1. Since {u_i, u_{i+1}} ∈ E_1, the edge {(u_i, x), (u_{i+1}, x)} ∈ E_C (OR condition: first component uses E_1). So
$$(u, x) = (u_0, x) \to (u_1, x) \to \cdots \to (u_k, x) = (v, x)$$
is a path in C. Similarly, since g_2 is connected, there is a path x = x_0, x_1, \ldots, x_ℓ = y in g_2, and {(v, x_j), (v, x_{j+1})} ∈ E_C (OR condition: second component uses E_2). So
$$(v, x) = (v, x_0) \to (v, x_1) \to \cdots \to (v, x_ℓ) = (v, y)$$
is a path in C. Concatenating, (u, x) is connected to (v, y) in C. Since (u, x) and (v, y) were arbitrary, C is connected.
Conclusion:
C is connected and every node has even degree. By Euler's theorem, C contains an Euler circuit. □
COMP 182 Homework 3 — Grading Report
---
Problem 1: Understanding Graph-theoretic Definitions and Terminology [29 pts]
1.1 Degree Sequences — 7/7
All three answers are correct:
- K₄: [3, 3, 3, 3] ✓
- C₅: [2, 2, 2, 2, 2] ✓
- K_{m,n}: Correctly identifies left-set nodes have degree n and right-set nodes have degree m, with the non-increasing order handled properly (assuming n ≥ m, gives n repeated m times followed by m repeated n times, and notes the swap if m > n). ✓
1.2 Planar Graphs — 4/4
- Correctly identifies K₂, K₃, K₄ as planar and K₅ as not planar. ✓ (1/1)
- Provides valid text-based drawings for K₂ (edge), K₃ (triangle), and K₄ (triangle with interior node). ✓ (3/3)
- Bonus: Provides a rigorous Euler's formula proof that K₅ is not planar — not required but demonstrates strong understanding.
1.3 Course Prerequisites — 9/9
(a) All 15 directed edges are listed correctly, matching every prerequisite relationship in the table. The text diagram captures the structure accurately. ✓ (3/3)
(b) Correctly identifies the graph as acyclic (DAG). Explanation is clear: a cycle would create a circular dependency making it impossible to take the involved courses. ✓ (3/3)
(c) Correct answer of 5 semesters, with a detailed level-by-level assignment showing the work. The general algorithm (topological sort + longest path computation) is clearly described with pseudocode-level detail. ✓ (3/3)
1.4 Matchings — 9/9
(a) Path graph P₅ with matching {{1,2}, {3,4}} — valid example with clear verification. ✓ (3/3)
(b) Star graph K_{1,4} — correctly explains that every edge is incident to the center node, so no two disjoint edges exist. ✓ (3/3)
(c) Correct answer of n/2 with solid reasoning: each matching edge covers exactly 2 nodes, no node shared, so n/2 edges cover all n nodes. ✓ (3/3)
---
Problem 2: Graph-theoretic Problem Formulation [21 pts]
2.1 Jury Selection — 7/7
- Graph model: Nodes = individuals, edges = acquaintance relationships. ✓ (3/3)
- Input: Graph G and integer m. ✓ (2/2)
- Output: Independent set of size m (no two selected individuals are adjacent). ✓ (2/2)
- Correctly identifies this as the Independent Set problem.
2.2 Student Groups — 7/7
- Graph model: Nodes = students, edges = mutual liking. ✓ (3/3)
- Input: Graph G. ✓ (2/2)
- Output: Partition into minimum number of cliques. ✓ (2/2)
- Correctly identifies this as the minimum clique cover problem. Additionally provides the elegant equivalence to graph coloring on the complement graph — excellent insight.
2.3 Course Scheduling — 7/7
- Graph model: Nodes = courses, edges = shared students (conflict). ✓ (3/3)
- Input: Graph G and integer k. ✓ (2/2)
- Output: Proper coloring with minimum number of colors ≤ k. ✓ (2/2)
- Correctly identifies this as the graph coloring problem.
---
Problem 3: Proving Graph-theoretic Results [50 pts]
3.1 Bipartite Bit Vector Graph — 10/10
Uses Hamming weight parity (number of 1-bits) instead of the rubric's zero-count parity — an equally valid characterization since flipping one bit changes either parity.
- Bipartition defined: L = even Hamming weight, R = odd Hamming weight. L ∩ R = ∅ and L ∪ R = V verified. ✓ (3/3)
- Edge analysis: Flipping one bit changes Hamming weight by ±1, always changing parity. Therefore endpoints of every edge lie in different partitions. ✓ (4/4)
- Structure and conclusion: Clean, well-organized proof. ✓ (3/3)
3.2 Bridges and Even Degrees — 10/10
The student uses an alternative approach via Euler circuits rather than the rubric's direct Handshaking Lemma argument. This is a correct and elegant alternative:
- Setup: Reduces to connected case; establishes that all even degrees → Euler circuit exists (by Euler's theorem). ✓ (2/2)
- Contradiction analysis: If bridge e = {u,v} exists, removing it splits the graph into two components C_u and C_v. The Euler circuit must traverse e, but then:
- Case 1 (start s ∈ C_u): After crossing e to C_v, circuit cannot return to s without reusing e. - Case 2 (start s ∈ C_v): Circuit must have used e to reach C_u before the assumed traversal, requiring e to be used twice. Both cases contradict the Euler circuit property. ✓ (6/6)
- Conclusion: Correctly stated. ✓ (2/2)
3.3 Edge Coloring and Hamiltonian Circuits — 10/10
Thorough, well-structured proof with careful verification:
- Step 1 (n is even): 3n = 2|E| by Handshaking Lemma, so n must be even. ✓ (2/2)
- Step 2 (2-color the circuit): Hamiltonian circuit has n edges; alternating colors 1 and 2 works because n is even (no conflict at e_n/e_1 junction). ✓ (2/2)
- Step 3 (remaining edges form a matching): Each node has degree 3 in g, degree 2 from the circuit, leaving exactly degree 1 in M = E \ E_H. M is therefore a perfect matching. ✓ (3/3)
- Step 4 (3rd color completes it): All matching edges get color 3. Verification of all three edge-pair cases (H-H, M-M, H-M) is meticulous and correct. ✓ (3/3)
3.4(a) Hamiltonian Circuits — 8/8
- Correctly states TRUE. ✓ (2/2)
- Construction: Uses a boustrophedon (snake) traversal — alternating row directions. This is a valid and well-known construction, different from the rubric's simpler row-by-row approach but equally correct. ✓ (4/4)
- Verification: Carefully checks all edge types:
- Intra-row edges use adjacency in g₂ ✓ - Inter-row transitions use adjacency in g₁ ✓ - Closing edge handled for both n-odd and n-even cases ✓ - Coverage: all n × m nodes visited exactly once ✓ (2/2)
3.4(b) Euler Circuits — 12/12
- Correctly states TRUE. ✓ (2/2)
- Connectivity proof: Constructs a path between arbitrary nodes (u,x) and (v,y) by first traversing along g₁ (fixing second component) then along g₂ (fixing first component). Clear and correct. ✓ (3/3)
- Degree computation: Uses inclusion-exclusion to derive deg_C(u,x) = deg₁(u)·|V₂| + |V₁|·deg₂(x) − deg₁(u)·deg₂(x). This is mathematically equivalent to the rubric's three-set partition approach (D₁, D₂, D₃), yielding the same formula. Each term is even (since deg₁(u) and deg₂(x) are even), so the sum is even. ✓ (5/5)
- Conclusion: Correctly applies Euler's theorem (connected + all even degrees → Euler circuit). ✓ (2/2)
---
Summary
| Problem | Score | Max |
|---|---|---|
| 1.1 Degree Sequences | 7 | 7 |
| 1.2 Planar Graphs | 4 | 4 |
| 1.3 Course Prerequisites | 9 | 9 |
| 1.4 Matchings | 9 | 9 |
| 2.1 Jury Selection | 7 | 7 |
| 2.2 Student Groups | 7 | 7 |
| 2.3 Course Scheduling | 7 | 7 |
| 3.1 Bipartite Bit Vector Graph | 10 | 10 |
| 3.2 Bridges and Even Degrees | 10 | 10 |
| 3.3 Edge Coloring | 10 | 10 |
| 3.4(a) Hamiltonian Circuits | 8 | 8 |
| 3.4(b) Euler Circuits | 12 | 12 |
| Total | 100 | 100 |
Overall Comments: This is an outstanding submission. Every problem is answered correctly with clear, rigorous reasoning. The student frequently employs alternative approaches to the reference solution (Hamming weight parity in 3.1, Euler circuit argument in 3.2, inclusion-exclusion in 3.4b, boustrophedon traversal in 3.4a) — all of which are mathematically sound and demonstrate deep understanding of the material. Several answers go beyond what is required, such as the Euler's formula proof for K₅'s non-planarity and the complement graph equivalence for the clique cover problem. Proofs are well-structured with clear notation and thorough verification of all cases.
Total: 100/100
diff --git a/writeup.md b/writeup.md
index 63ea42f..8cf7127 100644
--- a/writeup.md
+++ b/writeup.md
@@ -2,8 +2,362 @@
## Student Responses
-<!-- Write your solutions below. Add sections for each problem as needed. -->
-<!-- Use proper mathematical notation where applicable. -->
+---
-[Your solutions here]
+## Problem 1: Understanding Graph-theoretic Definitions and Terminology
+### 1.1 Degree Sequences
+
+**K_4 (complete graph on 4 nodes):**
+Every node is connected to all other 3 nodes, so each node has degree 3.
+Degree sequence: **[3, 3, 3, 3]**
+
+**C_5 (cycle on 5 nodes):**
+Every node is connected to exactly its two neighbors in the cycle, so each node has degree 2.
+Degree sequence: **[2, 2, 2, 2, 2]**
+
+**K_{m,n} (complete bipartite graph):**
+K_{m,n} has two disjoint sets: m nodes (call them the "left" set) each connected to all n nodes on the right, and n nodes (the "right" set) each connected to all m nodes on the left.
+- Each left-set node has degree n.
+- Each right-set node has degree m.
+
+Assuming n ≥ m, the degree sequence (non-increasing order) is:
+**[n, n, ..., n (m times), m, m, ..., m (n times)]**
+
+If m > n, swap the roles of m and n above to get [m, ..., m (n times), n, ..., n (m times)].
+
+---
+
+### 1.2 Planar Graphs
+
+**K_2:** Two nodes with one edge. Trivially planar (no crossings possible).
+Drawing: `A --- B`
+
+**K_3:** Three nodes forming a triangle. Planar.
+Drawing:
+```
+ A
+ / \
+ B---C
+```
+
+**K_4:** Planar. Place three nodes A, B, C as a triangle, and place D inside the triangle, connecting D to each of A, B, C. All 6 edges are drawn without crossings.
+Drawing:
+```
+ A
+ /|\
+ / | \
+ B--D--C
+ \ /
+ \ /
+ (B-C edge on bottom)
+```
+Edges: {A,B}, {A,C}, {B,C} (triangle), {A,D}, {B,D}, {C,D} (D inside) — no crossings.
+
+**K_5:** **Not planar.** Proof by Euler's formula: For a connected planar simple graph, V - E + F = 2. K_5 has V = 5, E = 10, so F = 2 - 5 + 10 = 7 faces. However, every face must be bounded by at least 3 edges, and each edge borders exactly 2 faces, so 3F ≤ 2E, giving 3(7) = 21 ≤ 2(10) = 20, a contradiction. Therefore K_5 is not planar.
+
+**Summary:** K_2, K_3, and K_4 are planar; K_5 is not.
+
+---
+
+### 1.3 Course Prerequisites
+
+**(a) Precedence Graph**
+
+Nodes represent courses. A directed edge A → B means "A is a direct prerequisite for B."
+
+Edges (direct prerequisites only):
+- MATH 111 → MATH 112
+- COMP 140 → COMP 182
+- MATH 211 → COMP 182
+- COMP 182 → COMP 215
+- COMP 215 → COMP 310
+- MATH 112 → STAT 310
+- MATH 211 → STAT 310
+- COMP 182 → COMP 311
+- COMP 182 → COMP 382
+- STAT 310 → COMP 382
+- ELEC 220 → COMP 321
+- COMP 215 → COMP 321
+- COMP 321 → COMP 410
+- COMP 310 → COMP 410
+- COMP 311 → COMP 410
+
+Diagram (text representation):
+```
+MATH 111 ---> MATH 112 ---> STAT 310 ---> COMP 382
+ ^ ^
+MATH 211 ---> COMP 182 --------+ |
+ | |--------> COMP 311 --------+
+ | |
+ +-------> COMP 215 --> COMP 310 --> COMP 410
+ \ ^
+ELEC 220 --------------------------> COMP 321 ----------+
+ |
+COMP 140 -> COMP 182 (already shown above) COMP 311 ^
+```
+
+**(b) Is the graph acyclic?**
+
+Yes, the graph is acyclic (it is a directed acyclic graph, or DAG).
+
+It makes sense for it to be acyclic. If there were a directed cycle, it would mean some course A has (directly or transitively) itself as a prerequisite, making it impossible to ever take course A. In any real course-scheduling scenario, prerequisites must form an acyclic structure so that students can actually complete all courses.
+
+**(c) Minimum number of semesters**
+
+Assign each course a "level" equal to the length of the longest prerequisite chain ending at that course (counting courses in the chain):
+
+- **Level 1** (no prerequisites): COMP 140, MATH 111, MATH 211, ELEC 220
+- **Level 2**: MATH 112 (needs MATH 111), COMP 182 (needs COMP 140, MATH 211)
+- **Level 3**: COMP 215 (needs COMP 182), STAT 310 (needs MATH 112, MATH 211), COMP 311 (needs COMP 182)
+- **Level 4**: COMP 310 (needs COMP 215), COMP 321 (needs ELEC 220, COMP 215), COMP 382 (needs COMP 182, STAT 310)
+- **Level 5**: COMP 410 (needs COMP 321, COMP 310, COMP 311)
+
+The minimum number of semesters is **5**.
+
+**General algorithm:** For an arbitrary precedence DAG, compute the minimum number of semesters by finding the length of the longest path in the DAG. This can be done by:
+1. Perform a topological sort of the DAG.
+2. For each node v in topological order, set level(v) = 1 + max(level(u)) over all direct prerequisites u of v; set level(v) = 1 if v has no prerequisites.
+3. The minimum number of semesters = max level(v) over all nodes v.
+
+This works because the level of a course equals the minimum semester in which it can first be taken, and the maximum level is the semester when the last course is completed.
+
+---
+
+### 1.4 Matchings
+
+**(a) Graph with ≥ 5 nodes and a matching of size 2**
+
+Let G = (V, E) be the path graph P_5 with V = {1, 2, 3, 4, 5} and edges {1,2}, {2,3}, {3,4}, {4,5}.
+
+The set M = {{1,2}, {3,4}} is a matching of size 2: edges {1,2} and {3,4} share no node.
+
+**(b) Graph with ≥ 5 nodes and no matching of size 2**
+
+Let G be the star graph K_{1,4} with nodes {c, 1, 2, 3, 4} and edges {c,1}, {c,2}, {c,3}, {c,4} (node c is the center).
+
+Every edge in G is incident to c. Therefore, any two edges in G share the node c. No two edges are disjoint, so the maximum matching has size 1—there is no matching of size 2.
+
+**(c) Size of a perfect matching for a graph with n nodes (n even)**
+
+If a perfect matching exists, its size is **n/2**.
+
+**Reasoning:** In a perfect matching, every node must be incident to at least one matching edge. Since each edge covers exactly 2 nodes and no two matching edges share a node, n/2 edges are needed to cover all n nodes. Moreover, n/2 edges can cover exactly n nodes, so the size of any perfect matching is exactly n/2.
+
+---
+
+## Problem 2: Graph-theoretic Problem Formulation
+
+### 2.1 Jury Selection
+
+**Graph:** Construct an undirected graph G = (V, E) where:
+- V = the set of n individuals in the city
+- {u, v} ∈ E if and only if individuals u and v know each other
+
+**Input:** Graph G and integer m.
+
+**Output:** A subset S ⊆ V with |S| = m such that no two nodes in S are adjacent in G (i.e., S is an **independent set** of size m).
+
+This is the **Independent Set problem**: find m individuals such that no two of them know each other, which corresponds to finding an independent set of size m in the "acquaintance graph."
+
+---
+
+### 2.2 Student Groups
+
+**Graph:** Construct an undirected graph G = (V, E) where:
+- V = the set of students in COMP 182
+- {u, v} ∈ E if and only if students u and v like each other
+
+**Input:** Graph G.
+
+**Output:** A partition of V into the minimum number of subsets (groups) such that each subset is a **clique** in G (every pair of students in the group like each other).
+
+This is the **minimum clique cover problem**. Equivalently, it is the **graph coloring problem** on the complement graph G' = (V, E'): form G' by placing an edge {u,v} in E' whenever {u,v} ∉ E (students who do NOT like each other). A proper coloring of G' assigns the same color only to students who are mutually non-adjacent in G', i.e., who all like each other—forming a clique in G. The minimum number of groups equals the chromatic number χ(G').
+
+---
+
+### 2.3 Course Scheduling
+
+**Graph:** Construct an undirected graph G = (V, E) where:
+- V = the set of courses offered in Fall 2023
+- {u, v} ∈ E if and only if courses u and v have at least one student in common (i.e., they conflict)
+
+**Input:** Graph G and integer k (number of available time slots).
+
+**Output:** A proper coloring of V using the minimum number of colors, where each color represents a time slot. A coloring is proper if no two adjacent nodes (conflicting courses) receive the same color.
+
+This is the **graph coloring problem**: the minimum number of time slots needed equals the chromatic number χ(G) of the conflict graph. Each color class (set of courses with the same color/slot) contains only mutually non-conflicting courses that can be scheduled simultaneously.
+
+---
+
+## Problem 3: Proving Graph-theoretic Results
+
+### 3.1 Bipartite Bit Vector Graph
+
+**Claim:** B_n is bipartite for all n ≥ 2.
+
+**Proof:**
+
+We explicitly construct a bipartition of V.
+
+For any bit vector v ∈ V, let wt(v) denote the number of 1-bits in v (its Hamming weight). Define:
+- L = {v ∈ V : wt(v) is even}
+- R = {v ∈ V : wt(v) is odd}
+
+Clearly L and R are disjoint and L ∪ R = V (every bit vector has either even or odd Hamming weight), so (L, R) is a partition of V.
+
+**Claim:** Every edge in E_n connects a node in L to a node in R.
+
+Let {u, v} ∈ E_n. By definition of B_n, u and v differ in exactly one bit position. Flipping one bit either:
+- Changes a 0 to a 1: wt increases by 1, changing its parity.
+- Changes a 1 to a 0: wt decreases by 1, changing its parity.
+
+In either case, wt(u) and wt(v) have opposite parity. Therefore, one of u, v is in L (even parity) and the other is in R (odd parity).
+
+Since every edge in E_n connects a node in L to a node in R, B_n is bipartite with bipartition (L, R). □
+
+---
+
+### 3.2 Bridges and Even Degrees
+
+**Claim:** If the degrees of all nodes in g are even, then g does not contain a bridge.
+
+**Proof:**
+
+It suffices to prove the claim for connected graphs, since each connected component of g inherits the even-degree property, and any bridge must lie within some connected component.
+
+**Assume g is connected with all even degrees.**
+
+By Euler's theorem (Theorem 2 in Section 10.5): a connected graph has an Euler circuit if and only if every vertex has even degree. Since all degrees in g are even, g has an Euler circuit—a closed walk that traverses every edge of g exactly once.
+
+**Suppose for contradiction** that e = {u, v} is a bridge in g. Then g' = g - e has two connected components: C_u (containing u) and C_v (containing v), with the only edge between them in g being e.
+
+Consider the Euler circuit EC of g, starting at some vertex s. EC traverses every edge exactly once. At some point, EC traverses e. Say EC goes from u to v via e (the direction is symmetric).
+
+- After traversing e, the circuit is at v ∈ C_v and must eventually return to s.
+- **Case 1 (s ∈ C_u):** After arriving at v, the circuit must reach s ∈ C_u. But the only edge between C_u and C_v is e, which has already been used. EC cannot reuse edges—contradiction.
+- **Case 2 (s ∈ C_v):** Before traversing e (going u → v), the circuit must have reached u ∈ C_u from s ∈ C_v at some earlier step. But the only edge between C_v and C_u is e, and we haven't used it yet (we're about to use it). So to reach C_u from C_v, the circuit would have to use e going v → u, then later use e again going u → v—but that means e is used twice, contradicting the Euler circuit property.
+
+In both cases we reach a contradiction. Therefore, no bridge exists in g. □
+
+---
+
+### 3.3 Edge Coloring and Hamiltonian Circuits
+
+**Claim:** If every node in g has degree 3 and g has a Hamiltonian circuit, then there exists a 3-coloring of g's edges.
+
+**Proof:**
+
+**Step 1: n must be even.**
+
+Since every node has degree 3, the sum of all degrees is 3n. By the handshaking lemma, 3n = 2|E|. Since the right side is even, 3n must be even. Since gcd(3, 2) = 1, n must be even.
+
+**Step 2: Partition edges into H and M.**
+
+Let H = (v_1, v_2, \ldots, v_n, v_1) be a Hamiltonian circuit in g. Let E_H = {e_1, e_2, \ldots, e_n} denote the edges of H, where e_i = {v_i, v_{i+1}} for i < n and e_n = {v_n, v_1}.
+
+Since every node has degree 3 in g and the Hamiltonian circuit accounts for exactly 2 edges at each node (entering and leaving), each node has exactly **one** edge in E \ E_H. Thus M = E \ E_H is a **perfect matching** (no two edges of M share a node).
+
+**Step 3: Define the 3-coloring f : E → {1, 2, 3}.**
+
+- For each e_i ∈ E_H: assign f(e_i) = 1 if i is odd, f(e_i) = 2 if i is even.
+- For each e ∈ M: assign f(e) = 3.
+
+**Step 4: Verify f is a valid 3-coloring.**
+
+We must show that any two edges sharing a node receive different colors.
+
+**(i) Two edges both in E_H sharing a node:**
+Adjacent edges in H are e_i and e_{i+1} (sharing v_{i+1}), or e_n and e_1 (sharing v_1).
+- e_i and e_{i+1}: one has odd index and one has even index, so they receive colors 1 and 2 (different). ✓
+- e_n and e_1: since n is even, f(e_n) = 2 and f(e_1) = 1—different colors. ✓
+
+**(ii) Two edges both in M sharing a node:**
+M is a perfect matching, so no two edges in M share a node. There are no such pairs. ✓
+
+**(iii) One edge from E_H and one from M sharing a node:**
+Every edge in E_H receives color 1 or 2; every edge in M receives color 3. Since {1, 2} ∩ {3} = ∅, these edges always receive different colors. ✓
+
+Therefore f is a valid 3-coloring of the edges of g. □
+
+---
+
+### 3.4 Cartesian Product Graphs
+
+Recall: C = (V_C, E_C) where V_C = V_1 × V_2 and {(u,x),(v,y)} ∈ E_C iff {u,v} ∈ E_1 OR {x,y} ∈ E_2.
+
+#### (a) Hamiltonian Circuits — TRUE
+
+**Claim:** If g_1 and g_2 both contain Hamiltonian circuits, then C contains a Hamiltonian circuit.
+
+**Proof:**
+
+Let H_1 = (u_1, u_2, \ldots, u_n, u_1) be a Hamiltonian circuit of g_1, and H_2 = (x_1, x_2, \ldots, x_m, x_1) be a Hamiltonian circuit of g_2.
+
+We construct a Hamiltonian circuit of C using a **boustrophedon (snake) traversal** of the n × m node grid:
+
+Traverse the rows in alternating directions:
+- **Row i (odd):** (u_i, x_1) → (u_i, x_2) → ··· → (u_i, x_m) [left to right]
+- **Row i (even):** (u_i, x_m) → (u_i, x_{m-1}) → ··· → (u_i, x_1) [right to left]
+- **Transition from row i to row i+1:** jump from the last node of row i to the first node of row i+1.
+- **Closing edge:** after row n, return to (u_1, x_1).
+
+**Validity of each edge type:**
+
+*Intra-row edge* (within row i, moving from (u_i, x_j) to (u_i, x_{j±1})):
+The condition requires {u_i, u_i} ∈ E_1 (impossible, self-loop) **OR** {x_j, x_{j±1}} ∈ E_2. The latter holds because consecutive nodes in H_2 are adjacent in g_2 by definition of a Hamiltonian circuit. ✓
+
+*Inter-row transition* (from last node of row i to first node of row i+1):
+- If i is odd: jump from (u_i, x_m) to (u_{i+1}, x_m). Requires {u_i, u_{i+1}} ∈ E_1 **OR** {x_m, x_m} ∈ E_2. The first holds since consecutive nodes in H_1 are adjacent. ✓
+- If i is even: jump from (u_i, x_1) to (u_{i+1}, x_1). Requires {u_i, u_{i+1}} ∈ E_1. ✓
+
+*Closing edge* (from the end of row n back to (u_1, x_1)):
+- If n is odd: closing edge is from (u_n, x_m) to (u_1, x_1). Requires {u_n, u_1} ∈ E_1 (true, closing edge of H_1) **OR** {x_m, x_1} ∈ E_2 (true, closing edge of H_2). ✓
+- If n is even: closing edge is from (u_n, x_1) to (u_1, x_1). Requires {u_n, u_1} ∈ E_1. ✓
+
+**Coverage:** Each of the n rows contributes exactly m nodes, and each node (u_i, x_j) appears exactly once in the traversal. The total count is n × m = |V_C|. The traversal starts and ends at (u_1, x_1), forming a closed circuit.
+
+Therefore C has a Hamiltonian circuit. □
+
+---
+
+#### (b) Euler Circuits — TRUE
+
+**Claim:** If g_1 and g_2 both contain Euler circuits, then C contains an Euler circuit.
+
+We use the criterion (Theorem 2, Section 10.5): a connected graph has an Euler circuit if and only if every vertex has even degree.
+
+**Step 1: Compute the degree of each node in C.**
+
+For node (u, x) ∈ V_C, its neighbors are all (v, y) such that {u,v} ∈ E_1 **OR** {x,y} ∈ E_2 (with (v,y) ≠ (u,x)). By inclusion-exclusion:
+
+$$\deg_C(u,x) = |\{(v,y) : \{u,v\} \in E_1\}| + |\{(v,y) : \{x,y\} \in E_2\}| - |\{(v,y) : \{u,v\} \in E_1 \text{ and } \{x,y\} \in E_2\}|$$
+
+$$= \deg_1(u) \cdot |V_2| + |V_1| \cdot \deg_2(x) - \deg_1(u) \cdot \deg_2(x)$$
+
+(Note: (u,x) itself is excluded from the neighbor count since self-loops do not exist in g_1 or g_2.)
+
+**Step 2: Show all degrees in C are even.**
+
+Since g_1 has an Euler circuit, all degrees in g_1 are even: deg_1(u) is even for all u. Similarly, deg_2(x) is even for all x. Therefore:
+- deg_1(u) · |V_2| is even (product with an even factor).
+- |V_1| · deg_2(x) is even (product with an even factor).
+- deg_1(u) · deg_2(x) is even (product of two even numbers).
+
+Thus deg_C(u, x) = even + even − even = **even** for every (u, x) ∈ V_C.
+
+**Step 3: Show C is connected.**
+
+Let (u, x) and (v, y) be any two nodes in V_C. Since g_1 is connected, there exists a path u = u_0, u_1, \ldots, u_k = v in g_1. Since {u_i, u_{i+1}} ∈ E_1, the edge {(u_i, x), (u_{i+1}, x)} ∈ E_C (OR condition: first component uses E_1). So
+
+$$(u, x) = (u_0, x) \to (u_1, x) \to \cdots \to (u_k, x) = (v, x)$$
+
+is a path in C. Similarly, since g_2 is connected, there is a path x = x_0, x_1, \ldots, x_ℓ = y in g_2, and {(v, x_j), (v, x_{j+1})} ∈ E_C (OR condition: second component uses E_2). So
+
+$$(v, x) = (v, x_0) \to (v, x_1) \to \cdots \to (v, x_ℓ) = (v, y)$$
+
+is a path in C. Concatenating, (u, x) is connected to (v, y) in C. Since (u, x) and (v, y) were arbitrary, C is connected.
+
+**Conclusion:**
+
+C is connected and every node has even degree. By Euler's theorem, C contains an Euler circuit. □
Sub-Model Usage
| Model | Input | Output | Cache Read | Cost |
|---|---|---|---|---|
| claude-sonnet-4-6 | 6 | 25.3K | 138.9K | $0.95 |
BSCS Bench