Tutorials › Graph Theory (Undergraduate) › Maximum Cardinality Search for Chordal Recognition

Perfect Graphs and Special Colorings · Tutorial 412 of 799

Maximum Cardinality Search for Chordal Recognition

Use maximum cardinality search to build a candidate perfect elimination ordering, test it, and justify the recognition algorithm and its running time.

Advanced 11 min read

What You'll Learn

  • Define maximum cardinality search using labels that count already selected neighbors.
  • Reverse the selection order to obtain the candidate perfect elimination ordering.
  • Test whether each vertex’s later neighbors form a clique, including in disconnected graphs.
  • Apply the standard MCS ordering theorem to justify both acceptance and rejection.
  • Trace MCS on chordal, nonchordal, and disconnected graphs.
  • Bound the search and verification costs of a direct implementation.

Maximum Cardinality Search and Chordal Graphs

A chordal graph has no induced cycle of length at least four. One way to recognize such a graph is to find a perfect elimination ordering: an ordering in which each vertex’s neighbors appearing later form a clique. Maximum cardinality search (MCS) is a simple rule for producing a candidate ordering. Its key feature is that the search order must be reversed before the clique tests are made.

All graphs in this tutorial are finite and simple. A set of vertices is a clique if every pair of distinct vertices in it is adjacent; the empty set and a one-vertex set count as cliques. An induced cycle is a cycle for which the subgraph induced by its vertices has no edges other than the cycle edges.

Definition: A graph \(G\) is chordal if it has no induced cycle of length at least \(4\). An ordering \(w_1,\dots,w_n\) of \(V(G)\) is a perfect elimination ordering (PEO) if, for every \(i\), the neighbors of \(w_i\) among \(w_{i+1},\dots,w_n\) form a clique.

MCS constructs a selection order \(v_1,\dots,v_n\). Initially every vertex has label \(0\). At each step, select an unselected vertex with largest current label; when labels tie, any fixed tie-breaking rule may be used. Then increase by \(1\) the label of each unselected neighbor of the chosen vertex. The candidate PEO is the reverse order \(w_i=v_{n+1-i}\). In that reverse order, the vertices later than \(v_i\) are exactly the vertices selected before \(v_i\).

Lemma: At every step of MCS, the label of each unselected vertex \(x\) is the number of its neighbors that have already been selected.

Proof. Initially no vertices have been selected, so every unselected vertex has zero selected neighbors and label \(0\). Suppose the statement holds just before a vertex \(v\) is selected. The algorithm increases the label of each unselected neighbor of \(v\) by \(1\), and leaves all other unselected labels unchanged. For each such neighbor, the number of selected neighbors has increased by exactly \(1\); for every other unselected vertex it has not changed. Thus the statement still holds after this step. Induction over the selection steps proves the claim. \(\square\)

The Recognition Test and Its Correctness

After MCS finishes, reverse the selection order and inspect each vertex’s later neighbors. The graph passes the test if every one of these sets is a clique. The following standard ordering theorem is the structural fact that makes this test a recognition algorithm.

Theorem (Maximum Cardinality Search ordering theorem): For a finite simple graph, and for any choices made when MCS has a tie, the reverse of the MCS selection order is a PEO if and only if the graph is chordal. This standard structural theorem is cited here; its proof is not developed in this tutorial.

In particular, the theorem applies to disconnected graphs and to graphs with isolated vertices. MCS need not be restarted separately in each component: when no unselected vertex has a positive label, the rule selects a vertex of label \(0\) from another component if one remains.

The acceptance direction can also be checked directly from the definitions, without using the MCS theorem. If an ordering is a PEO, the graph is chordal:

Proposition: If a graph has a PEO, then it is chordal.

Proof. Suppose \(w_1,\dots,w_n\) is a PEO and, to obtain a contradiction, that the graph contains an induced cycle of length at least \(4\). Choose the vertex of that cycle appearing earliest in the ordering, say \(w_i\). Its two neighbors along the cycle both appear later than \(w_i\). They are distinct and are not adjacent: an edge between them would be a chord of the induced cycle. But the PEO condition says that all later neighbors of \(w_i\) form a clique, so those two neighbors must be adjacent. This contradiction shows that no such induced cycle exists. \(\square\)

