The complexity of deciding whether a graph admits an orientation with fixed weak diameter

An oriented graph −→ G is said weak (resp. strong) if, for every pair { u, v } of vertices of −→ G , there are directed paths joining u and v in either direction (resp. both directions). In case, for every pair of vertices, some of these directed paths have length at most k , we call −→ G k -weak (resp. k -strong). We consider several problems asking whether an undirected graph G admits orientations satisfying some connectivity and distance properties. As a main result, we show that deciding whether G admits a k -weak orientation is NP -complete for every k ≥ 2 . This notably implies the NP -completeness of several problems asking whether G is an extremal graph (in terms of needed colours) for some vertex-colouring problems.


Introduction
Let G be a simple undirected graph with vertex set V (G) and edge set E(G).By orienting every edge uv of G, either from u to v or from v to u, one obtains an orientation − → G of G.This oriented graph − → G has the same vertex set as G, i.e.V ( − → G ) = V (G), and, for every edge uv ∈ E(G), we have either depending on the orientation assigned to uv.The distance dist(G, u, v) from u to v in G is the minimal length of a path joining u and v.We refer to the maximum distance between two vertices of G as its diameter, and denote it diam(G).These definitions can be naturally adapted to the context of oriented graphs.
G is the minimal length of a dipath starting from u and ending at v. Note that, contrarily to the undirected case, we may have dist( − → G , u, v) = dist( − → G , v, u).Therefore, two definitions of the oriented diameter can be adopted.Let These two measures are called the weak distance and strong distance, respectively, from u to v in − → G .The weak diameter of − → G , denoted diam w ( − → G ), is the maximum weak distance from a vertex to another one.The strong diameter of − → G , denoted diam s ( − → G ), is the maximum strong distance from a vertex to another one.The weak diameter can intuitively be seen as an optimistic measure of the directed distances in an oriented graph (basically two vertices u and v are considered close when, say, u can reach v with few moves, and this no matter how many moves needs v to reach u (if possible)).We call − → G k-weak (resp.k-strong) if it has weak (resp.strong) diameter at most k.More generally, we say that − → G is weak (resp.strong) if it is k-weak (resp.k-strong) for some finite value of k.In turn, a weak (resp.strong) orientation of an undirected graph refers to an orientation being a weak (resp.strong) oriented graph.
Many appealing and attractive problems in graph theory are about deducing graph orientations with particular properties.Such problems find natural applications in real-world problems (e.g.traffic problems).In this paper, we mainly focus on the existence of (either weak or strong) orientations of some undirected graph G in which the diameter is preserved, i.e. as close to diam(G) as possible.Though the question of deciding whether G admits a weak or strong orientation can be answered easily by using several classic results of graph theory (see Sections 2.1 and 3), the hardness of deciding the same when a (weak or strong) diameter restriction is required was mostly unknown.Our main contribution is an indication of the complexity of answering this problem.In particular, we show that deciding whether G admits a k-weak orientation is NP-complete for every k ≥ 2, and suggest that the same should be true for k-strong orientations, completing a result of Chvátal and Thomassen.
Using two classic tools of graph theory, we prove, in Theorem 3 below, that WEAK ORIENTATION can be answered in linear time.Then, we prove that k-WEAK ORIENTATION is in P for k = 1, and NPcomplete otherwise, i.e. whenever k ≥ 2 (see Theorem 5).These two results confirm that imposing a (even constant) weak diameter condition is a strong restriction which makes the problem more difficult.

