Oriented Coloring on Recursively Defined Digraphs

Coloring is one of the most famous problems in graph theory. The coloring problem on undirected graphs has been well studied, whereas there are very few results for coloring problems on directed graphs. An oriented k-coloring of an oriented graph G = ( V , A ) is a partition of the vertex set V into k independent sets such that all the arcs linking two of these subsets have the same direction. The oriented chromatic number of an oriented graph G is the smallest k such that G allows an oriented k-coloring. Deciding whether an acyclic digraph allows an oriented 4-coloring is NP-hard. It follows that finding the chromatic number of an oriented graph is an NP-hard problem, too. This motivates to consider the problem on oriented co-graphs. After giving several characterizations for this graph class, we show a linear time algorithm which computes an optimal oriented coloring for an oriented co-graph. We further prove how the oriented chromatic number can be computed for the disjoint union and order composition from the oriented chromatic number of the involved oriented co-graphs. It turns out that within oriented co-graphs the oriented chromatic number is equal to the length of a longest oriented path plus one. We also show that the graph isomorphism problem on oriented co-graphs can be solved in linear time.


Introduction
Graph coloring is one of the basic problems in graph theory, which has already been considered in the 19th century. A k-coloring for an undirected graph G is a k-labelling of the vertices of G such that no two adjacent vertices have the same label. The smallest k such that a graph G has a k-coloring is named the chromatic number of G. As even the problem, if a graph has a 3-coloring or not, is NP-complete, finding the chromatic number of an undirected graph is an NP-hard problem. But there are many efficient solutions for the coloring problem on special graph classes, like chordal graphs [15], comparability graphs [23], and co-graphs [6].
Oriented coloring has been introduced much later by Courcelle [7]. One could easily apply the definition of graph coloring to directed graphs, but as this would not take the direction of the arcs into account, this is not very interesting. For such a definition, the coloring of a directed graph would be the coloring of the underlying undirected graph.
Oriented coloring considers also the direction of the arcs. An oriented k-coloring of an oriented graph G = (V, A) is a partition of the vertex set V into k independent sets such that all the arcs linking two of these subsets have the same direction. In the oriented chromatic number problem (OCN for short) it is given some oriented graph G and some integer c and it is to decide whether there is an oriented c-coloring for G. Even the restricted problem if c is constant and does not belong to the input (OCN c for short) is hard. OCN 4 is NP-complete even for DAGs [10], whereas the undirected problem is easy for trees.
Right now, the definition of oriented colorings is mostly considered for undirected graphs. There the maximum value χ o (G ′ ) of all possible orientations G ′ of an undirected graph G is considered. For several special undirected graph classes the oriented chromatic number has been bounded. Among these are outerplanar graphs [28], planar graphs [26], and Halin graphs [11].
Ganian has shown in [14] an FPT-algorithm for OCN w.r.t. the parameter tree-width (of the underlying undirected graph). Further he has shown that OCN is DET-hard for classes of oriented graphs such that the underlying undirected class has bounded rank-width. Oriented colorings of special digraph classes seem to be uninvestigated up to now. The main reason is that the oriented chromatic number of the disjoint union of two oriented graphs can be larger than the maximum oriented chromatic number of the involved graphs (cf. Figure 1 and Example 4.7). In this paper we consider oriented coloring problem restricted to oriented cographs, which are obtained from directed co-graphs [4] by omitting the series operation. Oriented co-graphs were already analyzed by Lawler in [25] and [6, Section 5] using the notation of transitive series parallel (TSP) digraphs. We give several characterizations for oriented co-graphs and show that for oriented co-graphs, the oriented chromatic number of the disjoint union of oriented graphs is equal to the maximum oriented chromatic number of the involved graphs. Further, we show that for every oriented graph the oriented chromatic number of the order composition of oriented graphs is equal to the sum of the oriented chromatic number of the involved graphs. To show this we introduce an algorithm that computes an optimal oriented coloring and thus the oriented chromatic number of oriented co-graphs in linear time. We also consider the longest oriented path problem on oriented co-graphs. It turns out that within oriented co-graphs the oriented chromatic number is equal to the length of a longest oriented path plus one. Further, we give a linear time algorithm for the graph isomorphism problem on oriented co-graphs. Our results provide a useful basis for exploring the complexity of OCN related to width parameters.

