One-Way Trail Orientations

08/24/2017 ∙ by Anders Aamand, et al. ∙ 0

Given a graph, does there exist an orientation of the edges such that the resulting directed graph is strongly connected? Robbins' theorem [Robbins, Am. Math. Monthly, 1939] states that such an orientation exists if and only if the graph is 2-edge connected. A natural extension of this problem is the following: Suppose that the edges of the graph is partitioned into trails. Can we orient the trails such that the resulting directed graph is strongly connected? We show that 2-edge connectivity is again a sufficient condition and we provide a linear time algorithm for finding such an orientation, which is both optimal and the first polynomial time algorithm for deciding this problem. The generalised Robbins' theorem [Boesch, Am. Math. Monthly, 1980] for mixed multigraphs states that the undirected edges of a mixed multigraph can be oriented making the resulting directed graph strongly connected exactly when the mixed graph is connected and the underlying graph is bridgeless. We show that as long as all cuts have at least 2 undirected edges or directed edges both ways, then there exists an orientation making the resulting directed graph strongly connected. This provides the first polynomial time algorithm for this problem and a very simple polynomial time algorithm to the previous problem.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction and motivation

Suppose that the mayor of a small town decides to make all the streets one-way in such a way that it is possible to get from any place to any other place without violating the orientations of the streets111The motivation for doing so is that the streets of the town are very narrow and thus it is a great hassle when two cars unexpectedly meet.. If initially all the streets are two-way then Robbins’ theorem [9] asserts that this can be done exactly when the corresponding graph is -edge connected. If, on the other hand some of the streets were already one-way in the beginning then the generalised Robbins’ theorem [1] states that it can be done exactly when the corresponding graph is strongly connected and the underlying graph is -edge connected.

However, the proofs of both of these results assume that every street of the city corresponds to exactly one edge in the graph. This assumption hardly holds in any city in the world and therefore a much more natural assumption is that every street corresponds to a trail in the graph and that the edges of each trail must be oriented consistently222This version of the problem was given to us through personal communication with Professor Robert E. Tarjan.

In this paper we prove that Robbins’ Theorem continues to hold even when the set of edges is partitioned into trails. In other words a necessary and sufficient condition for an orientation to exist is that the graph is -edge connected. We also provide a linear time algorithm for finding such an orientation.

Finally we will consider the generalised Robbins’ theorem in this new setting i.e. we allow some edges to be oriented initially and suppose that the remaining edges are partitioned into trails. We will show that if any cut in the graph has either at least undirected edges going between to or a directed edge in each direction then it is possible to orient the trails making the resulting graph strongly connected. Although this condition is not necessary it does give a simple algorithm for deciding the problem. Indeed, the only cuts containing an undirected edge which we allow are the ones where this edge (and hence its trail) is forced in one direction. Hence for deciding the problem we can start by orienting all the forced trails until there are no more forced trails. Then the trails can be oriented making the graph strongly connected exactly if the resulting graph satisfies our condition.

Note that when some edges are initially oriented the answer to the problem depends on the trail decomposition which is not the case for the other results. That the condition from the generalised Robbins’ theorem is not sufficient can be seen from figure 1.

Figure 1: The graph is strongly connected and the underlying graph is -edge connected, but no matter the orientation of the red trail, the graph will lose its strong connectivity

Earlier methods

Several methods have already been applied for solving orientation problems in graphs where the goal is to make the resulting graph strongly connected.

One approach used by Robbins [9] is to use that a -edge connected graph has an ear-decomposition. An ear decomposition of a graph is a partition of the set of edges into a cycle and paths such that has its two endpoints but none of its internal vertices on . Assuming the existence of an ear decomposition of -edge connected graphs it is easy to prove Robbins’ theorem. Indeed, it is easy to see by induction that any consistent orientations of the paths and the cycle give a strongly connected graph.

