Algorithm Search⌘K

Proofs: Coloring chordal graphs

These are the human proofs of Coloring chordal graphs, at full length.

The chordal coloring algorithm is correct and optimal full

This proof shows: correctness, termination.

Let G=(V,E)G = (V, E) be a finite simple undirected graph. Maximum cardinality search visits the vertices one at a time and always visits next an unvisited vertex with the largest number of visited neighbors. Let σ\sigma be its visit order and t(v)t(v) the step at which vv is visited. For each vv, Earlier(v)={w∈N(v):t(w)<t(v)}\mathrm{Earlier}(v) = \{ w \in N(v) : t(w) < t(v) \}, and if it is not empty, p(v)p(v) is its element with the largest tt.

Termination is clear: maximum cardinality search makes nn steps, and lines L2 to L7 are loops over the vertices, their adjacency lists and the recorded requests. We prove that the answer is right.

Lemma 1 (the search property). If t(a)<t(b)<t(c)t(a) < t(b) < t(c), ac∈Eac \in E and ab∉Eab \notin E, then there is a vertex dd with t(d)<t(b)t(d) < t(b), db∈Edb \in E and dc∉Edc \notin E.

Proof. Let SS be the set of vertices visited before bb. Then a∈Sa \in S and c∉Sc \notin S. When bb was chosen, ∣N(b)∩S∣≥∣N(c)∩S∣|N(b) \cap S| \ge |N(c) \cap S|. The vertex aa is in N(c)∩SN(c) \cap S but not in N(b)N(b). If N(b)∩S⊆N(c)N(b) \cap S \subseteq N(c), then N(c)∩SN(c) \cap S would contain N(b)∩SN(b) \cap S and also aa, so it would be larger. So some d∈N(b)∩Sd \in N(b) \cap S has d∉N(c)d \notin N(c). □\square

Lemma 2. If GG is chordal, then Earlier(v)\mathrm{Earlier}(v) is a clique for every vertex vv.

Proof. Suppose some Earlier(v)\mathrm{Earlier}(v) contains two non-adjacent vertices x,yx, y. We call a path P=p0p1⋯pLP = p_0 p_1 \cdots p_L good if L≥2L \ge 2, PP is an induced path of GG (no edges between its vertices besides pipi+1p_i p_{i+1}), and every inner vertex p1,…,pL−1p_1, \ldots, p_{L-1} has a larger tt than both ends p0p_0 and pLp_L. The path x v yx\, v\, y is good: xy∉Exy \notin E, and t(v)>t(x),t(y)t(v) > t(x), t(y). For a good path let Φ(P)=t(p0)+t(pL)\Phi(P) = t(p_0) + t(p_L). We show that every good path PP gives a good path P′P' with Φ(P′)<Φ(P)\Phi(P') < \Phi(P). This is impossible, since Φ\Phi takes only finitely many values, so the lemma follows.

Let PP be good, and name its ends so that e=p0e = p_0 has the smaller time and f=pLf = p_L the larger: t(e)<t(f)t(e) < t(f). Let q=p1q = p_1, the inner neighbor of ee. Then t(e)<t(f)<t(q)t(e) < t(f) < t(q), eq∈Eeq \in E, and ef∉Eef \notin E because PP is induced and L≥2L \ge 2. Lemma 1 with a=ea = e, b=fb = f, c=qc = q gives a vertex dd with t(d)<t(f)t(d) < t(f), df∈Edf \in E and dq∉Edq \notin E.

The vertex dd is not on PP: it is not ff, since df∈Edf \in E; it is not ee, since ef∉Eef \notin E; and it is not an inner vertex, since those have tt larger than t(f)>t(d)t(f) > t(d).

