Rainbow Colouring ofSplit and Threshold Graphs

# Rainbow Colouring of Split and Threshold Graphs

L. Sunil Chandran Department of Computer Science and Automation,
Indian Institute of Science,
Bangalore -560012, India.
{sunil, deepakr}@csa.iisc.ernet.in
Deepak Rajendraprasad Department of Computer Science and Automation,
Indian Institute of Science,
Bangalore -560012, India.
{sunil, deepakr}@csa.iisc.ernet.in
###### Abstract

A rainbow colouring of a connected graph is a colouring of the edges of the graph, such that every pair of vertices is connected by at least one path in which no two edges are coloured the same. Such a colouring using minimum possible number of colours is called an optimal rainbow colouring, and the minimum number of colours required is called the rainbow connection number of the graph. A Chordal Graph is a graph in which every cycle of length more than has a chord. A Split Graph is a chordal graph whose vertices can be partitioned into a clique and an independent set. A threshold graph is a split graph in which the neighbourhoods of the independent set vertices form a linear order under set inclusion. In this article, we show the following:

1. The problem of deciding whether a graph can be rainbow coloured using colours remains NP-complete even when restricted to the class of split graphs. However, any split graph can be rainbow coloured in linear time using at most one more colour than the optimum.

2. For every integer , the problem of deciding whether a graph can be rainbow coloured using colours remains NP-complete even when restricted to the class of chordal graphs.

3. For every positive integer , threshold graphs with rainbow connection number can be characterised based on their degree sequence alone. Further, we can optimally rainbow colour a threshold graph in linear time.

Keywords: rainbow connectivity, rainbow colouring, threshold graphs, split graphs, chordal graphs, degree sequence, approximation, complexity.

## 1 Introduction

Connectivity is one of the basic concepts of graph theory. It plays a fundamental role both in theoretical studies and in applications. When a network (transport, communication, social, etc) is modelled as a graph, connectivity gives a way of quantifying its robustness. This may be the reason why connectivity is possibly the problem that has been studied on the largest variety of computational models [25]. Due to the diverse application requirements and manifold theoretical interests, many variants of the connectivity problem have been studied. One typical case is when there are different possible types of connections (edges) between nodes and additional restrictions on connectivity based on the types of edges that can used in a path. In this case we can model the network as an edge-coloured graph. One natural restriction to impose on connectivity is that any two nodes should be connected by a path in which no edge of the same type (colour) occurs more than once. This is precisely the property called rainbow connectivity. Such a restriction for the paths can arise, for instance, in routing packets in a cellular network with transceivers that can operate in multiple frequency bands or in routing secret messages between security agencies using different handshaking passwords in different links [18] [5]. The problem was formalised in graph theoretic terms by Chartrand et al. [7] in 2008.

An edge colouring of a graph is a function from its edge set to the set of natural numbers. A path in an edge coloured graph with no two edges sharing the same colour is called a rainbow path. An edge coloured graph is said to be rainbow connected if every pair of vertices is connected by at least one rainbow path. Such a colouring is called a rainbow colouring of the graph. A rainbow colouring using minimum possible number of colours is called optimal. The minimum number of colours required to rainbow colour a connected graph is called its rainbow connection number, denoted by . For example, the rainbow connection number of a complete graph is , that of a path is its length, that of an even cycle is its diameter, that of an odd cycle of length at least is one more than its diameter, and that of a tree is its number of edges. Note that disconnected graphs cannot be rainbow coloured and hence the rainbow connection number for them is left undefined. Any connected graph can be rainbow coloured by giving distinct colours to the edges of a spanning tree of the graph. Hence the rainbow connection number of any connected graph is less than its number of vertices.

While formalising the concept of rainbow colouring, Chartrand et al. also determined the precise values of rainbow connection number for some special graphs [7]. Subsequently, there have been various investigations towards finding good upper bounds for rainbow connection number in terms of other graph parameters [4] [21] [15] [24] [2] and for many special graph classes [19] [24] [2] [3]. Behaviour of rainbow connection number in random graphs is also well studied [4] [11] [23] [9]. A basic introduction to the topic can be found in Chapter of the book Chromatic Graph Theory by Chartrand and Zhang [6] and a survey of most of the recent results in the area can be found in the article by Li and Sun [18] and also in their forthcoming book Rainbow Connection of Graphs [17].