Complexity of WEAK ORIENTATION
We here show that WEAK ORIENTATION can be solved in linear time, and is hence in P. For this purpose, we need to recall the following two classic results.Recall that a bridge of a graph is an edge whose removal disconnects the graph.
Theorem 1 (Tarjan [11]).The bridges of a graph can be found in linear time.
Theorem 2 (Robbins [8]).A strong orientation of a bridgeless undirected graph can be computed in linear time.
We also need the notion of B-contraction.Given an undirected graph G, its B-contraction is the graph obtained as follows.Let first e 1 , e 2 , ..., e x denote the bridges of G, and B 1 , B 2 , ..., B y denote the (bridgeless) components of G − {e 1 , e 2 , ..., e x }.Then the B-contraction of G is obtained by associating a vertex v Bi with each component B i , and in which two vertices v Bi and v Bj are joined by an edge if and only if there is a bridge joining B i and B j in G. Clearly the B-contraction of any graph is a tree.
We are now ready to introduce the result of this section.Theorem 3.An undirected graph admits a weak orientation if and only if its B-contraction is a path.
Proof: We start by proving the sufficiency.Assume G is a connected undirected graph whose Bcontraction is a path with successive edges e 1 , e 2 , ..., e x , and denote B 1 , B 2 , ..., B y the components of G − {e 1 , e 2 , ..., e x }.We obtain a weak orientation − → G of G as follows.First orient the edges e 1 , e 2 , ..., e x towards the same direction, i.e. following the natural first-last ordering of the B-contraction.Then orient the edges of every B i to form a strong component.Such an orientation exists according to Theorem 2 since each B i has no bridge.Clearly − → G is weak since every two vertices within a same B i can reach each other and the orientation of the edges e 1 , e 2 , ..., e x form a dipath in the B-contraction.
We now prove the necessity by contradiction.Assume the B-contraction of G is not a path, but G admits a weak orientation − → G .Clearly the orientation of − → G , restricted to the B-contraction, should be weak.But this is impossible as the B-contraction of G has a node with degree at least 3, and every B-contraction is a tree.A contradiction.
Since the B-contraction of any graph can be computed in linear time (due to Theorem 1), we can answer in linear time to every instance of WEAK ORIENTATION.Actually, since the bridges of a graph and a strong orientation of every bridgeless undirected graph can be deduced in linear time (recall Theorems 1 and 2), the algorithm described in the sufficiency part of the proof of Theorem 3 can even be implemented to efficiently construct, i.e. in linear time, a weak orientation (if any) of every undirected graph.Corollary 4. WEAK ORIENTATION is in P.

Complexity of k-WEAK ORIENTATION
Clearly the answer to an instance of 1-WEAK ORIENTATION is yes if and only if G is complete.So 1-WEAK ORIENTATION is in P. The complexity of every remaining problem k-WEAK ORIENTATION (i.e. with k ≥ 2) was mentioned and asked in several references of literature (notably in [6,9,10]) due to its relationship with other problems of graph theory (see concluding Section 4).We herein settle the complexity of these problems by showing them to be NP-complete in general.
Theorem 5. k-WEAK ORIENTATION is NP-complete for every k ≥ 2.
Proof: For any fixed k, one can, given an orientation This can be done by essentially computing, for every pair of distinct vertices of G, the length of the shortest directed paths joining these two vertices in − → G .Many polynomial-time algorithms, such as e.g. the well-known Floyd-Warshall Algorithm (with unit weights), can be found in literature and applied to handle this.Consequently, k-WEAK ORIENTATION is in NP.
Let k ≥ 2 be fixed.We show that k-WEAK ORIENTATION is NP-hard by reduction from the following problem, which is shown to be NP-complete in [5].

