Colored Pr¨ufer codes for k-edge colored trees
Manwon Cho, Dongsu Kim∗†
, Seunghyun Seo and Heesung Shin
Department of Mathematics, KAIST, Daejeon 305-701, Korea
Submitted: Dec 31, 2002; Accepted: Oct 15, 2003; Published: Jul 19, 2004
MR Subject Classifications: 05C05, 05C30
Abstract
A combinatorial bijection between k-edge colored trees and colored Pr¨ufer codes
for labelled trees is established. This bijection gives a simple combinatorial proof
for the number k(n2)!nkn
n2of k-edge colored trees with nvertices.
1 Introduction
Ak-edge colored tree is a labelled tree whose edges are colored from a set of kcolors
such that any two edges with a common vertex have different colors [2, p81, 5.28]. For a
pair (n, k) of positive integers, let Cn,k denote the set of all k-edge colored trees on vertex
set [n]={1,2,...,n}, with color set [k]. The number of k-edge colored trees in Cn,k is
already known:
Theorem 1. The number of k-edge colored trees on vertex set [n],n2,is
k(nk n)(nk n1) ···(nk 2n+3)=k(n2)!nk n
n2.
Stanley in [2, p124] introduces a proof of the above formula and asks whether there
is a simple bijective proof. In this paper we provide a combinatorial bijection between
k-edge colored trees and ‘colored Pr¨ufer codes’, thus establishing a simple bijective proof
of the above formula.
The Pr¨ufer code ϕ(T)=(a1,...,a
n2,1) of a labelled tree Twith vertex set [n]is
obtained from the tree by successively pruning the leaf with the largest label. To obtain
thecodefromT, we remove the largest leaf in each step, recording its neighbor ai,from
the tree, until the single vertex 1 is left. The inverse of ϕcan be described easily. Let
σ=(a1,...,a
n2,1) be a sequence of positive integers with ai[n] for all i. We can find
the tree Twhose code is σas follows:
Corresponding author: dskim@math.kaist.ac.kr
Partially supported by the Korea Research Foundation Grant(KRF-2001-015-DP0055).
the electronic journal of combinatorics 11 (2004), #N10 1
Let V={1}and E=.
For each ifrom n2to1,
if ai6∈ V,thensetbi+1 =ai,
otherwise set bi+1 =min{x:x[n]\V};
set V:= V∪{bi+1}and E:= E∪{{ai+1,b
i+1}}.
Let b1be the unique element in [n]\V.
Finally, set V:= V∪{b1}and E:= E∪{{a1,b
1}}.
Let Tbe the tree with vertex set Vand edge set E.
Example. Let Tbe the tree in Figure 1. The Pr¨ufer code of Tis (1,6,1,3,3,1). We
HHHH
H
HHHH
H
4
2
31
7
65
s
s
s
s
s
s
s
Figure 1: The tree Tcorresponding to (1,6,1,3,3,1)
can recover Tfrom its Pr¨ufer code by the above algorithm.
Clearly, Pr¨ufer codes are in one-to-one correspondence with labelled trees. The fol-
lowing is a well known result. See [1, 2].
Theorem 2. The number of the tree on [n]vertices is nn2.
Proof. Any sequence (a1,a
2,...,a
n2)[n]n2of integers corresponds to a Pr¨ufer code
(a1,a
2,...,a
n2,1) which in turn determines a unique labelled tree with vertex set [n].
2 Colored Pr¨ufer code
Let Pn,k denote the set of all arrays of the form
a1a2··· an21
c1c2··· cn2cn1,
such that (a1,c
1),(a2,c
2),...,(an2,c
n2)[n]×[k1] are distinct and cn1[k]. An
array like the above is called a colored Pr¨ufer code, since its first row is a Pr¨ufer code and
its second row can be interpreted as an edge-coloring.
the electronic journal of combinatorics 11 (2004), #N10 2
Lemma 3. The cardinality of Pn,k is
k(n2)! nk n
n2.
Proof. Consider an element σ∈P
n,k:
σ=a1a2··· an21
c1c2··· cn2cn1.
The conditions for σare: (ai,c
i)[n]×[k1] for 1 in2, cn1[k] and the first
n2 columns of σare distinct. So the number of possible σis
k(nk n)(nk n1)(nk n2) ···(nk 2n+3)=k(n2)! nk n
n2.
Recall that Cn,k is the set of all k-edge colored trees on vertex set [n] with color set
[k]. Let Tbe a k-edge colored tree in Cn,k with vertex set V(T)andedgesetE(T). Let
CT:E(T)[k] denote the edge-coloring of T, i.e. CT(e) is the color of edge ein T.
For each pair of distinct edges eand e0in T, define the distance between eand e0,
denoted by d(e, e0), to be l1whenlis the shortest length of paths containing eand e0.
Note that the distance between edges sharing a vertex is one.
When xis the smallest neighbor of 1 in T, we call the edge α={1,x}the root edge
of T. For any two edges e,e0in Twith a common vertex, we call ethe parent edge of e0
and e0the child edge of e,ifd(e, α)+1=d(e0).
Let e
Cn,k denote the set of labelled trees with vertex set [n] whose edges are colored
from a set of kcolors, say [k], in such a way that
1. the root edge is colored from [k],
2. any pair of edges sharing a vertex with a common parent edge have distinct colors,
and
3. edges which are not the root edge are colored from [k1].
For a tree Tin e
Cn,k,let e
CTdenote the edge-coloring of T, i.e. e
CT(e)isthecolorofedge
ein T.
Bijection φ
We define a mapping φ:e
Cn,k →P
n,k through the following steps:
Set T0:= T.
the electronic journal of combinatorics 11 (2004), #N10 3
For any i,1in1, assuming that Ti1is defined already, define ai,bi,ciand
Ti:biis the largest leaf in Ti1,aiis the vertex adjacent to bi,Tiis the tree obtained
by removing the vertex biand the edge {ai,b
i}from Ti1,andci=e
CT({ai,b
i}).
Define φ(T)by
φ(T)=a1a2··· an21
c1c2··· cn2cn1
Note that the first row of φ(T)isthePr¨ufer code of T,soφis one-to-one.
Clearly, the first n2 columns of φ(T) are distinct, and ci[k1] for 1 in2,
cn1[k]. So φ(T) is an element in Pn,k.
Bijection ψ
We now define a mapping ψ:Pn,k e
Cn,k,whichistheinverseofφ.Letσbe an element
in Pn,k:
σ=a1a2··· an21
c1c2··· cn2cn1.
We construct, by the following algorithm, a labelled tree whose Pr¨ufer code is the first
row of σ, with an edge-coloring e
CT:
Let V={1}and E=.
For each ifrom n2to1,
if ai6∈ V,thensetbi+1 =ai,
otherwise set bi+1 =min{x:x[n]\V};
set V:= V∪{bi+1}and E:= E∪{{ai+1,b
i+1}}.
Let b1be the unique element in [n]\V.
Finally, set V:= V∪{b1}and E:= E∪{{a1,b
1}}.
Let Tbe the tree with vertex set Vand edge set E.
Set e
CT({ai,b
i})=cifor i[n2] and e
CT({1,b
n1})=cn1.
Let ψ(σ) be the resulting tree with edge-coloring e
CT. Clearly ψ(σ)isin e
Cn,k and ψis the
inverse of φ. So we have the following.
Lemma 4. The mapping φ:e
Cn,k →P
n,k is a bijection and thus the cardinality of e
Cn,k is
k(n2)! nk n
n2.
the electronic journal of combinatorics 11 (2004), #N10 4
Main result
We now define a mapping from Cn,k to e
Cn,k. For any T∈C
n,k, define e
CT:E(T)[k]
as follows:
Let xbe the smallest neighbor of 1 and αdenote edge {1,x}.Sete
CT(α)=CT(α).
Assume that e
CT(f) is defined for all edges fsuch that d(α, f )<i. For an edge g
with d(α, g)=i,lethbe the unique edge such that d(α, h)=i1andd(h, g)=1.
Define e
CT(g)by
e
CT(g)=(CT(g),if CT(g)e
CT(h),
CT(g)1,otherwise.
Note that e
CT(f)k1 for all f6=α.Let(T) be the tree Twith its edge-coloring CT
replaced by e
CT. Clearly ∆(T) is an element in e
Cn,k.
We next define a mapping Λ from e
Cn,k to Cn,k. For any Te
Cn,k, define CT:E(T)[k]
as follows:
Let xbe the smallest neighbor of 1 and αdenote the edge {1,x}.SetCT(α)=
e
CT(α).
Assume that CT(f) is defined for all edges fsuch that d(α, f)<i. For an edge g
with d(α, g)=i,lethbe the unique edge such that d(α, h)=i1andd(h, g)=1.
Define CT(g)by
CT(g)=(e
CT(g),if e
CT(g)<C
T(h),
e
CT(g)+1,otherwise.
Note that CT(f)kfor all fand no pair of two edges with a common vertex have the
same color. Let Λ(T) be the tree Twith its edge-coloring e
CTreplaced by CT. Clearly
Λ(T) is an element in Cn,k.
Clearly, Λ is the inverse of ∆. Hence we have the following crucial lemma:
Lemma 5. The mapping ∆:Cn,k e
Cn,k is a bijection.
Example. Ak-edge colored tree Tin C10,5and its ∆(T) are in Figures 2 and 3. The
edge {1,3}is the root edge.
We can now count the number of the k-edge colored trees with nvertices. The following
is the restatement of Theorem 1.
Theorem 6 (Main theorem). The number of k-edge colored trees on [n]is
k(n2)! nk n
n2.
the electronic journal of combinatorics 11 (2004), #N10 5