Consequently, if the MCS test accepts, its reversed order is a PEO and the proposition shows that the graph is chordal. If the test rejects, the reversed order is not a PEO; the MCS ordering theorem then implies that the graph is not chordal. The failed clique check is a valid rejection certificate for this algorithm, though it does not by itself list an induced cycle.

1
Initialize.
Set every label to \(0\), mark all vertices unselected, and choose a fixed tie-breaking rule.
2
Search.
Repeatedly select an unselected vertex of maximum label, record it next in the selection order, and increase the labels of its unselected neighbors.
3
Reverse and test.
Reverse the recorded order. For each vertex, check every pair of its later neighbors for adjacency. Accept exactly when all these sets are cliques.

Worked MCS Traces

Worked Example: A Chordal Graph

Let \(G=(V,E)\), where \(V=\{1,2,3,4,5\}\) and \(E=\{12,13,23,24,34,45\}\). Break ties by choosing the smallest-numbered vertex. The table gives the labels of unselected vertices after each selection; a label not increased in a row retains its previous value.

StepSelectedLabel updatesUnselected labels afterward
Start——\(1:0,2:0,3:0,4:0,5:0\)
11\(2:0\to1,\ 3:0\to1\)\(2:1,3:1,4:0,5:0\)
22\(3:1\to2,\ 4:0\to1\)\(3:2,4:1,5:0\)
33\(4:1\to2\)\(4:2,5:0\)
44\(5:0\to1\)\(5:1\)
55NoneNone

The selection order is \(1,2,3,4,5\), so the candidate PEO is \(5,4,3,2,1\). In this order the later-neighbor sets, listed by vertex, are: for \(5\), \(\{4\}\); for \(4\), \(\{2,3\}\); for \(3\), \(\{1,2\}\); for \(2\), \(\{1\}\); and for \(1\), \(\varnothing\). The set \(\{2,3\}\) is a clique because \(23\in E\), and \(\{1,2\}\) is a clique because \(12\in E\); the remaining sets have at most one vertex and are cliques by convention. Thus the test accepts.

Check: The six edges in the displayed edge set are \(12,13,23,24,34,45\). In the reversed order, the only later-neighbor sets with two elements are exactly \(\{2,3\}\) and \(\{1,2\}\), and both corresponding edges are in \(E\). The order is a PEO, so the proposition verifies that this graph is chordal.

Worked Example: A Nonchordal Cycle

Let \(G=(V,E)\), where \(V=\{1,2,3,4\}\) and \(E=\{12,23,34,41\}\). Use the same smallest-numbered tie-break. The labels after each selection are shown explicitly.

StepSelectedLabel updatesUnselected labels afterward
Start——\(1:0,2:0,3:0,4:0\)
11\(2:0\to1,\ 4:0\to1\)\(2:1,3:0,4:1\)
22\(3:0\to1\)\(3:1,4:1\)
33\(4:1\to2\)\(4:2\)
44NoneNone

The selection order is \(1,2,3,4\), and its reverse is \(4,3,2,1\). In the reversed order \(4,3,2,1\), vertex \(4\) has later neighbors \(3\) and \(1\), since \(43,41\in E\). They are not adjacent, because \(13\notin E\). Therefore the test rejects. (The other sets are \(\{2\}\) for \(3\), \(\{1\}\) for \(2\), and \(\varnothing\) for \(1\).) The MCS ordering theorem guarantees that this rejection means the graph is not chordal.

Check: The edges are precisely the four cycle edges \(12,23,34,41\); neither possible diagonal \(13\) nor \(24\) is in \(E\). Thus the cycle \(1,2,3,4,1\) has length \(4\) and has no chord, independently confirming that the graph is nonchordal.

Worked Example: Disconnected Graph with an Isolated Vertex

Let \(G=(V,E)\), where \(V=\{a,b,c,d,e,f\}\) and \(E=\{ab,bc,de\}\). The vertex \(f\) is isolated. Break ties alphabetically. The labels are:

StepSelectedLabel updatesUnselected labels afterward
Start——\(a:0,b:0,c:0,d:0,e:0,f:0\)
1\(a\)\(b:0\to1\)\(b:1,c:0,d:0,e:0,f:0\)
2\(b\)\(c:0\to1\)\(c:1,d:0,e:0,f:0\)
3\(c\)None\(d:0,e:0,f:0\)
4\(d\)\(e:0\to1\)\(e:1,f:0\)
5\(e\)None\(f:0\)
6\(f\)NoneNone