Graphs and Digraphs
We use the notations of Bang-Jensen and Gutin [2] for graphs and digraphs.
For some given digraph G = (V, A), we define its underlying undirected graph by ignoring the directions of the edges, i.e. und(G) = (V, {{u, v} | (u, v) ∈ A, u, v ∈ V }) and for some class of digraphs X, let und(X) = {und(G) | G ∈ X}. For some (di)graph class F we define Free(F ) as the set of all (di)graphs G such that no induced sub(di)graph of G is isomorphic to a member of F .
An oriented graph is a digraph with no loops and no opposite arcs. We recall some special oriented graphs. By n ≥ 2, we denote the oriented path on n vertices, by n ≥ 3, we denote the oriented cycle on n vertices and by − → T n we denote the transitive tournament on n vertices.

Undirected Co-Graphs
• The disjoint union of G 1 , . . . , G k , denoted by G 1 ∪ . . . ∪ G k , is the graph with vertex set • The join composition of G 1 , . . . , G k , denoted by G 1 × . . . × G k , is defined by their disjoint union plus all possible edges between vertices of G i and G j for all 1 ≤ i, j ≤ k, i = j.
The set of all graphs which can be defined by the disjoint union and join composition is characterized as the set of all co-graphs. It is well known that co-graphs are precisely the P 4 -free graphs [6].

Undirected Graph Coloring
The chromatic number of G, denoted by χ(G), is the smallest k such that G has a k-coloring.
On undirected co-graphs, the graph coloring problem is easy to solve by the following result proved by Corneil et al.: 3 Let G be a co-graph, then χ(G) can be computed in linear time.
The undirected coloring problem, i.e. computing χ(G), can be solved by an FPT-algorithm w.r.t. the tree-width of the input graph [17]. In contrast, this is not true for clique-width, since in [13] it has been shown that the undirected coloring problem is W[1]-hard w.r.t. the clique-width of the input graph. That is, under reasonable assumptions an XP-algorithm is the best one can hope for and such algorithms are known [12].

Directed Co-Graphs
The following operations for digraphs have already been considered by Bechet et al. in [4]. Let • The disjoint union of G 1 , . . . , G k , denoted by G 1 ⊕ . . . ⊕ G k , is the digraph with vertex set V 1 ∪ . . . ∪ V k and arc set E 1 ∪ . . . ∪ E k .
• The series composition of G 1 , . . . , G k , denoted by G 1 ⊗ . . . ⊗ G k , is defined by their disjoint union plus all possible arcs between vertices of G i and G j for all 1 ≤ i, j ≤ k, i = j.
• The order composition of G 1 , . . . , G k , denoted by G 1 ⊘ . . . ⊘ G k , is defined by their disjoint union plus all possible arcs from vertices of G i to vertices of G j for all 1 ≤ i < j ≤ k.
The set of all digraphs which can be defined by the disjoint union, series composition, and order composition is characterized as the set of all directed co-graphs [4]. Obviously for every directed co-graph we can define a tree structure, denoted as the di-co-tree. The leaves of the di-co-tree represent the vertices of the graph and the inner nodes of the di-co-tree correspond to the operations applied on the subexpressions defined by the subtrees. For every directed co-graph one can construct a di-co-tree in linear time, see [9].
In [3] it is shown that the weak k-linkage problem can be solved in polynomial time for directed co-graphs. By the recursive structure there exist dynamic programming algorithms to compute the size of a largest edgeless subdigraph, the size of a largest subdigraph which is a tournament, the size of a largest semicomplete subdigraph, and the size of a largest complete subdigraph for every directed co-graph in linear time. Also the Hamiltonian path, Hamiltonian cycle, regular subdigraph, and directed cut problem are polynomial on directed co-graphs [18]. Calculs of directed co-graphs were also considered in connection with pomset logic in [27]. Further the directed path-width and also the directed tree-width can be computed in linear time for directed co-graphs [20,19].
In [9] it has been shown that directed co-graphs can be characterized by the eight forbidden induced subdigraphs shown in Figure 2. Figure 2: The eight forbidden induced subdigraphs for directed co-graphs.