A second approach introduced by Tarjan [3] gives another simple proof of Robbins’ theorem. One can make a DFS tree in the graph rooted at a vertex and orient all edges in the DFS tree away from . The remaining edges are oriented towards and if the graph is -edge connected it is easily verified that this gives a strong orientation.

A similar approach was used by Chung et al. [2] in the context of the generalized Robbins theorem for mixed multigraphs.

The above methods not only prove Robbins’ theorem, they also provide linear time algorithms for finding strong orientations of undirected or mixed multigraphs.

However, none of the above methods have proven fruitful in our case. In case of the ear decomposition one needs a such which is somehow compatible with the partitioning into trails and this seems hard to guarantee. The original proof by Roberts is essentially similar to using the ear decomposition. Similar problems appear when trying a DFS-approach. Neither does the proof by Boesch [1] of Robbins’ theorem for mixed multigraphs generalise to prove our result. Most importantly the corresponding theorem is no longer true for trail orientations as is shown by the example above.

Since the classical linear time algorithms rely on ear-decompositions and DFS searches, and since these approaches do not immediately work for trail partitions, our linear time algorithm will be a completely new approach to solving orientation problems.

2 Preliminaries

Let us briefly review the concepts from graph theory that we will need. Recall that a walk in a graph is an alternating sequence of vertices and edges , such that for the edge has and as its two endpoints. In a directed or mixed graph the ordering of the endpoints of each edge in the sequence must be consistent with the direction of the edge in case it is oriented. A trail is a walk without repeated edges. A path is a trail without repeated vertices (except possibly ). Finally a cycle is a path for which

Next, recall that a mixed multigraph is called strongly connected if for any vertices there exists a walk from to . In case that the graph contains no directed edges this is equivalent to saying that it consists of exactly one connected component.

We also recall the definition of -edge connectivity. A graph is said to be -edge connected if and only if is connected for all where . A trivially equivalent condition is that any edge-cut in the graph has at least edges going between and .

Finally, if is a mixed multigraph and we define to be that graph obtained by contracting to a single vertex and to be the subgraph of induced by . The following simple observation will be used repeatedly in this paper.

Observation 1.

If is -edge connected and then is -edge connected. Also if is a strongly connected mixed multigraph then is too.

The structure of this paper is as follows. In section 3 we prove our generalisation of Robbins’ theorem for undirected graphs partitioned into trails. In section 4 we study what happens in the case of mixed graphs. Finally in section 5 we provide our linear time algorithm for trail orientation in an undirected graph.

3 Robbins Theorem Revisited

We are now ready to state our generalisation of Robbins’ theorem.

Theorem 2.

Let be a multigraph with partitioned into trails. An orientation of each trail such that the resulting directed graph is strongly connected exists if and only if is -edge connected.

Proof.

If is not -edge connected, such an orientation obviously doesn’t exist so we need to prove the converse. Suppose therefore that is -edge connected.

Our proof is by induction on the number of edges in . If there are no edges, the graph is a single vertex, and the statement is obviously true. Assume now the statement holds for all graphs with strictly fewer edges than . Pick an arbitrary edge that is at the end of its corresponding trail.

If is -edge connected, then by the induction hypothesis there is a strong orientation of that respects the trails of . Such an orientation clearly extends to the required orientation of .

Figure 2: A two edge cut and the two graphs and .

If is not -edge connected, there exists a bridge in (see figure 2). Let be the two connected components of , and let and such that for , (note that we don’t necessarily have that and are distinct for ). Now for construct the graph , and define the trails in to be the trails of that are completely contained in , together with a single trail combined from the (possibly empty) partial trail of contained in and ending at , followed by the edge , followed by the (possibly empty) partial trail of contained in starting at . Both and are -edge connected since they can each be obtained as a contraction of . Furthermore, they each have strictly fewer edges than , so inductively each has a strong orientation that respects the given trails. Further, we can assume that the orientations are such that the new edges are oriented as and by flipping the orientation of all edges in either graph if necessary. We claim that this orientation, together with oriented as and oriented as , is the required orientation of . To see this first note that (by construction) this orientation respects the trails. Secondly suppose and are arbitrary. Since is strongly connected contains a directed path from to . Similarly, contains a directed path from to . Thus contains a directed path from to . A similar argument gives a directed path from to and since and were arbitrary this proves that is strongly connected and our induction is complete.