On the computational side, the problem has received relatively less attention. It was shown by Chakraborty et al. that computing the rainbow connection number of an arbitrary graph is NP-Hard [5]. In particular, it was shown that the problem of deciding whether a graph can be rainbow coloured using colours is NP-complete. Later, Ananth et al. [1] complemented the result of Chakraborty et al., and now we know that for every integer , it is NP-complete to decide whether a given graph can be rainbow coloured using colours. Chakraborty et al., in the same article, also showed that deciding whether a given edge coloured graph is rainbow connected is NP-complete. It was then shown by Li and Li that this problem remains NP-complete even when restricted to the class of bipartite graphs [16].

On the positive side, Basavaraju et al. have demonstrated an -time -factor approximation algorithm for rainbow colouring any graph with radius [2]. Constant factor approximation algorithms for rainbow colouring Cartesian, strong and lexicographic products of non-trivial graphs are reported in [3]. Constant factor approximation algorithms for bridgeless chordal graphs, and additive approximation algorithms for interval, AT-free, threshold and circular arc graphs without pendant vertices will follow from the proofs of their upper bounds [24]. To the best of our knowledge, no efficient optimal rainbow colouring algorithm has been reported for any non-trivial subclass of graphs.

### 1.1 Our Results

In this article we consider the problem of rainbow colouring split graphs and a particular subclass of split graphs called threshold graphs (Definition 3). We show the following results.

• The problem of deciding whether a graph can be rainbow coloured using colours remains NP-complete even when restricted to the class of split graphs (Corollary 5). Any split graph can be rainbow coloured in linear time using at most one more colour than the optimum (Algorithm 1).

This is similar to the problem of finding the chromatic index of a graph. Though every graph with maximum degree can be properly edge-coloured in time using colours using a constructive proof of Vizing’s Theorem [20], it is NP-hard to decide whether the graph can be coloured using colours [12].

No two pendant edges (Definition 2) can share the same colour in any rainbow colouring of a graph (Observation 2). The -approximation algorithm above is obtained by carefully reusing the same colours on most of the remaining edges of the graph. The hardness result is obtained by demonstrating a reduction from the problem of -colourability of -uniform hypergraphs. In fact, the technique in the reduction can be extended to show the following result for chordal graphs.

• For every integer , the problem of deciding whether a graph can be rainbow coloured using colours remains NP-complete even when restricted to the class of chordal graphs (Theorem 6).

Though a similar hardness result is known for deciding the rainbow connection number of general graphs, the above strengthening to chordal graphs is interesting since, unlike for general graphs, a constant factor approximation algorithm is already known for rainbow colouring chordal graphs. Chandran et al. [24] have shown that any bridgeless chordal graph can be rainbow coloured using at most colours, where is the radius of the graph. The proof given there is constructive and can be easily extended to a polynomial-time algorithm which will colour any chordal graph with bridges and radius using at most colours. Since is easily seen to be a lower bound for , this immediately gives us a -factor approximation algorithm.

• For every positive integer , threshold graphs with rainbow connection number exactly can be characterised based on their degree sequence (Definition 2) alone (Corollary 14). Further, we can optimally rainbow colour a threshold graph in linear time (Algorithm 4).

In particular we show that if is the degree sequence of an -vertex threshold graph , then

 rc(G)=⎧⎪⎨⎪⎩1,dn=n−12,dn

where and .

Both the characterisation and the algorithm are obtained by connecting the problem of rainbow colouring a threshold graph to that of generating a prefix-free binary code.

### 1.2 Preliminaries

All graphs considered in this article are finite, simple and undirected. For a graph , we use and to denote its vertex set and edge set respectively. Unless mentioned otherwise, and will respectively denote the number of vertices and edges of the graph in consideration. The shorthand denotes the set . The cardinality of a set is denoted by .

###### Definition 1.

Let be a connected graph. The length of a path is its number of edges. The distance between two vertices and in , denoted by is the length of a shortest path between them in . The eccentricity of a vertex is . The diameter of is and radius of is .

###### Definition 2.

The neighbourhood of a vertex is the set of vertices adjacent to but not including . The degree of a vertex is . The degree sequence of a graph is the non-increasing sequence of its vertex degrees. A vertex is called pendant if its degree is . An edge incident on a pendant vertex is called a pendant edge.