Oriented Co-Graphs
Oriented colorings are defined on oriented graphs, which are digraphs with no bidirected edges. Therefor we introduce oriented co-graphs by restricting directed co-graphs from [4] by omitting the series operation.

Definition 3.1 (Oriented Co-Graphs)
The class of oriented co-graphs is recursively defined as follows.
The class of oriented co-graphs was already analyzed by Lawler in [25] and [6, Section 5] using the notation of transitive series parallel (TSP) digraphs. A digraph G = (V, A) is called transitive if for every pair (u, v) ∈ A and (v, w) ∈ A of arcs with u = w the arc (u, w) also belongs to A.

Theorem 3.2 ([6]) A graph G is a co-graph if and only if there exists an orientation
A di-co-tree T is canonical if on every path from the root to the leaves of T , the labels disjoint union and order operation strictly alternate. Since the disjoint union ⊕ and the order composition ⊘ are associative we always can restrict to canonical di-co-trees.

Lemma 3.3 Let G be an oriented co-graph and T be a di-co-tree for G. Then T can be transformed in linear time into a canonical di-co-tree for G.
The recursive definitions of oriented and undirected co-graphs lead to the following observation.

Observation 3.4 For every oriented co-graph G the underlying undirected graph und (G) is a co-graph.
The reverse direction of this observation only holds under certain conditions, see Theorem 3.6. By we denote the complete biorientation of a path on n = 2 vertices.
, we know that u and w are connected either only by (u, w) ∈ A or by (u, w) ∈ A and (w, u) ∈ A, which implies that G is transitive.
Oriented co-graphs can be characterized by forbidden subdigraphs as follows.
Theorem 3.6 Let G be a digraph. The following properties are equivalent: Proof (1) ⇒ (2) If G is an oriented co-graph, then G is a directed co-graph and by [9] it holds there is no series operation in any construction of G which implies that G is an oriented co-graph. (3) ⇔ (4) Since co-graphs are precisely the P 4 -free graphs [6]. (2) ⇒ (7) By Lemma 3.5. (5) and (1)  Among others are two subclasses of oriented co-graphs, which will be of interest within our results. By restricting within Definition 3.1 (2) to k = 2 and graph G 1 or G 2 to an edgeless graph or to a single vertex, we obtain the class of all oriented simple co-graphs or oriented threshold graphs, respectively. The class of oriented threshold graphs has been introduced by Boeckner in [5].

Oriented Graph Coloring Problem
Oriented graph coloring has been introduced by Courcelle [7] in 1994. Most results on this problem are for orientations of undirected graphs. Now we consider oriented graph coloring on recursively defined oriented graph classes.
The oriented chromatic number of G, denoted by χ o (G), is the smallest k such that G has an oriented k-coloring. The vertex sets The oriented graphs G 1 and G 2 are homomorphically equivalent, if there is a homomorphism from G 1 to G 2 and there is one homomorphism from G 2 to G 1 . A homomorphism from G 1 to G 2 can be regarded as an oriented coloring of G 1 that uses the vertices of G 2 as colors classes. This leads to equivalent definitions of oriented colorings and oriented chromatic numbers. There is an oriented k-coloring of an oriented graph G 1 if and only if there is a homomorphism from G 1 to some oriented graph G 2 on k vertices. That is, the oriented chromatic number of G is the minimum number of vertices in an oriented graph G 2 such that there is a homomorphism from G 1 to G 2 . Obviously, G 2 can be chosen as a tournament.

Observation 4.2
There is an oriented k-coloring of an oriented graph G 1 if and only if there is a homomorphism from G 1 to some tournament G 2 on k vertices. Further the oriented chromatic number of G is the minimum number of vertices in a tournament G 2 such that there is a homomorphism from G 1 to G 2 .   If c is constant and is not part of the input, the corresponding problem is denoted by OCN c . OCN 4 is NP-complete even for DAGs [10].
The definition of oriented colorings is also used for undirected graphs G. There the maximum value χ o (G ′ ) of all possible orientations G ′ of G is considered. In this sense, every tree has oriented chromatic number at most 3. For several further graph classes there are bounds on the oriented number. Among these are outerplanar graphs [28], planar graphs [26], and Halin graphs [11].