The construction in the proof can be interpreted as a naive algorithm for finding the required orientation when it exists.

Corollary 3.

The one-way trail orientation problem on a graph with vertices and edges can be solved in time, where is the time per operation for fully dynamic bridge finding (a.k.a. -edge connectivity).

At the time of this writing333Separate paper submitted to SODA’18 by Holm, Rotenberg and Thorup., this is . In Section 5 we will show a less naive algorithm that runs in linear time.

4 Extension to Mixed graphs

Now we will extend our result to the case of mixed graphs. We are going to prove the following.

Theorem 4.

Let be a strongly connected mixed multigraph. Then is strongly connected for all undirected if and only if for any partition of the undirected edges of into trails, and any , any orientation of can be extended to a strong trail orientation of .

Suppose is as in the theorem. We will say that is forced if it is undirected and satisfies that is not strongly connected444This terminology is natural since it is equivalent to saying that there exists a cut in such that is the only undirected edge in this cut and such that all the directed edges go from to . If one wants an orientation of the trails making the graph strongly connected we are clearly forced to orient from to .. Note that this is a proper extension of Theorem 2 since if is undirected and -edge connected then no is forced.

For proving the result we’ll need the following lemma.

Lemma 5.

Let be a directed graph, and let be a cut with exactly one edge crossing from to and at least one edge crossing from to . Then is strongly connected if and only if and are.

Proof.

Strong connectivity is preserved by contractions, so if is strongly connected then and both are. For the other direction, let be the edge going from to , and let be any edge from to . Since is strongly connected and is the only edge from to , contains a path from to that stays in . Since this holds for any edge going from to , and since is strongly connected, is strongly connected in . By a symmetric argument, is also strongly connected in and since the cut has edges in both directions, must be strongly connected. ∎

Now we provide the proof of Theorem 4.

Proof of theorem 4.

If is not strongly connected, the trail containing can at most be directed one way since is forced, so there is an orientation of which not extend to a strong trail orientation of . To prove the converse suppose is strongly connected for all undirected .

The proof is by induction on . If the result is trivial. So suppose and that the theorem holds for all with .

Consider a trail . Suppose there is no cut that crosses exactly once, which has exactly one other undirected edge crossing it, and has every directed edge crossing it going from to . Then regardless of the orientation of , the resulting graph has no undirected edge such that is not strongly connected. Thus, by induction has a strong trail orientation, which is also a strong trail orientation of , as desired.

Figure 3: A cut with two undirected edges and all directed edges going from to followed by a contraction of .

Now suppose there is such a cut (see figure 3). Construct a graph by contracting every vertex in into a single new vertex . Let consist of all trails in that are completely contained in , together with a single trail combined from the (possibly empty) fragments of the two trails that crossed the cut, joined at . Since any cut in corresponds to a cut in , is strongly connected and remains so after deletion of any single undirected edge. By induction any orientation of in extends to a strong orientation of . Let , , and be defined symmetrically, then by the same argument any orientation of in extends to a strong orientation of . Now for any orientation of , we can choose orientations of and that are compatible. The result follows by Lemma 5. ∎

Notice that the partitioning of edges into trails does not matter in the case when no edge is forced. Since any undirected graph has no forced edges if it is -edge connected, the theorem implies that the most naive algorithm: "directing trails that are forced and if none are forced direct an arbitrary trail" works for undirected graphs. In general for mixed graphs algorithm 1 below can clearly be implemented in polynomial time and does solve the trail orientation problem for mixed graphs.