###### Definition 3.

A graph is called chordal, if there is no induced cycle of length greater than . A graph is a split graph, if can be partitioned into a clique and an independent set. A graph is a threshold graph, if there exists a weight function and a real constant such that two vertices are adjacent if and only if .

Before getting into the main results, we note two elementary and well known observations on rainbow colouring whose proofs we omit.

###### Observation 1.

For every connected graph , we have .

###### Observation 2.

If and are two pendant vertices in a connected graph , then their incident edges get different colours in any rainbow colouring of . In particular, if has pendant vertices, then .

## 2 Split Graphs: Hardness and Approximation Algorithm

We first show that determining the rainbow connection number of a split graph is NP-hard, by demonstrating a reduction to it from the -colouring problem on -uniform hypergraphs.

###### Definition 4.

A hypergraph is a tuple , where is a finite set and . Elements of and are called vertices and (hyper-)edges respectively. The hypergraph is called -uniform if for every . An -uniform hypergraph is called complete if .

###### Definition 5.

Given a hypergraph and a colouring , an edge is called -coloured if the edge contains vertices of different colours. An edge is called monochromatic if it is -coloured. The colouring is called proper if no edge in is monochromatic under . The minimum number of colours required to properly colour is called its chromatic number and is denoted by .

We need a -uniform hypergraph of chromatic number to avoid the occurrence of a border case in the reduction. The following observation gives us one.

###### Observation 3.

Let be the complete -uniform hypergraph on vertices. Then .

###### Proof.

Assign colours to the vertices of . This is a proper colouring of since every edge contains vertices and hence cannot be monochromatic. On the other hand, in any colouring of using fewer than colours, some three vertices have to share the same colour and hence the edge of constituted of those vertices will be monochromatic. Hence . ∎

It follows from Theorem in [13] that it is NP-hard to decide whether an -vertex -uniform hypergraph can be properly coloured using colours. A reduction from this problem to a problem of computing the rainbow connection number of a split graph is illustrated in the proofs of Theorem 4 and Theorem 6.

###### Theorem 4.

The first problem below (P1) is polynomial-time reducible to the second (P2).

1. Given a -uniform hypergraph , decide whether .

2. Given a split graph , decide whether .

###### Proof.

Let be the disjoint union of and a complete -uniform hypergraph on vertices (). This ensures that (Observation 3) and that iff . Let and be the vertex set and edge set, respectively, of . We construct a graph from as follows (See Figure 1).

 VG = VH∪EH∪{a0,a1,a2,b} (2) EG = {{v,e}:v∈VH,e∈EH,v∈e in H} (3) ∪{{v,v′}:v,v′∈VH,v≠v′} ∪{{b,v}:v∈VH} ∪{{ai,b}:i=0,1,2}

The graph thus constructed is a split graph with being a clique and its complement with respect to , which is , being an independent set. It is clear that can be constructed from in polynomial-time. We complete the proof by showing that iff .

Firstly, we show that if , then . Since , it suffices to show that can be properly -coloured. Let be a rainbow colouring of . Define a colouring by for each . We claim that is a proper colouring of . For the sake of contradiction, suppose that one of the hyper-edges of is monochromatic under , i.e, all the vertices in get the same colour for some . This happens only when . Hence all the paths of length two from to in will use the colour . Since are pendant vertices, the edges from to all have distinct colours in any rainbow colouring of (Observation 2). Hence one of them, say , gets the colour . Then it is easy to see that there is no rainbow path from to in under (Note that any rainbow path in a -coloured graph has length at most ). This contradicts the fact that was a rainbow colouring of .

Next, we show that if , then . Since has pendant vertices, (Observation 2). So it suffices to show that can be rainbow coloured using colours. Let be a proper colouring of . Let , , be the colour classes. Note that none of the colour classes is empty as . We define a colouring as follows (See Figure 2). for each . Consider a hyper-edge of . If is -coloured in then (Note that the colours are from and hence the addition is modulo ). If is -coloured in , then without loss of generality, let and , . Set , , and . This ensures that for every hyper-edge , for each colour , there exists a -length rainbow path from to such that colour does not appear in path . The remaining edges of are coloured as follows.

 CG({ai,b}) = i∀i∈Z3 CG({v,v′}) = i∀v,v′∈Vi,v≠v′,∀i∈Z3 CG({v,v′}) = 2∀v∈V0,v′∈V1∪V2 CG({v,v′}) = 0∀v∈V1,v′∈V2. (4)

