Rooting a Tree and Assigning Levels
A tree can be colored without making a sequence of local choices: choose any vertex as a root, measure every vertex’s distance from it, and alternate two colors as the distance increases. The key fact that makes this work is specific to trees: every edge joins vertices whose distances from the root differ by exactly one. We will prove that fact and then use it to establish the chromatic number of every tree, including the one-vertex case.
All graphs in this tutorial are finite and simple. A path is a sequence of distinct vertices in which consecutive vertices are adjacent. Its length is the number of edges in the sequence. A cycle is a sequence \(v_0,v_1,\ldots,v_k\) with \(k\ge 3\), \(v_0=v_k\), \(v_0,\ldots,v_{k-1}\) distinct, and consecutive vertices adjacent. A graph is connected if there is a path between every pair of distinct vertices.
A tree is connected, so each vertex has a path from the root. We first establish that this path is unique; this ensures that the levels describe a single, well-defined route outward from the root.
Proof. Let \(u\) and \(v\) be distinct vertices of a tree. Connectedness gives at least one \(u\)-\(v\) path. Suppose there are two different such paths. Starting from \(u\), take their first point of divergence and then follow the paths until the first point where the diverging portions meet again; such a meeting exists at least at \(v\). The two portions between these points have no common internal vertex, by the choice of the first meeting. Following one portion forward and the other backward therefore gives a cycle. Its length is at least \(3\): the portions are distinct, and in a simple graph they cannot both be the same single edge. This contradicts that a tree has no cycles. Thus the path is unique. \(\square\)
Every Edge Joins Consecutive Levels
Proof. Let \(P_u\) and \(P_v\) be the unique paths from \(r\) to \(u\) and from \(r\) to \(v\). First consider the case where neither endpoint lies on the root path to the other: \(u\) is not on \(P_v\), and \(v\) is not on \(P_u\). The paths share an initial segment from \(r\), and after they diverge they cannot meet again, since that would give two different paths between a pair of vertices, contrary to the preceding lemma. Their two tails, together with the edge \(uv\), form a cycle. This is impossible in a tree. Therefore one endpoint lies on the root path to the other; suppose, for example, that \(u\) lies on \(P_v\).
The part of \(P_v\) from \(u\) to \(v\) is a path between \(u\) and \(v\). The edge \(uv\) is also a path between them. By uniqueness of paths, these must be the same path, so the part of \(P_v\) from \(u\) to \(v\) consists of the single edge \(uv\). Consequently \(d(r,v)=d(r,u)+1\). If instead \(v\) lies on \(P_u\), the same argument gives \(d(r,u)=d(r,v)+1\). In either case the levels differ by exactly one. \(\square\)
In particular, an edge never joins vertices at the same level, and it does not skip a level. This conclusion depends on the graph being a tree: for a general graph, adjacent vertices can lie at the same distance from a chosen root.
Alternating Colors by Level
For a rooted tree, assign one color to vertices on even levels and a second color to vertices on odd levels. The edge-level lemma proves this is proper: along every edge the level changes by exactly one, so its endpoints have opposite parity and therefore different colors.
Proof. Let \(T\) have at least two vertices, choose any root \(r\), and assign color \(A\) to vertices at even distance from \(r\) and color \(B\) to vertices at odd distance from \(r\). The edge-level lemma shows that the endpoints of every edge lie on consecutive levels. Consecutive integers have opposite parity, so every edge has one endpoint colored \(A\) and the other colored \(B\). This is a proper coloring, and hence \(\chi(T)\le 2\).
Because \(T\) is connected and has at least two vertices, there is a path between two distinct vertices. That path contains an edge. The endpoints of an edge must have different colors in any proper coloring, so one color cannot suffice; thus \(\chi(T)\ge 2\). Combining the two bounds gives \(\chi(T)=2\).
Now suppose \(T\) has exactly one vertex. Assigning one color to that vertex is proper, since there are no edges whose endpoints need different colors. A coloring uses a color on each vertex, so a nonempty graph cannot be colored with zero colors. Therefore \(\chi(T)=1\). \(\square\)
The root is arbitrary. Choosing a different root may change which vertices receive color \(A\) and which receive color \(B\), but the same edge-level proof applies. The result concerns the existence of a proper coloring with two colors, not a unique assignment of color names.
Worked Example: Alternating Levels in a Branching Tree
Let \(T\) have vertex set \(V(T)=\{1,2,3,4,5,6\}\) and edge set \(E(T)=\{12,13,24,25,36\}\). Root the tree at \(1\). The paths from \(1\) give \(d(1,1)=0\), \(d(1,2)=1\), \(d(1,3)=1\), \(d(1,4)=2\), \(d(1,5)=2\), and \(d(1,6)=2\). Thus the levels are \(L_0=\{1\}\), \(L_1=\{2,3\}\), and \(L_2=\{4,5,6\}\).
Color the even levels \(A\) and the odd levels \(B\). The color classes are \(\{1,4,5,6\}\) and \(\{2,3\}\). Check every edge: \(12\) joins levels \(0\) and \(1\); \(13\) joins \(0\) and \(1\); \(24\) joins \(1\) and \(2\); \(25\) joins \(1\) and \(2\); and \(36\) joins \(1\) and \(2\). Each edge therefore has one endpoint of each color.
Check: the edge list contains five edges, and the five checks above account for all of them. The coloring is proper. Since \(12\) is an edge, a proper coloring cannot use only one color; consequently this tree has chromatic number \(2\).
Worked Example: Rooting a Path at an Interior Vertex
Let \(T\) have vertex set \(V(T)=\{a,b,c,d,e,f\}\), edge set \(E(T)=\{ab,bc,cd,de,ef\}\), and root \(c\). The unique paths from \(c\) give \(d(c,c)=0\), \(d(c,b)=1\), \(d(c,d)=1\), \(d(c,a)=2\), \(d(c,e)=2\), and \(d(c,f)=3\). Thus \(L_0=\{c\}\), \(L_1=\{b,d\}\), \(L_2=\{a,e\}\), and \(L_3=\{f\}\).
Coloring even levels \(A\) and odd levels \(B\) gives \(A=\{c,a,e\}\) and \(B=\{b,d,f\}\). The edge \(ab\) joins levels \(2\) and \(1\); \(bc\) joins \(1\) and \(0\); \(cd\) joins \(0\) and \(1\); \(de\) joins \(1\) and \(2\); and \(ef\) joins \(2\) and \(3\). Every edge crosses between the two color classes, including \(bc\) and \(cd\), which meet the root’s level.
Check: all five edges in the specified edge set have been checked, and each joins consecutive levels. Since the tree has the edge \(ab\), the displayed proper coloring with two colors is optimal.
Worked Example: The Single-Vertex Tree
Let \(T\) have vertex set \(V(T)=\{x\}\) and edge set \(E(T)=\varnothing\), with root \(x\). The only vertex has distance \(d(x,x)=0\), so it lies on level \(L_0=\{x\}\). Assign it color \(A\); there is no second vertex and no edge to check.
Check: the edge set is empty, so the condition that every edge has differently colored endpoints is satisfied. One color is enough, and zero colors cannot assign a color to \(x\). Hence \(\chi(T)=1\), not \(2\).
Why the Tree Condition Matters
The level argument is useful because it gives both a coloring and a direct verification: calculate distances from a root, divide vertices by parity, and use the edge-level lemma to check every edge at once. In applications, this can express a two-way division of the vertices in which adjacent vertices belong to opposite groups. It also gives an optimal coloring immediately for any tree with an edge; there is no need to search through possible color assignments.
A common mistake is to assume that every edge of every graph joins different levels. For a concrete counterexample, take the triangle \(G\) with \(V(G)=\{1,2,3\}\), \(E(G)=\{12,13,23\}\), and root \(1\). The distances are \(d(1,1)=0\), \(d(1,2)=1\), and \(d(1,3)=1\). The edge \(23\) joins two vertices at the same level. Coloring by level parity would give both \(2\) and \(3\) the same color, so that coloring would not be proper.
The correction is to check the hypothesis before using the level argument. The triangle is not a tree: it is connected, but it has the cycle \(1,2,3,1\). In a tree, the unique-path property rules out an edge joining two vertices at the same level. The theorem does not say that alternating levels properly colors every rooted graph; it says that it works for rooted trees because their edges must join consecutive levels.
There is a separate small-case pitfall: saying “a tree uses exactly two colors” without excluding the single-vertex tree. The two-color assignment is still a proper coloring of a single vertex, but it is not minimal. The chromatic number is \(1\) there. For every tree with at least two vertices, connectedness guarantees at least one edge, which forces the chromatic number to be \(2\).
Check Your Understanding
Use the unique-path and edge-level arguments to justify your answers.
- Let \(T\) have vertices \(\{r,a,b,c,d\}\), edges \(\{ra,rb,ac,bd\}\), and root \(r\). List the levels and give the two color classes.
- Why does uniqueness of paths rule out an edge between vertices on the same level of a rooted tree?
- Prove that changing the root of a tree does not affect the conclusion that the tree with at least two vertices has chromatic number \(2\).
- For the triangle with root \(1\), identify the edge that prevents the level-parity assignment from being proper.
- Explain why a single-vertex tree does not need two colors, even though it can be assigned one of two alternating colors.