Input: A mixed multigraph and a partition of the undirected edges of into trails.
Output: True if has a strong trail orientation, otherwise false. is modified in place, either to have such a strong trail orientation, or to a forced graph that is not strongly connected.
1 if  has a bridge or is not strongly connected then
2       return false
3 end if
4while  do
5       if for some undirected edge , is not strongly connected then
6             Let be the trail containing . if some orientation of leaves strongly connected then
7                   Apply such an orientation of to
8            else
9                   return false
10             end if
11            
12      else
13             Let be arbitrary. Update by orienting in an arbitrary direction.
14       end if
15      Remove from .
16 end while
return true
Algorithm 1 Algorithm for mixed graphs.

Theorem 4 gives a sufficient condition for when a strong orientation exists and we deal with the other cases by dealing with the forced edges first. However, the generalised Robbins’ Theorem provides a simple equivalent condition, which we lack. Finding such an equivalent condition when you have trail decomposition is an essential open problem for strong graph orientations. Due to figure 1 in this setting one has to take into account the structure of the trail partition.

5 Linear time algorithm

In this section we provide our linear time algorithm for solving the trail orientation problem in undirected graphs. For this, we make two crucial observations. First, we show that there is an easy linear time reduction from general graphs or multigraphs to cubic multigraphs. Second, we show that in a cubic multigraph with vertices, we can in linear time find and delete a set of edges that are at the end of their trails, such that the resulting graph has -edge connected components. We further show that we can compute the required orientation recursively from an orientation of each -edge connected component together with the cactus of -edge connected components. Since the average size of these components is constant, we can compute the orientations of most of them in linear time. The rest contains at most a constant fraction of the vertices, and so a simple geometric sum argment tells us that the total time is also linear.

We start out by making the following reduction.

Lemma 6.

The one-way trail problem on a -edge connected graph or multigraph with vertices and edges, reduces in time to the same problem on a -edge connected cubic multigraph with vertices and edges.

Proof.

Order the edges adjacent to each vertex such that two edges that are adjacent on the same trail are consecutive in the order. Replace each single vertex with a cycle of length , with each vertex of the new cycle inheriting a corresponding neighbour of . Note that for a vertex of degree , this creates a pair of parallel edges, so the result may be a multigraph. Since edges on the same trail are neighbours, we can make the cycle-edge between the two corresponding vertices belong to the same trail. The rest of the cycle edges form new length trails. This graph has exactly vertices and edges, and any one-way trail orientation on this graph translates to a one-way trail orientation of the original graph. The graph is constructed in time.

Figure 4: A node of degree 5 turns into a cycle of length 5

Recall now that a graph is called a cactus if it is connected and each edge is contained in at most one cycle. If is any connected graph we let be its -edge connected components. It is well known that if we contract each of these we obtain a cactus graph. For a proof of this result see section 2.3.5 of [7]. As the cuts in a contracted graph are also cuts in the original graph we have that if is -edge connected then the cactus graph is -edge connected. The edges of the cactus are exactly the edges of which are part of a -edge cut. We will call these edges 2-edge critical.

It is easy to check that if a cactus has edges and vertices then . We will be using this result in the proof of the following lemma.

Lemma 7.

Let be a cubic -edge connected multigraph, let , and let be minimal such that is -edge connected. Then has at least distinct -edge connected components.

Proof.

Let , be the set of edges deleted from to obtain , and let be the remaining edges in .

If , then by minimality of there are at least 2-edge-critical edges in i.e. edges of the corresponding cactus, and thus at least distinct -edge connected components.

If then , and since is cubic and the removal of each edge creates two vertices of degree we must have that has at least distinct -edge connected components. ∎

Lemma 8.

Let be a connected cubic multigraph with partitioned into trails. Then has a spanning tree that contains all edges that are not at the end of their trail.

Proof.

Let be the set of edges that are not at the end of their trail. Since is cubic, the graph is a collection of vertex-disjoint paths, and in particular it is acyclic. Since is connected can be extended to a spanning tree. ∎

Note that we can find this spanning tree in linear time. Indeed, we may assign weight to edges in and to the remaining edges and use the so-called555Originally discovered by Jarník [4], later rediscovered by Prim [8] Prim’s minimal spanning tree algorithm with a suitable priority queue to find the tree.