The selection order is \(a,b,c,d,e,f\); the reversed order is \(f,e,d,c,b,a\). The later-neighbor sets are, respectively, \(\varnothing,\{d\},\varnothing,\{b\},\{a\},\varnothing\) for \(f,e,d,c,b,a\). For example, \(e\) appears before \(d\) in the reversed order, so \(d\) is a later neighbor of \(e\), but \(e\) is not a later neighbor of \(d\). Each set is empty or a singleton, so the test accepts.

Check: The graph has components with vertex sets \(\{a,b,c\}\), \(\{d,e\}\), and \(\{f\}\). Each component is a path or an isolated vertex, and the displayed reversed order passes the clique test across all six vertices. In particular, no special restart is needed for the zero-labeled vertices in the other components.

Running Time and Implementation

Labels are integers between \(0\) and \(n-1\), because a vertex has at most \(n-1\) neighbors. A direct implementation can keep all unselected vertices in a max-priority queue. Insert each vertex initially with key \(0\). Whenever an unselected neighbor’s label increases, insert a new queue entry with its new key. When extracting a maximum, discard entries for already selected vertices or entries whose key is smaller than that vertex’s current label. Labels only increase, so an entry with a key different from the current label is stale.

There are \(n\) initial insertions and at most \(m\) label increases: each edge can cause an increase at most once, when its first endpoint is selected. Thus there are at most \(n+m\) insertions and at most \(n+m\) extractions, including stale entries. A binary heap therefore performs the search in \(O((n+m)\log(n+m))\) time when \(n+m\ge2\), using \(O(n+m)\) heap space. For the empty graph, the search and test take constant time.

For a direct clique test, let \(k_v\) be the number of later neighbors of vertex \(v\) in the reversed order. Checking all unordered pairs in each later-neighbor set takes \(\sum_{v\in V}\binom{k_v}{2}\) adjacency queries. With adjacency sets providing constant-time membership queries, the expected verification time is \(O(n+m+\sum_v\binom{k_v}{2})\); the additional \(n+m\) accounts for storing the graph and iterating over its vertices and edges. With a deterministic representation, such as sorted adjacency lists, each pair query can instead use binary search, giving \(O(n+m+\sum_v\binom{k_v}{2}\log n)\) verification time. Since \(k_v\le n-1\), this straightforward test can be quadratic or larger in dense cases. These bounds describe this implementation of the requested pairwise clique checks; more specialized implementations can reduce verification time.

Common Mistake

Testing the selection order instead of its reverse. Let \(V=\{0,1,2,3\}\) and \(E=\{01,02,03\}\), a star with center \(0\). With smallest-numbered tie-breaking, MCS selects \(0\) first, increasing the labels of \(1,2,3\) from \(0\) to \(1\), and then selects \(1,2,3\) in that order. The selection order is \(0,1,2,3\). If one mistakenly tests that order, vertex \(0\) has later neighbors \(\{1,2,3\}\), which is not a clique because none of the edges \(12,13,23\) is present. That incorrect test would reject a chordal graph. The correct order is the reverse, \(3,2,1,0\): each leaf has just one later neighbor, \(0\), and the center has no later neighbors. Every set passes, as required.

Check Your Understanding

Use the definitions and the direction of the ordering carefully in each question.

  1. For \(V=\{1,2,3,4\}\) and \(E=\{12,13,23,24,34\}\), run MCS using the smallest-numbered tie-break. Give the selection order, reverse it, and test every later-neighbor set.
  2. Explain why every vertex label is at most \(n-1\), and prove that at most \(m\) label increases occur during MCS.
  3. Why does a failed clique test establish nonchordality for an MCS order, while a failed clique test for an arbitrary ordering would not by itself establish nonchordality?
  4. Give the reversed MCS order for the graph with \(V=\{a,b,c,d\}\) and \(E=\{ab,bc\}\), using alphabetical tie-breaking. Include its isolated vertices in the test.
  5. For a reversed order whose later-neighbor sets have sizes \(0,1,2,2\), compute the number of unordered vertex pairs examined by the direct clique test.