EP06

EP06: Graph Coloring and Voice Assignment

完美图, χ=ω
6:28 Graph TheoryCombinatorics

Overview

Beethoven’s Fifth Symphony, fourth movement, deploys over twenty orchestral staves. Collapse all octave doublings, and the climax still demands more than ten distinct pitch heights simultaneously — more than two human hands can play. How do you reduce a full orchestra to a piano score without destroying the harmonic structure? And what is the minimum number of voices absolutely required?

This episode answers both questions with graph coloring. Model each note as a vertex; connect two vertices when their sounding intervals overlap in time. The resulting interval graph encodes all simultaneity conflicts. The chromatic number of this graph is the minimum number of voices (colors) needed so that no two simultaneously-sounding notes share a voice. The Perfect Graph Theorem (Lovász, 1972) guarantees that for interval graphs — the chromatic number equals the clique number, i.e., the maximum number of notes sounding at once. A single greedy pass along the time axis achieves this bound in linear time.

When exceeds the number of available performers, the theorem gives the precise cost of every forced deletion — turning an artistic choice into a quantifiable trade-off.

中文: “完美图定理给了我们一个保证:对区间图,χ永远等于ω。不多不少。”


Prerequisites


Definitions

Def 6.1 (Proper Graph Coloring)

A proper -coloring of a graph is a function such that whenever .

The chromatic number is the smallest for which a proper -coloring exists.

Def 6.2 (Clique Number)

A clique in is a set of vertices that are pairwise adjacent. The clique number is the size of the largest clique.

Since any clique requires all its vertices to have distinct colors, always.

Def 6.3 (Interval Graph)

An interval graph is constructed from a finite set of closed intervals on the real line by:

  • setting (one vertex per interval),
  • connecting and with an edge iff (intervals overlap).

In the musical application, each interval represents the sounding duration of note : onset , release .

Def 6.4 (Perfect Graph)

A graph is perfect if for every induced subgraph :

Equivalently, is perfect iff neither nor its complement contains an odd cycle of length as an induced subgraph (this is the content of the Strong Perfect Graph Theorem, Chudnovsky et al. 2006).

Def 6.5 (Chromatic Polynomial)

The chromatic polynomial counts the number of proper -colorings of . It is a polynomial in of degree .

Examples:

  • — must assign distinct colors.
  • — tree on vertices; each new vertex has one neighbor constraint.
  • — the 5-cycle (odd cycle), which violates perfection: but , confirming .

Main Theorems

Theorem 6.1 (Interval Graphs are Perfect)
Every interval graph is a perfect graph: for any interval graph .
Proof.

We show that the greedy algorithm achieves colors, establishing . Since always, equality follows.

Algorithm: Sort the intervals by left endpoint: . Process vertices in this order. When processing vertex with interval , assign the smallest color .

Claim: The algorithm uses at most colors.

At the moment vertex is processed, the set of already-processed neighbors of is exactly — the intervals that started before and are still sounding when begins. Together with itself, the set is a clique (all pairwise overlapping, since they all contain in their interiors). Therefore .

Since needs a color different from at most colors, there is always a color in available. The algorithm never needs a -th color.

Why general graphs fail: The odd 5-cycle has but . The greedy ordering can be bad (e.g., alternating vertices of ) and need a third color. But cannot be an interval graph, because any five intervals containing a cyclic overlap pattern must contain a “triangle” (three mutually overlapping intervals) by the Helly property for intervals on the line: if pairwise intersections are nonempty, the total intersection is nonempty.

Theorem 6.2 (Perfect Graph Theorem (Lovász, 1972))

A graph is perfect if and only if its complement is perfect.

Equivalently (the Weak Perfect Graph Theorem): is perfect iff it contains no odd cycle of length as an induced subgraph, and neither does .

Proof.

The full proof is deep (Lovász’s original 1972 proof uses a topological argument; the full Strong Perfect Graph Theorem by Chudnovsky, Robertson, Seymour, Thomas (2006) is a 150-page paper). We give the key idea for the weak version.

Necessity (): An odd cycle with has (no triangle since it is an odd cycle) but (it takes 3 colors to properly color any odd cycle). So it is not perfect.

Sufficiency () sketch (Lovász’s approach): The key lemma is that any minimal non-perfect graph must satisfy where is the independence number. Lovász showed this forces the existence of an odd hole or odd antihole. The details require the theory of perfect graph structure theorems.