Oriented Graph Coloring for Oriented Graphs
Oriented graph coloring has not yet been considered for recursively defined graphs, though it has been analyzed for some graph operations. In this section we show some results of oriented graph coloring on some graph operations and conclude algorithms for some recursively defined oriented graph classes. This will also be useful for the following section.
First we give some results on the oriented graph coloring for general recursively defined oriented graphs. These results will be very useful to prove our results for oriented co-graphs in the next section.
Since no new arcs are inserted G 1 can keep its colors. The added isolated vertex gets a color of G 1 in order to get a valid coloring for G 1 ⊕ •.
Since G 1 is an induced subdigraph of G 1 ⊕ • this relation holds by Lemma 4.3.
Since the digraphs G 1 , . . . , G k are induced subdigraphs of digraph G 1 ⊕ . . . ⊕ G k , all values χ o (G 1 ), . . . , χ o (G k ) lead to a lower bound on the number of necessary colors for the combined graph by Lemma 4.3.
This mapping c satisfies the definition of an oriented coloring as follows. No two adjacent vertices from G i , 1 ≤ i ≤ k have the same color by assumption and by our definition of mapping c. A vertex of G i and a vertex of G j for 1 ≤ i = j ≤ k are always adjacent but are never colored equally by our definition of mapping c.
Further the arcs between two color classes of every G i , 1 ≤ i ≤ k have the same direction by our definition of mapping c. The arcs between a color class of G i and a color class of G j for 1 ≤ i = j ≤ k have the same direction by the definition of the order operation. This shows the statements of the lemma. By Lemma 4.5 we can solve oriented coloring for oriented simple co-graphs and thus also for subclasses such as oriented threshold graphs and transitive tournaments in linear time.

Proposition 4.6 Let G be an oriented simple co-graph, then χ o (G) = χ(und (G)) = ω(und(G)) and all values can be computed in linear time.
It is not easy to generalize these results to oriented co-graphs. To do so, we would need to compute the oriented chromatic number of the disjoint union of two oriented co-graphs with at least two vertices. But it is not possible to compute this oriented chromatic number of the disjoint union of general oriented graphs from the oriented chromatic numbers of the involved graphs. In Lemma 4.5 (2) we only show a lower bound. The following example proves that in general this can not be strengthened to equality.
Example 4.7 The two graphs − → C 3 and − → T 3 in Figure 1 have the same oriented chromatic number

but their disjoint union needs more colors.
On the other hand, there are several examples for which the disjoint union does not need more than max(χ o (G 1 ), χ o (G 2 )) colors, such as for the union of two isomorphic oriented graphs. By Theorem 3.6, we know that − → T 3 shown in Figure 1 is an oriented co-graph but − → C 3 shown in Figure  1 is not an oriented co-graph. So the question arises whether oriented coloring could be closed under disjoint union if restricted to oriented co-graphs.

Oriented Graph Coloring for Oriented Co-Graphs
In order to solve OCN restricted to oriented co-graphs G we created an algorithm, which is shown in Figure 3. The method traverses a canonical di-co-tree T for G using a depth-first search such that for very inner vertex the children are visited from left to right. For every inner vertex u of T we store two values in[u] and out [u]. These values ensure that the vertices of G corresponding to the leaves of the subtree rooted at u will we labeled by labels ℓ such that in[u] ≤ ℓ ≤ out [u]. For every leaf vertex u of T we additionally store the label of the corresponding vertex of G in color [u]. These values lead to an optimal oriented coloring of G by the next theorem.   Proof Let G = (V, A) be an oriented co-graph. Using the method of [9] we can build a di-co-tree T with root r for G in linear time. Further we can assume that T is a canonical di-co-tree by Lemma 3.3. For some node u of T we define by T u the subtree of T rooted at u and by G u the subgraph of G which is defined by T u . Obviously, for every vertex u of T the tree T u is a di-co-tree for the digraph G u which is also an oriented co-graph.
Next we verify that algorithm Label(G, r, 1), shown in Figure  We distinguish the following three cases depending on the type of operation corresponding to the vertices u of T . • If u is an inner vertex of T which corresponds to an order operation and u 1 , . . . , u ℓ are the children of u in T .
We already know that the oriented colorings of G ui , 1 ≤ i ≤ ℓ, are feasible. Further by our algorithm a vertex from G ui and a vertex from G uj for 1 ≤ i = j ≤ ℓ are never colored equally in G u . The arcs between a color class of G ui and a color class of G uj for 1 ≤ i = j ≤ ℓ have the same direction by the definition of the order operation.