We show that is a rainbow colouring of by demonstrating a rainbow path between every pair of non adjacent vertices in . First we demonstrate the paths from to all their non-adjacent vertices. (The numbers above an edge indicate the colour assigned to the edge under .)

 \pathaiaj,i≠j : ai\lx@stackreli---\negthinspace---b\lx@stackrelj---\negthinspace---aj \pathaivj∈Vj,i≠j : ai\lx@stackreli---\negthinspace---b\lx@stackrelj---\negthinspace---vj \pathaivi∈Vi : a0\lx@stackrel0---\negthinspace---b\lx@stackrel1---\negthinspace---V1\lx@stackrel2---\negthinspace---v0 a1\lx@stackrel1---\negthinspace---b\lx@stackrel0---\negthinspace---V0\lx@stackrel2---\negthinspace---v1 a2\lx@stackrel2---\negthinspace---b\lx@stackrel1---\negthinspace---V1\lx@stackrel0---\negthinspace---v2 \pathaie∈EH : ai\lx@stackreli---\negthinspace---b\lx@stackrelPe,i---\negthinspace---e \pathbe∈EH : b\lx@stackrelPe,0---\negthinspace---% e (5)

The rainbow path between any vertex and a non-adjacent vertex is given by , if . It remains to demonstrate a rainbow path between any two vertices . By we denote the -tuple . If is -coloured, we relabel so that and hence . If is -coloured, we relabel so that and such that and . We do the same for too. Edges and may share some vertices, in which case the same vertex will get different labels when considered under and . We consider the following cases separately: (i) both and are -coloured, (ii) is -coloured and is 2-coloured and (iii) both and are -coloured. The last case is further split into sub-cases.

 CH(e)=CH(e′)=(0,1,2) :e\lx@stackrel1---\negthinspace---v0\lx@stackrel2---\negthinspace---v′2\lx@stackrel0---\negthinspace---e′ (Case i) CH(e)=(0,1,2),CH(e′)=(i,i,j),i≠j :e\lx@stackreli+1---\negthinspace---vi\lx@stackreli---\negthinspace---v′1\lx@stackreli+2---\negthinspace---e′ (Case ii) CH(e)=(i,i,j),CH(e′)=(i,i,k) :e\lx@stackreli+1---\negthinspace---v0\lx@stackreli---\negthinspace---v′1\lx@stackreli+2---\negthinspace---e′ (Case iii) CH(e)=(0,0,j),CH(e′)=(1,1,k) :e\lx@stackrel1---\negthinspace---v0\lx@stackrel2---\negthinspace---v′1\lx@stackrel0---\negthinspace---e′ CH(e)=(1,1,j),CH(e′)=(2,2,k) :e\lx@stackrel2---\negthinspace---v0\lx@stackrel0---\negthinspace---v′1\lx@stackrel1---\negthinspace---e′ CH(e)=(2,2,j),CH(e′)=(0,0,k) :e\lx@stackrel0---\negthinspace---v0\lx@stackrel2---\negthinspace---v′0\lx@stackrel1---\negthinspace---e′ (6)

It is possible that may coincide with in Case (ii), and may coincide with in the first sub-case of Case (iii). In both those situations, we still get a -length rainbow path between the end points without using the middle edge indicated above. We have exhausted all the cases and hence is a rainbow colouring of . ∎

Since Problem P1 is known to be NP-hard, so is Problem P2. Further, it is easy to see that the problem P2 is in NP. Hence the following corollary.

###### Corollary 5.

Deciding whether remains NP-complete even when is restricted to be in the class of split graphs.

The reduction used in the proof of Theorem 4 can be extended to show that for every , it is NP-complete to decide whether a chordal graph can be rainbow coloured using colours.

###### Theorem 6.

For any integer , the first problem below (P1) is polynomial-time reducible to the second (P2).

1. Given a -uniform hypergraph , decide whether .

2. Given a chordal graph , decide whether .