Lemma 9.

Let be a cubic -edge connected multigraph with partitioned into trails. Let be a spanning tree of containing all edges that are not at the end of their trail. Let be a minimal subgraph of that contains and is -edge connected. Then for any , less than of the vertices in are in a -edge connected component with at least vertices.

Proof.

Let be the set of edges that are not in . Since is cubic, . By Lemma 7 has at least -edge connected components. Each such component contains at least one vertex, so the total number of vertices in components of size at least is less than . ∎

Definition 10.

Let be a -edge connected component in some graph , whose edges is partitioned into trails. Define to be the -edge connected graph obtained by replacing each min-cut where and and with a single new edge . Define the corresponding partition of the edges of into trails by taking every trail that is completely contained in , together with new trails combined from the fragments of the trails that were broken by the min-cuts together with the new edges that replaced them. See figure 5.

At this point the idea of the algorithm can be explained. We remove as many of the edges, at the end of their trails, as we can still maintaining that the graph is -edge connected. Lemma 9 guarantees that we obtain a graph with many -edge connected components of size . We solve the problem for each for every -edge connected component. Finally, we combine the solutions for the different components like in the proof of theorem 2.

Figure 5: -edge connected components, notice how every edge out from the centre is part of a cycle. This right hand shows where is the component in the middle.
Theorem 11.

The one-way trail orientation problem can be solved in time on any -edge connected graph or multigraph with vertices and edges.

Proof.

By Lemma 6, we can assume the graph is cubic. For the algorithm we will use two subroutines. First of all when we have found the minimum spanning tree containing the edges that are not on the end of their trail we can use the algorithm of Kelsen [5] to, in linear time, find a minimal (w.r.t. inclusion) subgraph of that contains and is -edge connected. Secondly we will use the algorithm of Melhorn [6] to, in linear time, build the cactus graph of -edge connected components. The algorithm runs as follows:

  1. Construct a spanning tree of that contains all edges that are not at the end of their trail.

  2. Construct a minimal subgraph of that contains and is -edge connected666See Kelsen [5].

  3. Find the cactus of -edge connected components of777See Melhorn [6] .

  4. For each -edge connected component , construct .

  5. Recursively compute an orientation for each888Note that is cubic unless it consists of exactly one node. In this case however we don’t need to do anything. .

  6. Combine the orientations from each component.

First we will show correctness and then we will determine the running time.

Recall that we can flip the orientation in each and still obtain a strongly connected graph respecting the trails in . The way we construct the orientation of the edges of is by flipping the orientation of each in such a way that each cycle in the cactus graph becomes a directed cycle999In practise this is done by making a DFS (or any other search tree one likes) of the cactus and repeatedly orienting each component in a way consistent with the previous ones.. This can be done exactly because no edge of the cactus is contained in two cycles. By construction this orientation respects the trails so we need to argue that it gives a strongly connected graph.

For showing that the resulting graph is strongly connected, first let every -edge connected component be contracted, then the graph is strongly connected since the cycles of the cactus graph have become directed cycles. Now assume inductively that we have uncontracted some of the components and call this graph . Now we uncontract another component (see figure 6) and obtain a new graph which we will show is also strongly connected. If , then since is strongly connected there is a path from to in . If this path only contains edges which are edges in clearly this path also exists in so we are done. If the path uses one of the added edges (without loss of generality oriented from to ), it is because there are edges and forming a cut and thus being part of a cycle in the cactus. In this case we use edge to leave component and then go from back to component which is possible since was strongly connected. When we get back to the component we must arrive at since otherwise there would be two cycles in the cactus containing the edge . Hence the edge was not needed. This argument can be used for any of the edges of that are not in and thus we can move between any two nodes in . Since was strongly connected this suffices to show that is strongly connected. By induction this implies that after uncontracting all components the resulting graph is strongly connected.

Figure 6: Before and after uncontracting component