By the algorithm, value out[u] − in[u] + 1 is equal to
• If u is an inner vertex of T which corresponds to a disjoint union operation and u 1 , . . . , u ℓ are the children of u in T .
We already know that the oriented colorings of G ui , 1 ≤ i ≤ ℓ, are feasible. Since a disjoint union operation does not create any arcs, no two adjacent vertices have the same color in G u . Further, our method ensures that for every arc (u, v) in G it holds that color[u] < color [v]. Thus all arcs between two color classes in G u have the same direction.
By the algorithm value out[u] − in[u] + 1 is equal to max(χ o (G 1 ), . . . , χ o (G ℓ )). By Lemma 4.5 we conclude that out holds by the feasibility of our oriented coloring.
By applying the invariant for u = r, the statements of the theorem follow.

Example 4.9
We illustrate the method given in Figure 3 by computing an oriented coloring for the oriented co-graph G which is given by the canonical di-co-tree T of Figure 4. On the left of each vertex u of T , the values in[u] and out[u] are given. An optimal oriented coloring for G is given in blue letters below the leaves of T . The root r of T leads to χ o (G) = out[r] = 5.  Figure 4: Canonical di-co-tree T for oriented co-graph G.
Next we can improve the result of Lemma 4.5(2) for oriented co-graphs.
Corollary 4.10 Let G 1 , . . . , G k be k vertex-disjoint oriented co-graphs. Then it holds Proof Let G = G 1 ⊕. . .⊕G k be an oriented co-graph and T be a di-co-tree with root r for G. The method given in Figure 3 computes an oriented coloring using Further the proof of Theorem 4.8 shows that χ o (G 1 ⊕ . . . ⊕ G k ) = max(χ o (G 1 ), . . . , χ o (G k )).

Corollary 4.11
Let G be an oriented co-graph. The following properties are equivalent: 1. G is an oriented clique.
2. G has a di-co-tree, which does not use any disjoint union operation.

G is a transitive tournament.
Further characterizations for transitive tournaments and thus for oriented co-graphs which are oriented cliques can be found in [16,Chapter 9].
As mentioned in Observation 4.2, oriented colorings of an oriented graph G can be characterized by the existence of homomorphisms to tournaments. These tournaments are not necessarily transitive and G is not necessarily homomorphically equivalent to some tournament. For oriented co-graphs we can show a deeper result.

Corollary 4.12
There is an oriented k-coloring of an oriented co-graph G if and only if there is a homomorphism from G to some transitive tournament − → T k on k vertices. Further the oriented chromatic number of an oriented co-graph G is the minimum number k such that G is homomorphically equivalent with the transitive tournament − → T k .
Proof Within an oriented co-graph G = (V, A) the color classes V 1 , . . . , V k of an oriented kcoloring define a transitive tournament , then there is a homomorphism from − → T k to G.

Longest Oriented Path for Oriented Graphs
Name: Oriented Path (OP) Instance: An oriented graph G = (V, A) and a positive integer k ≤ |V |. Question: Is there an oriented path of length at least k in G?
We can bound the path length using the oriented chromatic number when considering oriented co-graphs. Please note that in the subsequent results oriented path − −− → P k+1 does not necessarily mean induced path (though, its definition implies no chord on the path). In order to compute for some oriented graph G the length of a longest oriented path ℓ(G), we give the next result. Proof The statement can be shown recursively on the structure of an oriented co-graph G.
This shows the statements of the lemma. This implies that for every oriented co-graph the upper bound of Corollary 5.2 is tight.
Proof The first equality holds by Proposition 5.5 and remaining equalities follow by Lemma 2.2.