Let J={j:dpj∈E}J = \{ j : d p_j \in E \}; then L∈JL \in J and 1∉J1 \notin J. Suppose JJ has two elements i<i′i < i' with no element of JJ strictly between them and i′≥i+2i' \ge i + 2. Then d,pi,pi+1,…,pi′,dd, p_i, p_{i+1}, \ldots, p_{i'}, d is a cycle of length i′−i+2≥4i' - i + 2 \ge 4. It has no chord: PP is induced, and dd is not adjacent to pi+1,…,pi′−1p_{i+1}, \ldots, p_{i'-1}. This contradicts chordality. So JJ is a set of consecutive integers {r,r+1,…,L}\{r, r+1, \ldots, L\}, and since 1∉J1 \notin J, r≥2r \ge 2.

Let P′=p0p1⋯pr dP' = p_0 p_1 \cdots p_r\, d. It has at least 3 vertices, since r≥2r \ge 2. It is induced: its part p0⋯prp_0 \cdots p_r is part of PP, and dd is adjacent to prp_r and to no pjp_j with j<rj < r. Its inner vertices are p1,…,prp_1, \ldots, p_r. Each of them is an inner vertex of PP or equals f=pLf = p_L, so its time is at least t(f)t(f), which is larger than t(e)t(e) and larger than t(d)t(d); inner vertices of PP other than pLp_L have time larger than t(f)t(f). So P′P' is good, with the ends ee and dd, and Φ(P′)=t(e)+t(d)<t(e)+t(f)=Φ(P)\Phi(P') = t(e) + t(d) < t(e) + t(f) = \Phi(P). □\square

Lemma 3 (the check of lines L2 to L5). Every Earlier(v)\mathrm{Earlier}(v) is a clique if and only if, for every vv with Earlier(v)≠∅\mathrm{Earlier}(v) \ne \emptyset, Earlier(v)∖{p(v)}⊆N(p(v))\mathrm{Earlier}(v) \setminus \{p(v)\} \subseteq N(p(v)).

Proof. If Earlier(v)\mathrm{Earlier}(v) is a clique, p(v)p(v) is adjacent to its other elements. Conversely, assume the condition, and show by induction on t(v)t(v) that Earlier(v)\mathrm{Earlier}(v) is a clique. Let w1≠w2w_1 \ne w_2 be in Earlier(v)\mathrm{Earlier}(v) and p=p(v)p = p(v). If one of them is pp, the condition gives w1w2∈Ew_1 w_2 \in E. Otherwise both are adjacent to pp and have t(wi)<t(p)t(w_i) < t(p), by the choice of pp, so both lie in Earlier(p)\mathrm{Earlier}(p). As t(p)<t(v)t(p) < t(v), the induction hypothesis says that Earlier(p)\mathrm{Earlier}(p) is a clique, so w1w2∈Ew_1 w_2 \in E. □\square

Line L5 tests exactly the condition of Lemma 3: for each uu it marks N(u)N(u) and checks every ww recorded for uu, and the recorded pairs are (p(v),w)(p(v), w) for w∈Earlier(v)∖{p(v)}w \in \mathrm{Earlier}(v) \setminus \{p(v)\}.

Lemma 4. If every Earlier(v)\mathrm{Earlier}(v) is a clique, then GG is chordal.

Proof. Let CC be a cycle of length at least 4, and vv its vertex with the largest tt. The two neighbors of vv on CC have smaller times, so they lie in Earlier(v)\mathrm{Earlier}(v) and are adjacent. They are not consecutive on CC, because CC has length at least 4, so this edge is a chord. □\square

The answer NOT CHORDAL. If GG is chordal, Lemma 2 and Lemma 3 show that line L5 finds no failure. If line L5 finds no failure, Lemma 3 and Lemma 4 show that GG is chordal. So the algorithm returns NOT CHORDAL exactly when GG is not chordal.

The coloring. Assume GG is chordal, so each Earlier(v)\mathrm{Earlier}(v) is a clique. Lines L6 and L7 color the vertices in the order σ\sigma, and when vv is colored, its colored neighbors are exactly Earlier(v)\mathrm{Earlier}(v). The colors of these ∣Earlier(v)∣|\mathrm{Earlier}(v)| vertices exclude at most ∣Earlier(v)∣|\mathrm{Earlier}(v)| values, so the smallest free value c(v)c(v) is at most ∣Earlier(v)∣+1|\mathrm{Earlier}(v)| + 1, and it differs from the color of each vertex of Earlier(v)\mathrm{Earlier}(v). Every edge vwvw with t(w)<t(v)t(w) < t(v) has w∈Earlier(v)w \in \mathrm{Earlier}(v), so the coloring is proper. The set {v}∪Earlier(v)\{v\} \cup \mathrm{Earlier}(v) is a clique of size ∣Earlier(v)∣+1|\mathrm{Earlier}(v)| + 1, so

max⁡vc(v)≤max⁡v(∣Earlier(v)∣+1)≤ω(G)≤χ(G).\max_v c(v) \le \max_v \big(|\mathrm{Earlier}(v)| + 1\big) \le \omega(G) \le \chi(G).

A proper coloring uses at least χ(G)\chi(G) colors, so the coloring uses exactly χ(G)=ω(G)\chi(G) = \omega(G) colors and is optimal. ■\blacksquare

Back to Coloring chordal graphs