In particular, for every integer , the problem of deciding whether remains NP-complete even when is restricted to be in the class of chordal graphs.

###### Proof.

Let be the disjoint union of and a complete -uniform hypergraph on vertices (). This ensures that (Observation 3) and that iff . Let and be the vertex set and edge set, respectively, of . Let be fixed. We construct a graph from as follows (See Figure 3).

 VG = VH∪EH∪{a0,a1,a2,b0,…,bk−3} (7) EG = {{v,e}:v∈VH,e∈EH,v∈e in H} (8) ∪{{v,v′}:v,v′∈VH,v≠v′} ∪{{bk−3,v}:v∈VH} ∪{{bi−1,bi}:i=1,…,k−3} ∪{{ai,b0}:i=0,1,2}

The graph thus constructed is easily seen to be a chordal graph with diameter . It is clear that can be constructed from in polynomial-time. We complete the proof by showing that iff .

It is easy to see that when , the graph constructed as above is the same as the split graph constructed in the proof of Theorem 4. In that proof we showed a rainbow colouring of using colours in the case when . The same colouring can be extended to by giving new colours exclusively to the edges . Since the original -colouring made rainbow connected, it is easy to see that this colouring makes rainbow connected. Hence it is enough to show that if , then .

Since , it suffices to show that can be properly -coloured. Let be a rainbow colouring of . Since the subgraph of induced on is a tree with edges, it is easy to see that in any rainbow colouring of the edges of get distinct colours. Without loss of generality we rename the colours so that . Hence the edges in the path from to get colours from . Define a colouring by for each . We claim that is a proper colouring of . For the sake of contradiction, suppose that one of the hyper-edges of is monochromatic under , i.e, all the vertices in get the same colour for some . This happens only when . If is or , all the paths of length two from to in will use the colour and hence there is no (-length) rainbow path from to . If is , then too, all the paths of length two from to in will use one of the colours already used in the unique path from to and hence there is no (-length) rainbow path from to .

Since Problem P1 is known to be NP-hard, so is Problem P2. Further, it is easy to see that the problem P2 is in NP. Hence the result. ∎

In the wake of Corollary 5, it is unlikely that there exists a polynomial-time algorithm to optimally rainbow colour split graphs in general. In Section 3, we show that the problem is efficiently solvable when restricted to threshold graphs, which are a subclass of split graphs. Before that, we describe a linear-time (approximation) algorithm which rainbow colours any split graph using at most one colour more than the optimum (Theorem 7). First we note that it is easy to find a maximum clique in a split graph, as follows.

The vertices of a graph can be sorted according to their degrees in time using a counting sort [22]. If is a split graph with the vertices labelled so that , where is degree of vertex , then is a maximum clique in and is a maximum independent set in [10]. Hence we can assume, if needed, that a maximum clique or a maximum independent set or an ordering of the vertices according to their degrees is given as input to our algorithms.

###### Theorem 7.

For every connected split graph , Algorithm 1 (ColourSplitGraph) rainbow colours using at most colours. Further, the time-complexity of Algorithm 1 is .

###### Proof.

If is a clique, then and Algorithm 1 colours every edge of with colour . This is an optimal rainbow colouring for . Hence we can assume that is not a clique in the following discussions. So . It is easy to check, by considering all pairs of non-adjacent vertices, that Algorithm 1 indeed produces a rainbow colouring of . For example, between two vertices , we get a rainbow path . It is also evident that the algorithm uses at most colours. By Observation 1 and Observation 2, . Hence the rainbow colouring produced by Algorithm 1 uses at most colours.

Further, the algorithm visits each edge exactly once and hence the time-complexity is . ∎

The following bounds follow directly from Observation 1, Observation 2, and Theorem 7.

###### Corollary 8.

For every connected split graph with pendant vertices and diameter ,

 max{p,d}≤rc(G)≤max{p+1,3}.

## 3 Threshold Graphs: Characterisation and Exact Algorithm

Threshold graphs form a subclass of split graphs (Observation 9b). The neighbourhoods of vertices in a maximum independent set of a threshold graph form a linear order under set inclusion (Observation 9c). We exploit this structure to give a full characterisation of rainbow connection number of threshold graphs based on degree sequences (Corollary 14). We use this characterisation to design a linear-time algorithm to optimally rainbow colour any threshold graph (Algorithm 4).