2-VERTEX-COLOURING OF 3-UNIFORM HYPERGRAPHS
Instance: A 3-uniform hypergraph H. Question: Is H 2-colourable, i.e. can we colour each vertex of H either blue or red so that every hyperedge of H has at least one blue vertex and one red vertex?Throughout this proof, for any hypergraph H with order n and size m we denote its vertices by x 1 , x 2 , ..., x n and hyperedges by E 1 , E 2 , ..., E m .For every i ∈ {1, 2, ..., n}, we further denote by n i ≥ 1 the number of distinct hyperedges of H which contain the vertex x i .From a 3-uniform hypergraph H, we produce a graph G H such that H is 2-colourable if and only if G H admits a k-weak orientation −→ G H .This reduction is achieved in polynomial time compared to the size of H.
We first describe the crux G c H of G H , i.e. the subgraph of G H from which the equivalence with H will follow.The subgraph G c H does not have diameter k, but G H will be augmented later so that it has diameter k, and this without altering the equivalence.The crux G c H has the following vertices (see Figure 1).With each vertex x i of H, we associate n i + 2 vertices u i , u i , and v i,j1 , v i,j2 , ..., v i,jn i in G c H , where j 1 , j 2 , ..., j ni are the distinct indices of the hyperedges of H which contain x i .We now associate additional vertices in G c H with each hyperedge E j of H, where j ∈ {1, 2, ..., m}.This association depends on the parity of k: • If k is even, then add two vertices a j and a j to G c H . • Otherwise, if k is odd, then add two cycles a j b j c j a j and a j b j c j a j with length 3 to G c H .
We now link the vertices of G c H by means of several vertex-disjoint paths.By "joining a pair {u, v} of vertices by a path", we mean that we identify the endvertices of a new path with u and v, respectively.Since this operation is used at most once for joining any pair {u, v} of G c H , we use the notation uP v to denote the resulting path (if any).First, join every pair {u i , u i } by a path with length k 2 .Then also join every pair {u i , v i,j } by a path with length k 2 .Now consider each hyperedge E j = {x i1 , x i2 , x i3 } of H, and add the following paths to G c H : • If k is even, join every pair of {v i1,j , v i2,j , v i3,j } × {a j , a j } by means of a path with length k 2 .• Otherwise, if k is odd, then join every pair of {v i1,j } × {a j , a j }, {v i2,j } × {b j , b j }, and {v i3,j } × {c j , c j } by a path with length k 2 .
Note that, by construction, exactly one pair {v i,j , s(v i,j )} (resp.{v i,j , s (v i,j )}) was joined by a path with length k 2 , where s(v i,j ) (resp.s (v i,j )) is a vertex of the form a j , b j or c j (resp.a j , b j or c j ).The notation s(v i,j ) and s (v i,j ) are used throughout this section.In particular, observe that if k is even, then we have A pair {u, v} of distinct vertices of G c H is said representative whenever it matches one of the following forms: 1. {u i , v i,j } where i ∈ {1, 2, ..., n}, j ∈ {1, 2, ..., m}, and x i ∈ E j .

An orientation of G c
H is good if every two vertices forming a representative pair are linked by a k-dipath in either direction.Note that, in this definition, there is no requirement on the oriented distance between two vertices which are at distance at least k + 1.A representative pair is a pair of vertices which will not be adjacent in the final G H , and for which there will be at most two paths with length at most k joining it.All of these paths will belong to G c H so that the existence of a k-weak orientation of G H will depend on the existence of a good orientation of G c H .We prove below that we have an equivalence between finding a proper 2-vertex-colouring of H and a good orientation of G c H .The proof relies on the following claims.Claim 1. Suppose the vertex x i belongs to the hyperedges E j1 , E j2 , ..., E jn i of H.