Graph Isomorphism for Oriented Co-Graphs
The isomorphism problem for undirected co-graphs has been shown to be solvable in polynomial time in [6]. This result can even be improved as follows. Two undirected co-graphs G 1 and G 1 are isomorphic if and only if their canonical co-trees T 1 and T 2 are isomorphic. A canonical co-tree for some co-graph can be found in linear time. Thus by applying a linear time isomorphism test for rooted labeled trees (cf. [1, Section 3.2]) on canonical co-trees for G 1 and G 2 one can decide in linear time, whether G 1 and G 2 are isomorphic.
We consider the corresponding problem for oriented co-graphs.
Name: Oriented Co-Graph Isomorphism (OCI) Instance: Two oriented co-graphs G 1 = (V 1 , A 1 ) and G 2 = (V 2 , A 2 ). Question: Are G 1 and G 2 isomorphic, i.e. is there a bijection b : For oriented co-graphs, the method using an isomorphism test for rooted labeled trees on the co-trees does not work, since the order of the vertices, which are representing order operations in the di-co-tree, must be preserved. Our solution, given in Figure 5, is obtained by a modification of the method given in [1, Section 3.2]. W.l.o.g. we can assume that the height and the operation of the root of di-co-trees T 1 and T 2 are equal. if (S ′ 1 = S ′ 2 ) return f alse let V ℓ be the set of all vectors on level ℓ in T 1 find a bijection b : Figure 5: Testing graph isomorphism for two oriented co-graphs given by canonical di-co-trees. Theorem 6.1 Let G 1 and G 2 be two oriented co-graphs, then oriented co-graph isomorphism for G 1 and G 2 can be solved in linear time.

Conclusions and Outlook
In this paper we have considered vertex coloring on oriented graphs. We were able to introduce linear time solutions for the oriented coloring problem, longest oriented path problem and isomorphism problem on oriented co-graphs. Our solutions are based on computations along a canonical di-co-tree for the given input co-graphs. Furthermore, it turns out that within oriented co-graphs, the oriented chromatic number is equal to the length of a longest oriented path plus one, which is a quite interesting result, as within undirected co-graphs even for bipartite graphs the path length can not be bounded by the chromatic number.
Further on oriented co-graphs an independent set of largest size can be computed in the same way as known for undirected co-graphs [6], as well as a tournament subdigraph of largest size and also a partition of the vertex set into a minimum number of tournaments can be computed by applying the method for independent set or oriented coloring problem on the reverse input graph.
It remains to consider the existence of an FPT-algorithm for OCN w.r.t. the parameter directed tree-width given in [24]. Since the directed tree-width of a digraph is always less or equal the undirected tree-width of the corresponding underlying undirected graph [24] the FPT-algorithm of Ganian [14] (see also Section 1) does not imply such a result.
In [14] Ganian has also shown that OCN is DET-hard for classes of oriented graphs such that the underlying undirected class has bounded rank-width. He used a reduction from isomorphism problem for tournaments, which has been shown to be DET-hard in [29]. The same reduction also works for several linear width parameters, since these can define the disjoint union of two arbitrarily large cliques. Thus OCN is DET-hard for classes of oriented graphs such that the underlying undirected class has linear NLC-width at most 2, linear clique-width at most 3, neighbourhood-width at most 2, or linear rank-width 1. Further OCN is DET-hard for classes of oriented graphs such that the underlying undirected class has NLC-width 1 or equivalently clique-width 2. The complexity of OCN on oriented graphs such that the underlying undirected class has linear NLC-width at most 1 (equivalently neighbourhood-width 1) or linear clique-width at most 2 remains open, since these classes do not contain the disjoint union of two arbitrarily large cliques.
It also remains to generalize the shown results for oriented coloring on oriented graphs of bounded directed clique-width given in [8,21]. By the existence of a monadic second order logic formula it follows that for every c the problem OCN c is fixed parameter tractable w.r.t. the parameter directed clique-width.
For the more general problem OCN the existence of XP-algorithm or even FPT-algorithm w.r.t. the directed clique-width of the input graph is still open. Since the directed clique-width of a digraph is always greater or equal the undirected clique-width of the corresponding underlying undirected graph [21], the result of Ganian [14] (see also Section 1) does not imply a hardness result.