The following observations are easy to make from the definition of a threshold graph (Definition 3).

###### Observation 9.

Let be a threshold graph with a weight function . Let the vertices be labelled so that . Then

1. , where is the degree of vertex .

2. is a maximum independent set and is a clique in . In particular, every threshold graph is a split graph.

3. , for every . Thus the neighbourhoods of vertices in form a linear order under set inclusion. Further, if is connected, then every vertex in is adjacent to .

###### Definition 6.

A binary codeword is a finite string over the alphabet (bits). The length of a codeword , denoted by , is the number of bits in the string . We denote the -th bit of by . A codeword is said to be a prefix of a codeword if and for all . A binary code is a set of binary codewords. A binary code is called prefix-free if no codeword in is a prefix of another codeword in .

The Kraft’s Inequality [14] gives a necessary and sufficient condition for the existence of a prefix-free code for a given set of codeword lengths.

###### Theorem 10 (Kraft 1949 [14]).

For every prefix-free binary code ,

 n∑i=12−li≤1

where , and conversely, for any sequence of lengths satisfying the above inequality, there exists a prefix-free binary code , with .

###### Observation 11.

Given any sequence of lengths satisfying the Kraft Inequality, we can construct a prefix-free binary code , with in time . Further, we can ensure that every bit in is .

###### Proof.

A binary tree is a rooted tree in which every node has at most two child nodes. A node with only one child node is said to be unsaturated. The level of a node is its distance from the root. We assume that every edge from a parent to its first (second) child, if it exists, is labelled (). We can represent a prefix-free binary code by a binary tree such that (i) every codeword corresponds to a leaf of the binary tree at level and (ii) the labels on the unique path from the root to a leaf will be the codeword associated with that leaf [8]. We construct a prefix-free binary code with the given length sequence by constructing the corresponding binary tree as explained below.

Create the root, and for every new node created, create its first child till we hit a node at depth for the first time. Declare as a leaf. Once we have created a leaf , , we proceed to create the next leaf as follows. Backtrack from along the tree created so far towards the root till we hit the first unsaturated node. Create its second child. If the second child is at level , then declare it as the leaf . Else, recursively create first child till we create a node at level and declare it as leaf . Terminate this process once we create the leaf .

The process will continue till we create all the leaves. Otherwise, it has to be the case that every internal node in the tree got saturated by the time we created some leaf , . If we have a binary tree with every internal node saturated, it is easy to see by an inductive argument that , where is the set of leaves of and denotes the level of leaf . Hence , contradicting the hypothesis that the lengths satisfy the Kraft Inequality.

It follows from the construction that every bit of is . Since every edge in the tree constructed corresponds to a bit in at least one of the codewords returned, the total number of edges in the tree constructed is at most . Since each edge of the tree is traversed at most twice, the construction will be completed in time . ∎

Now we give a necessary and sufficient condition for -rainbow-colourability of a threshold graph.

###### Theorem 12.

For every connected threshold graph with , if and only if

 n∑i=k2−di≤1, (9)

where is the degree of vertex and . Further, if satisfies Inequality (9), then Algorithm 2 (ColourThresholdGraph-Case1) gives an optimal rainbow colouring of in time.

###### Proof.

Note that is a maximal independent set in (Observation 9b) and that the summation on the left hand side of Inequality (9) is over all the vertices in . Hence is a clique in .

First we show that if , then the inequality is satisfied. Let be a rainbow colouring of . We can associate a codeword with each vertex by reading the colours assigned by to edges . Since every pair are non-adjacent, they need a -length rainbow path between them through a common neighbour (Observation 9c). This ensures that the codewords corresponding to and are complementary in at least one bit position. Hence the binary code formed by codewords corresponding to all the vertices in form a prefix-free code. Hence the inequality is satisfied (by Theorem 10).

Conversely, if the inequality is satisfied, then Algorithm 2 gives a colouring of using at most colours. We show that is indeed a rainbow colouring of . Consider any two non-adjacent vertices . Since they are non-adjacent, either both of them are in or otherwise is in and is from the clique such that (Since ). In the former case, and there exists a such that since is not a prefix of (They both belong to a prefix-free code ). Hence is a rainbow path. Similarly in the latter case, and there exists a such that since is not a prefix of . Hence and