Then, in any good orientation
) is a dipath for every j ∈ {j 1 , j 2 , ..., j ni }, or )P v i,j P u i P u i is a dipath for every j ∈ {j 1 , j 2 , ..., j ni }.
Proof: Note that because u i P u i P v i,j1 is the only path with length at most k joining u i and must also be a dipath for every j ∈ {j 1 , j 2 , ..., j ni } since u i P u i P v i,j is the only path with length at most k joining u i and v i,j in G c H . Similarly, since, for every j ∈ {j 1 , j 2 , ..., j ni }, the only path with length at most k joining u i and H is u i P v i,j P s(v i,j ), and belongs to the orientation.The claim follows analogously from the assumption that Claim 2. Suppose k is even, and )P v i,j is a dipath for every i ∈ {i 1 , i 2 , i 3 }.Furthermore, these three dipaths cannot be all directed from or towards the s(v i,j )'s.
Proof: Recall that s(v i1,j ) = s(v i2,j ) = s(v i3,j ) = a j and s (v i1,j ) = s (v i2,j ) = s (v i3,j ) = a j when k is even.Note further that there are only two paths with length at most k joining any two of v i1,j , v i2,j , and v i3,j .These include a j and a j , respectively.If the statement of the claim is not fulfilled, then there is H joining any two of v i1,j , v i2,j , and v i3,j including a j .So there must be three k-dipaths joining these vertices including a j , but this is impossible.Claim 3. Suppose k is odd, and Besides these three dipaths cannot be all directed from or towards the s(v i,j )'s.
Proof: Similarly as for previous Claim 2, if the statement of the claim is not fulfilled by −→ G c H , then there is no dipath with length at most k joining any two of v i1,j , v i2,j , and v i3,j including the s(v i,j )'s.Then there cannot be three k-dipaths, including the s (v i,j )'s, joining every pair of these vertices, and this no matter how the paths v i1,j s (v i1,j ), v i2,j s (v i2,j ) and v i3,j s (v i3,j ) are oriented, and how the edges of the cycles a j b j c j a j and a j b j c j a j are oriented.
Regarding previous Claims 2 and 3, remark that if two of the dipaths obtained by orienting the paths v i1,j P s(v i1,j ), v i2,j P s(v i2,j ) and v i3,j P s(v i3,j ) have the same direction, i.e. from or towards the s(v i,j )'s, while the third one is oriented in the opposite direction, then we can obtain three k-dipaths joining any two of v i1,j , v i2,j , and v i3,j .Suppose e.g. that So far, note that there are two k-dipaths starting from v i1,j and v i2,j , respectively, and ending at v i3,j (when k is odd, these are obtained by adding . The last k-dipath starting from v i1,j and ending at v i2,j can be obtained According to Claims 1, 2 and 3, we have an equivalence between finding a proper 2-vertex-colouring of H and a good orientation of G c H . Indeed, assume that having the dipath H simulates that vertex x i of H is coloured blue (resp.red), and that having the dipath ) simulates the fact that the vertex x i is counted as a blue (resp.red) vertex in E j .Claim 1 reflects the fact that if x i is coloured, say, blue by a proper 2-vertex-colouring of H, then x i counts as a blue vertex in every hyperedge which contains it.Claims 2 and 3 depict the fact that all vertices from a single hyperedge of H cannot have the same colour.Thus, by the discussion following the proof of Claim 3, it can be concluded that from a proper 2-vertex-colouring of H we can deduce a good orientation of G c H , and vice-versa.
We now augment G H with additional vertices so that there is a path with length at most k joining every two non-adjacent vertices of G c H that do not form a representative pair.This is done in such a way that there is an orientation of the edges of E(G H ) − E(G c H ) so that every two vertices of G H that do not form a representative pair are joined by a dipath with length at most k.In this way, the existence of a k-weak orientation of G H will only rely on the existence of a good orientation of G c H .The augmentation consists in associating a gadget G v with each vertex v of G c H , and then connecting all the resulting gadgets in such a way there is a path with length at most k between any two vertices from different gadgets G u and G v .In the case where {u, v} is not a representative pair, we add a shortcut between G u and G v , i.e. an alternative shorter path for joining two vertices of G u and G v .This is done in such a way that every vertex u of G u is at distance at most k from any vertex v of G v , unless u = u, v = v and {u, v} is a representative pair.However, in the situation where {u, v} is not representative, there is a path with length k joining u and v that uses the shortcut between G u and G v .
Set x = k 2 .For every i ∈ {1, 2, ..., x}, add two new vertices s i v and p i v to G v .These two vertices form the i th level of G v , and are said to be i-vertices.Next, for every i ∈ {1, 2, ..., x − 1}, add all possible edges between the iand (i + 1)-vertices of G v so that two consecutive levels of G v form a clique on 4 vertices.Finally, add an edge between v and every 1-vertex of G v .
We finish the construction of G H by adding some connection between the gadgets.We distinguish two cases depending on the parity of k: • If k is even, then turn the subgraph induced by all x-vertices of G H into a clique.Next, for every pair {u, v} of vertices of G c H which is not representative, add a shortcut vertex e u,v to the clique constructed just before.Finally, add every edge between e u,v and the vertices from the (x − 1) th levels of G u and G v if k ≥ 4, or the edges ue u,v and e u,v v when k = 2.
• Otherwise, if k is odd, then add a new vertex z to G H , and add all possible edges between z and x-vertices.For every pair {u, v} of G c H that is not representative, also add the shortcut edges This construction is illustrated in Figure 2 for k = 6 and k = 7.Note that no new path with length at most k joining two vertices composing a representative pair of G H arose from the modifications.Therefore, the equivalence between finding a proper 2-vertex-colouring of H and a good orientation of G c H is preserved.The last thing to do, is showing that there is an orientation of the edges we have just added so that every pair of vertices of G H which is not representative is joined by a k-dipath in either direction.