Theorem 6.3 (Brooks' Theorem)

For any connected graph that is neither a complete graph nor an odd cycle :

where is the maximum degree.

(The bound always holds by greedy coloring; Brooks' theorem improves this by 1 in all non-exceptional cases.)

Proof.

Greedy bound : When the greedy algorithm processes a vertex , it has at most neighbors already colored. At most colors are forbidden, so one of is always available.

Improvement to (sketch): The key step is to find a vertex ordering in which every vertex except the last has a neighbor later in the ordering. For a -regular connected non-complete graph, one shows (using a spanning tree rooted at a non-cut vertex) an ordering where each vertex has at most earlier-colored neighbors, allowing greedy to use only colors. The odd cycle is exceptional because any coloring attempt on fails at the last step.

Prop 6.1 (Helly Property for Intervals)
Let be a collection of intervals on the real line. If every two intervals intersect (pairwise intersection), then all intervals share a common point: .
Proof.

Let (rightmost left endpoint) and (leftmost right endpoint). For the interval achieving , say , and the interval achieving , say : since these two intersect, , i.e., . Then the point (or any point in ) belongs to every interval.

This property underlies the perfection of interval graphs: it prevents the formation of odd holes (chordless odd cycles of length ), since three pairwise-overlapping intervals always share a common time point, forming a triangle rather than a triangle-free cycle.


Musical Connection

音乐联系

Voice allocation as graph coloring

Every polyphonic score implicitly defines an interval graph: notes are vertices, simultaneous notes are adjacent. The chromatic number is the minimum voice count. For Bach’s C-major Fugue BWV 846:

  • Maximum simultaneous voices:
  • Chromatic number (by perfection):
  • Bach’s actual voices: 4 — exactly matching the theoretical minimum

No voice is redundant; no voice can be removed without a collision. The theorem proves that Bach’s four-voice writing is tight.

For Beethoven’s Fifth Symphony, fourth movement:

  • After collapsing octave doublings, at the climax
  • Two hands give at most 10 simultaneous notes
  • The theorem guarantees the reduction is lossy by necessity, not by artistic choice

Liszt’s strategy (1865) as high-degree-first deletion

When , Liszt retained the outer voices (melody and bass) and deleted middle-register doublings. In graph-theoretic terms: middle-register notes have the highest degree (most overlaps with other notes), so deleting them disrupts the fewest colorings. This is equivalent to a maximum independent set heuristic on the conflict subgraph — preserve as many non-conflicting notes as possible.

Register allocation in compilers (Chaitin, 1982)

IBM’s Gregory Chaitin recognized that assigning variables to CPU registers is exactly graph coloring: variables are vertices, two variables are adjacent if they are live simultaneously (overlap in program execution time), and registers are colors. The variable liveness graph is an interval graph (live ranges are intervals of program time), so and greedy allocation is optimal when registers suffice. When registers are insufficient ( registers available), some variables must “spill” to memory. Chaitin’s heuristic: spill the variable with the highest degree (most conflicts) — the same principle as Liszt deleting the most-overlapping middle voices.

Music and compiler design, separated by 117 years, converge on the same graph-coloring trade-off.


Limits and Open Questions

  1. The Four Color Theorem. For planar graphs (graphs drawable without edge crossings), . Proved by Appel and Haken (1976) using computer-assisted case analysis — the first major theorem proved by computer. Musical planar graphs arise when voice crossings are forbidden (a common constraint in choral writing).

  2. Kempe chains and the failed 1879 proof. Alfred Kempe published a purported proof of the four color theorem in 1879. His key idea was “Kempe chains” — maximal connected subgraphs alternating between two colors. In 1890, Percy Heawood found Kempe’s proof was flawed. Kempe chains are still used in graph coloring algorithms; the flaw only appears in a subtle case with five-colored maps.

  3. Chromatic polynomial complexity. Computing for general is -hard (harder than NP), but for interval graphs it can be computed in polynomial time due to the perfect structure.

  4. Tonal pitch space vs. pitch height. The interval graph model treats pitch height as a continuous real variable. But Western tonal harmony groups notes into equivalence classes (e.g., C4 and C5 are “the same harmony”). A richer model uses the pitch helix (introduced in EP08) and asks about coloring in that quotient space.

  5. Weighted coloring for dynamics. If different notes carry different dynamic markings, a weighted chromatic number would give the minimum number of weighted voices. This is open in general for weighted interval graphs.


Academic References

  1. Lovász, L. (1972). Normal hypergraphs and the perfect graph conjecture. Discrete Mathematics, 2(3), 253–267.

  2. Chudnovsky, M., Robertson, N., Seymour, P., & Thomas, R. (2006). The strong perfect graph theorem. Annals of Mathematics, 164(1), 51–229.

  3. Golumbic, M. C. (2004). Algorithmic Graph Theory and Perfect Graphs (2nd ed.). Elsevier. (The standard reference on interval graphs and perfect graphs.)

  4. Brooks, R. L. (1941). On colouring the nodes of a network. Mathematical Proceedings of the Cambridge Philosophical Society, 37(2), 194–197.

  5. Chaitin, G. J. (1982). Register allocation and spilling via graph coloring. ACM SIGPLAN Notices, 17(6), 98–105.

  6. Appel, K., & Haken, W. (1977). Every planar map is four colorable. Bulletin of the American Mathematical Society, 82(5), 711–712.

  7. Tymoczko, D. (2011). A Geometry of Music. Oxford University Press. Ch. 3 (Voice leading as motion in chord space).

  8. West, D. B. (2001). Introduction to Graph Theory (2nd ed.). Prentice Hall. Ch. 5 (Graph coloring).