Now for the running time. By Lemma 9 each level of recursion reduces the number of vertices in “large” components by a constant fraction, for instance for we reduce the number of vertices in large components by a factor of . Let be the worst case running time with nodes for a cubic graph, and pick large enough such that is larger than the time it takes to go through steps - and as well as computing the orientations in the “small” components. Let be the number of vertices in the “large” -edge connected components. Then and

Inductively we may assume that and thus obtain

proving that for all .

Input: An undirected multigraph and a partition of the edges of into trails.
Output: True if has a strong trail orientation, otherwise false. is modified in place, either to have such a strong trail orientation, or to a forced graph that is not strongly connected.
1 Construct a spanning tree of that contains all edges that are not at the end of their trail. Construct a minimal subgraph of that contains and is -edge connected. Find the cactus of -edge connected components of . for each -edge connected component in in DFS preorder do
2       Construct . Recursively compute an orientation for . if the orientation of is not compatible with its DFS parent then
3             Flip orientation of
4       end if
5      
6 end for
7for each edge deleted from to create  do
8       if no edge on the trail of has been oriented yet then
9             Pick an arbitrary orientation for .
10      else
11             Set the orientation of to follow the trail.
12       end if
13      
14 end for
Algorithm 2 Linear time algorithm for cubic graphs.

6 Open problems

We here mention two problems concerning trail orientations which remain open.

First of all, our linear time algorithm for finding trail orientations only works for undirected graphs and it doesn’t seem to generalise to the trail orientation problem for mixed graphs. It would be interesting to know whether there also exists a linear time algorithm working for mixed graphs. If so it would complete the picture of how fast an algorithm we can obtain for any variant of the trail orientation problem.

Secondly, our sufficient condition for when it is possible to solve the trail orientation problem for mixed multigraphs is clearly not necessary. It would be interesting to know whether there is a simple necessary and sufficient condition like there is in the undirected case. Since in the mixed case the answer to the problem actually depends on the given trail decomposition and not just on the connectivity of the graph it is harder to provide such a condition. One can give the following condition. It is possible to orient the trails making the resulting graph strongly connected if and only if when we repeatedly direct the forced trails end up with a graph satisfying our condition in theorem 4. This condition is not simple and is not easy to check directly. Is there a more natural condition?

References

  • [1] Frank Boesch and Ralph Tindell. Robbins’s theorem for mixed multigraphs. The American Mathematical Monthly, 87(9):716–719, 1980.
  • [2] Fan R. K. Chung, Michael R. Garey, and Robert E. Tarjan. Strongly connected orientations of mixed multigraphs. Networks, 15(4):477–484, 1985.
  • [3] John Hopcroft and Robert Tarjan. Algorithm 447: Efficient algorithms for graph manipulation. Commun. ACM, 16(6):372–378, June 1973.
  • [4] V. Jarník. O jistém problému minimálním: (Z dopisu panu O. Borůskovi). Práce Moravské přírodovědecké společnosti. Mor. přírodovědecká společnost, 1930.
  • [5] Pierre Kelsen and Vijaya Ramachandran. On finding minimal 2-connected subgraphs. In Proceedings of the Second Annual ACM/SIGACT-SIAM Symposium on Discrete Algorithms, 28-30 January 1991, San Francisco, California., pages 178–187, 1991.
  • [6] Kurt Mehlhorn, Adrian Neumann, and Jens M. Schmidt. Certifying 3-edge-connectivity. Algorithmica, 77(2):309–335, 2017.
  • [7] Hiroshi Nagamochi and Toshihide Ibaraki. Algorithmic Aspects of Graph Connectivity. Cambridge University Press, New York, NY, USA, 1 edition, 2008.
  • [8] R. C. Prim. Shortest connection networks and some generalizations. The Bell System Technical Journal, 36(6):1389–1401, Nov 1957.
  • [9] H. E. Robbins. A theorem on graphs, with an application to a problem of traffic control. The American Mathematical Monthly, 46(5):281–283, 1939.