Define an arbitrary ordering
) over all vertices of G c H , and consider the following partial orientation of G H (see Figure 2).First, for every vertex v of G c H , let to the partial orientation.The partial orientation is completed depending on the parity of k: Note that, under the partial orientation given above, any vertex u from a gadget G u can directly "access" the upper or lower level of G u .Besides, there is a dipath with length at most k joining u and any vertex v from another gadget G v , unless u = u, v = v, and {u, v} is a representative pair.Such a path typically goes up across G u , then exits G u to enter G v (either directly from the x th levels or via z), and finally goes down across G v .Because the gadgets have x = k 2 levels, the length of such a path does not exceed k.Finally observe that if {u, v} is representative, then there is no path with length at most k joining u and v going across the gadgets.On the contrary, if {u, v} is not a representative pair, then there is a path with length exactly k joining u and v.This path necessarily includes the shortcut between G u and G v , i.e. the vertex e u,v if k is even or an edge linking the x th levels of G u and G v otherwise.
Hence Using Theorems 1 and 2, we can answer to every instance G of STRONG ORIENTATION in linear time via the following algorithm.Clearly, if G has bridges, then it admits no strong orientation.Otherwise, a strong orientation can be obtained according to Theorem 2. All these steps can be achieved in linear time, so the whole algorithm indeed runs in linear time.Theorem 6. STRONG ORIENTATION is in P.
Clearly, no instance of 1-STRONG ORIENTATION is positive since we consider oriented graphs only (no symmetric arc is allowed).So 1-STRONG ORIENTATION is trivially in P. Besides, it was proved by Chvátal and Thomassen that 2-STRONG ORIENTATION is NP-complete in general (see [1]).For the other values of k ≥ 3, we strongly believe that the NP-completeness of the remaining problems could be proved by slightly modifying the reduction scheme given in the proof of Theorem 5. Namely, consider e.g. the following modifications.First, the crux graph G c H would be obtained in the same way.Then, when constructing the big clique subgraph (which would be intended to have the same purpose, namely to have a lot of pairs of vertices being joined by a lot of paths with length at most k), one would have to make sure that the following additional paths exist: • at least two new paths with length k joining the vertices from every non-representative pair; • one new path with length k joining the vertices from every representative pair.
Then note that if these modifications are performed, then, in order to get a strong orientation of G H , for every representative pair {u, v}, we would need to have the path of length k joining u and v in G c H being oriented, say, from u to v, and the additional path (of the clique subgraph) oriented from v to u.The hard part would be to make sure that the clique subgraph can be always oriented correctly (as in the second part of the proof of Theorem 5), but this should be doable due to its large number of paths with length at most k (basically the clique subgraph could be less dense in the original construction, but its large size facilitates the proof process).

Discussion
In this paper, we have considered the complexity of orienting an undirected graph in such a way that the distances between its vertices are preserved.As a main result, we have proved the same result as Chvátal and Thomassen for weak orientations, hence proving that the weak and strong versions of all these problems are theoretically as hard as each other in essence.
It is worth mentioning that Theorem 5 has consequences on some special vertex-colouring problems.These consequences are related to the following context.Usually, a proper vertex-colouring of an undirected graph G is an assignment of colours to its vertices such that no two adjacent vertices receive the same colour.It is well-known that extremal graphs for the notion of proper vertex-colouring (i.e. the graphs which need the most colours to be coloured, relatively to their order) are complete graphs.But for augmented kinds of graphs and vertex-colourings, the notion of extremal graph is not as obvious.It turns out that the NP-completeness of every problem k-WEAK ORIENTATION (in particular for k = 2) implies that, in some contexts, an easy characterization of these extremal graphs in terms of underlying undirected graph cannot exist (unless P=NP).− → G is 2-weak, see e.g.[3,4].From the undirected graphs point of view, the case k = 2 of Theorem 5 hence implies the following.

Oriented vertex-colouring of oriented graphs
Corollary 7. It is NP-complete to decide whether an undirected graph G is the underlying graph of an oriented clique.

Proper vertex-colouring of 2-edge-coloured graphs
A 2-edge-coloured graph G = (V, E r , E b ) (sometimes also called a signified graph) is basically an undirected graph whose each edge is either red (i.e. in E r ) or blue (i.e. in E b ), refer e.g. to [7,9] for more details.A proper vertex-colouring of G is then a vertex-colouring c such that: • for every two adjacent vertices u and v, we have c(u) = c(v), • for every red edge xy and blue edge uv, if c(x) = c(u) then c(y) = c(v).
Similarly as in the previous section, in case G cannot be properly vertex-coloured with strictly less than |V (G)| colours, we call G a 2-edge-coloured clique.According to the definition, G is a 2-edge-coloured clique if and only if every two of its vertices are either adjacent, or joined by a path of length 2 whose one edge is red and the other one is blue (see notably [9] for more details).Actually the reduction given in the proof of Theorem 5 can be modified to prove the following, which is equivalent to a result that appeared in [2].
Corollary 8.It is NP-complete to decide whether an undirected graph G is the underlying graph of a 2-edge-coloured clique.
The modifications are mainly the following.Instead of orienting the edges of G c H (and G H ), we now basically want to colour each of them either red or blue.The reduced crux graph G c H remains the same.A colouring of the edges of G c H is good if, for every representative pair {u, v} of vertices, the unique path with length 2 joining u to v has one red edge and one blue edge.Then it can be easily checked that the cornerstone property of overlapping unique short paths remains applicable in this context.Namely, in a good 2-edge-colouring, colouring the edges of a unique path with length 2 in the crux "forces" the colouring of other unique paths overlapping it.The rest of the reduction, i.e. the construction of G H from G c H , is similar.

Figure 2 :
Figure 2: The gadgets Gu and Gv obtained for a pair {u, v} which is not representative.
oriented graph.An oriented vertex-colouring of − → G is a vertex-colouring c satisfying the following two properties: • for every two adjacent vertices u and v, we have c(u) = c(v), • for every two arcs − → xy and − → uv, if c(x) = c(v) then c(y) = c(u).We call − → G an oriented clique if it does not admit an oriented vertex-colouring using strictly less than|V ( − → G )| colours.It is known that − →G is an oriented clique if and only if every two vertices of − → G are at weak distance at most 2, i.e.
, G H admits a k-weak orientation if and only if G c H admits a good orientation.Besides, G c H admits a good orientation if and only if H is 2-colourable.By transitivity, we get that G H admits a k-weak orientation if and only if H is 2-colourable, and thus that k-WEAK ORIENTATION is NP-complete.