Some algorithmic results for finding compatible spanning circuits in edge-colored graphs

A compatible spanning circuit in a (not necessarily properly) edge-colored graph G is a closed trail containing all vertices of G in which any two consecutively traversed edges have distinct colors. Sufficient conditions for the existence of extremal compatible spanning circuits (i.e., compatible Hamilton cycles and Euler tours), and polynomial-time algorithms for finding compatible Euler tours have been considered in previous literature. More recently, sufficient conditions for the existence of more general compatible spanning circuits in specific edge-colored graphs have been established. In this paper, we consider the existence of (more general) compatible spanning circuits from an algorithmic perspective. We first show that determining whether an edge-colored connected graph contains a compatible spanning circuit is an NP-complete problem. Next, we describe two polynomial-time algorithms for finding compatible spanning circuits in edge-colored complete graphs. These results in some sense give partial support to a conjecture on the existence of compatible Hamilton cycles in edge-colored complete graphs due to Bollobás and Erdős from the 1970s.


Introduction
In this paper we consider only finite undirected simple graphs. For terminology and notations not defined here, we refer the reader to the textbook of Bondy and Murty (2008).
Let G be a graph. We use V (G) and E(G) to denote the vertex set and edge set of G, respectively. For a vertex v of G, we denote by E G (v) the set of edges of G incident with v, and we denote by N G (v) the set of neighbors of v in G. The degree of a vertex v in a graph G, denoted by d G (v), is defined to be the cardinality of E G (v). We write (G) = max{d G (v) | v ∈ V (G)}. If no ambiguity can arise, we will denote E G (v), N G (v) and d G (v) by E(v), N (v) and d(v), respectively.
A spanning circuit in a graph G is defined as a closed trail that visits (contains) each vertex of G. A Hamilton cycle of G refers to a spanning circuit visiting each vertex of G exactly once; an Euler tour of G refers to a spanning circuit traversing each edge of G. Hence, a spanning circuit is a common relaxation of a Hamilton cycle and an Euler tour. A graph is said to be hamiltonian if it contains a Hamilton cycle, and a graph is said to be eulerian if it admits an Euler tour.
An edge-coloring of a graph G is defined as a mapping c : E(G) → N, where N is the set of natural numbers. An edge-colored graph refers to a graph with a fixed edge-coloring. Two edges of a graph are said to be consecutive with respect to a trail (with a fixed orientation) if they are traversed consecutively along the trail. A compatible spanning circuit in an edge-colored graph refers to a spanning circuit in which any two consecutive edges have distinct colors. An edge-colored graph is said to be properly colored if any two adjacent edges (i.e., edges sharing exactly one end vertex) of the graph have distinct colors, and an edge-colored graph is rainbow if each pair of edges of the graph has distinct colors. Thus, a compatible Hamilton cycle is properly colored, and a properly colored spanning circuit is compatible. Conversely, a compatible spanning circuit is obviously not necessarily properly colored. Thus, a compatible spanning circuit can be viewed as a generalization of a properly colored spanning circuit. Compatible spanning circuits are of interest in graph theory applications, for example, in genetic and molecular biology (Pevzner 2000;Szachniuk et al. 2014Szachniuk et al. , 2009, in the design of printed circuits and wiring boards (Tseng et al. 2010), and in channel assignment of wireless networks (Ahuja 2010;Sankararaman et al. 2014).
Let G be an edge-colored graph. We use c(e) to denote the color appearing on the edge e of G, and we use C(G) to denote the set of colors appearing on the edges of these two parameters are called the maximum monochromatic degree of a vertex v of G and the maximum monochromatic degree of an edge-colored graph G, respectively. The color degree of a vertex v of an edge-colored graph G, denoted by cd G (v), is defined to be the number of colors appearing on the edges of G incident with v. When no confusion can arise, we will use From a sufficient condition perspective, the existence of two kinds of extremal compatible spanning circuits, i.e., compatible Hamilton cycles and compatible Euler tours in specific edge-colored graphs has been studied extensively. For more details on the topic, we refer the reader to Alon and Gutin (1997), Bollobás and Erdős (1976), Chen and Daykin (1976), Daykin (1976), Fleischner and Fulmek (1990), Kotzig (1968), Lo (2016) and Shearer (1979). On the other hand, Benkouar et al. (1996), from an algorithmic perspective, considered the existence of compatible Euler tours in edgecolored eulerian graphs. Benkouar et al. (1996) provided a polynomial-time algorithm for finding a compatible Euler tour in an edge-colored eulerian graph G in which Independently, Pevzner (1995) described a similar algorithm for solving the same problem.
In recent work (Guo et al. 2020a, b), sufficient conditions for the existence of more general compatible spanning circuits (i.e., not necessarily a compatible Hamilton cycle or Euler tour) in specific edge-colored graphs have been established.
In this paper, we consider the existence of compatible spanning circuits in edge-colored graphs from an algorithmic perspective. We first prove the following complexity result by a simple reduction from a result due to Garey et al. (1974).

Theorem 1.1 The decision problem of determining whether an edge-colored connected graph contains a compatible spanning circuit is NP-complete.
We postpone the proofs of all our results in order not to interrupt the flow of the narrative. Motivated by the above NP-completeness result, we consider the existence of compatible spanning circuits in specific classes of edge-colored graphs from an algorithmic perspective, and we analyze the complexity of the associated algorithms.
A number of sufficient conditions for the existence of compatible Hamilton cycles in edge-colored complete graphs have been obtained (see Alon and Gutin 1997;Bollobás and Erdős 1976;Chen and Daykin 1976;Daykin 1976;Lo 2016;Shearer 1979). In particular, Bollobás and Erdős (1976) considered the problem and proposed the following conjecture on the existence of compatible Hamilton cycles in edge-colored complete graphs back in the 1970s (see Conjecture 1.1). Recently, Lo (2016) proved that this conjecture is true asymptotically. Throughout the rest of this paper, we use K c n to denote an edge-colored complete graph on n vertices, where n ≥ 3.
Conjecture 1.1 (Bollobás and Erdős 1976) If mon (K c n ) < n/2 , then K c n contains a compatible Hamilton cycle.
In the rest of this paper, we first deal with the existence of compatible spanning circuits (with no restrictions) in graphs K c n with mon (K c n ) ≤ (n − 1)/2 , as follows.
Theorem 1.2 If mon (K c n ) ≤ (n − 1)/2 , then K c n contains a compatible spanning circuit. Moreover, such a compatible spanning circuit can be found by an O(n 4 ) algorithm.
Remark 1.1 The following example, extended from a construction given by Fujita and Magnant (2011), shows that the bound on mon (K c n ) in Theorem 1.2 is tight.
Example 1.1 Let G be a complete graph on n (n ≥ 3) vertices, and let u be one of the vertices of G. We label the remaining vertices with v 1 , . . . , v n−1 , respectively, and we color the edge uv i with color i for each v i , where 1 ≤ i ≤ n − 1. Let H = G − u, and consider a decomposition of the edges of H into (n −2)/2 Hamilton cycles (together with one perfect matching M, if n is odd). We arbitrarily orient these Hamilton cycles (and M, if n is odd) such that they become directed cycles (a directed perfect matching). We color the edge v i v j with color j if the arc − − → v i v j is an arc of one of these Hamilton cycles (perfect matching). This defines an edge-coloring of G, thus a K c n .
One can check that the edge-colored complete graph K c n of Example 1.1 satisfies mon (K c n ) = (n − 1)/2 + 1, but it contains no compatible spanning circuit, because such a circuit cannot visit the vertex u compatibly.
We next deal with the existence of compatible spanning circuits visiting every vertex, except for one specific vertex, exactly (n − 2)/2 times in graphs K c n , and we obtain the following result.

Theorem 1.3 Let n be an even integer such that n
then K c n contains a compatible spanning circuit visiting every vertex of K c n , except for v 0 , exactly (n − 2)/2 times. Moreover, such a compatible spanning circuit can be found by an O(n 4 ) algorithm.

Remark 1.2
The edge-colored complete graphs on even n (n ≥ 4) vertices of Example 1.1 also show that the bound on mon (K c n ) in Theorem 1.3 is tight. However, we do not know whether the bound on cd(v 0 ) in Theorem 1.3 is tight.
The rest of the paper deals with the proofs of our three results.

Proof of Theorem 1.1
Our proof is based on the NP-completeness of the following special case of the Hamilton problem, an early complexity result due to Garey et al. (1974).
Problem 2.1 (Garey et al. 1974) Instance: A connected graph G with (G) = 3. Question: Does G contain a Hamilton cycle?
The problem above can easily be reduced to the following special case of the decision problem we stated in Theorem 1.1.

Problem 2.2
Instance: An edge-colored connected graph G c with (G c ) = 3. For any instance G of Problem 2.1, we construct a rainbow edge-colored graph by coloring all edges of G with pairwise distinct colors, to obtain an instance G c of Problem 2.2. It is obvious that the graph G contains a Hamilton cycle if and only if the edge-colored graph G c contains a compatible spanning circuit.
It follows directly from our construction that the reduction above is polynomial. This proves that Problem 2.2 is NP-complete. Since Problem 2.2 is a special case of the decision problem we stated in Theorem 1.1, the result is immediate.

Proofs of Theorems 1.2 and 1.3
Before proceeding with our proofs, we first introduce some additional terminology.
For a given trail . We prove Theorem 1.2 by considering the following polynomial algorithm, and proving its correctness. We use CSC as shorthand for compatible spanning circuit.
Algorithm 1 Finding a CSC in K c n with mon (K c n ) ≤ (n − 1)/2 .

Input:
A graph K c n with mon (K c n ) ≤ (n − 1)/2 ; Output: A CSC T of K c n ; Step 1. If n is odd, then let H = K c n ; otherwise, choose an arbitrary perfect matching M of K c n , and let H = K c n − M; Step 2. Choose an arbitrary vertex x 1 of H , and put T 1 = x 1 ; Choose the next vertex x 2 such that c(x 1 x 2 ) is (one of) the least frequent colors among the edges of E H (x 1 ), and put T 2 = x 1 x 2 ; Step 3. Based on T i = x 1 x 2 · · · x i (i ≥ 2), build up T i+1 = x 1 x 2 · · · x i x i+1 according to the following rules: Step 4. i ← i + 1, and go to Step 3; Step 5. T is a CSC of K c n ; terminate the process; return T .
The ideas behind Algorithm 1 were inspired by similar ideas due to Pevzner (1995) for an efficient algorithm to construct a compatible Euler tour in an edge-colored eulerian graph G in which mon (v) ≤ d(v)/2 for each vertex v of G.
Next, we show the correctness of Algorithm 1 by proving the following lemmas, with the notations H i , T i , H and T defined as above. Proof Suppose, to the contrary, that the statement of Lemma 3.1 does not hold. Let i 0 be the minimum integer such that Lemma 3.1 fails. Clearly, we have i 0 > 2. Thus, for some color c and some vertex v distinct from x 1 and x i 0 , we have d c It is not difficult to see that v = x i 0 −1 ; otherwise Lemma 3.1 would already fail for the integer i 0 − 1. It follows from d c We first prove the following claim in order to complete the proof of Lemma 3.1.

Claim 1 c(x i
Proof Suppose, to the contrary, that c( contradicting the minimality of i 0 . This completes the proof of Lemma 3.1.

Proof By
Step 2 of Algorithm 1, we have mon Next, we assume that i ≥ 3. Suppose, to the contrary, that the statement of Lemma 3.2 does not hold. Let i 0 be the minimum integer such that Lemma 3.2 fails. Since x i 0 = x 1 , we conclude that x i 0 −1 = x 1 ; otherwise Lemma 3.2 would already fail for some integer less than i 0 . Thus, for some color c, we have d c We first prove the following claim in order to complete the proof of Lemma 3.2.
Proof Suppose, to the contrary, that c( It follows that c(x i 0 −2 x 1 ) = c by the rules of Step 3 of Algorithm 1. Thus, we have d c contradicting the minimality of i 0 . This confirms our claim.
By Claim 2, we have c( , contradicting the minimality of i 0 . This completes the proof of Lemma 3.2.
From Lemmas 3.1 and 3.2, we obtain the following lemma immediately.

Lemma 3.3 implies that for each trail T i = T , there always exists an edge
Next, we show that Algorithm 1 will terminate, by proving the following lemma.

Lemma 3.4 For an integer i with i
Proof Let i be an integer with i ≥ 3 such that We first claim that V (T i ) = V (H ). Suppose, to the contrary, that there exists a vertex v ∈ V (H )\V (T i ). Obviously, we have v / ∈ {x 1 , x i }. Recall that K c n is a complete graph on n vertices, where n ≥ 3. It follows from the construction of H that at least one of vx i and vx 1 is an edge of H i , contradicting the fact that Next, we prove the assertion that c(x i x 1 ) = c(x 1 x 2 ). Suppose, to the contrary, that c(x i x 1 ) = c(x 1 x 2 ) = c 0 . Let us consider T i as the oriented trail in the direction from x 1 to x 2 (see Fig. 1). Note that d H (x 1 ) = n − 1, if n is odd, and d H (x 1 ) = n − 2, otherwise. We use y 1 , y 2 , . . . , y n−3 , y n−2 (and y n−1 , if n is odd) to denote the vertices of H adjacent to the vertex x 1 according to the order in which they are visited by the oriented trail T i (see Fig. 1a, b).
We prove the following claim in order to complete the proof of Lemma 3.4.

Claim 3
There exists an integer j with 2 ≤ j ≤ n − 4 (2 ≤ j ≤ n − 3, if n is odd) such that c( − − → y j x 1 ) = c 0 and c( − −−− → x 1 y j+1 ) = c 0 . . 1 a The oriented trail T i for n odd; b the oriented trail T i for n even Proof Suppose, to the contrary, that at least one of c( − − → y j x 1 ) and c( − −−− → x 1 y j+1 ) is c 0 for every integer j with 2 ≤ j ≤ n − 4 (2 ≤ j ≤ n − 3, if n is odd). It follows that , contradicting the fact that mon (K c n ) ≤ (n − 1)/2 . This confirms our claim.
x 1 y j 0 +1 ) = c 0 by the rules of Step 3 of Algorithm 1. However, as supposed, we have c( − −−−→ x 1 y j 0 +1 ) = c 0 , a contradiction. This completes the proof of Lemma 3.4. Lemma 3.4 implies that Algorithm 1 will terminate in the case that E H i (x i ) = E H i (x 1 ) = {x i x 1 } for some integer i with i ≥ 3 such that x i = x 1 . However, it is possible that Algorithm 1 terminates earlier. It is not difficult to check that in all cases the output T of Algorithm 1 is a compatible spanning circuit of K c n . Now, we analyze the time complexity of Algorithm 1. It is obvious from the structure of the algorithm that the combination of Step 4 and Step 3 dominates and determines its time complexity. Since each edge of H is traversed at most once, Step 3 is performed at most |E(H )| = O(n 2 ) times according to Step 4 of Algorithm 1. In Step 3 of Algorithm 1, it requires at most O(n 2 ) time to choose a vertex x i+1 such that x i x i+1 is suitable for T i in H : this requires checking and comparing these colors that appear on x i−1 x i and the at most O(n 2 ) edges of E H (x i ). Thus, Step 3 takes at most O(n 2 ) time, yielding an overall time complexity O(n 4 ). This completes the proof of Theorem 1.2.

Proof of Theorem 1.3
We prove Theorem 1.3 by using a known algorithm due to Pevzner (1995) as a subroutine to construct an O(n 4 ) algorithm, and proving its correctness. Pevzner (1995) provided a polynomial algorithm for constructing a compatible Euler tour (CET for short) in an edge-colored eulerian graph G in which mon (v) ≤ d(v)/2 for each vertex v of G (see Algorithm 2 below). Benkouar et al. (1996) inde-pendently described a different algorithm for solving the same problem, requiring solving a perfect matching problem for a specific class of complete k-partite graphs.
We use Algorithm 2 as a subroutine to construct an O(n 4 ) algorithm for finding a compatible spanning circuit visiting every vertex of K c n , except for one specific vertex, exactly (n − 2)/2 times (SCSC for short), subject to the conditions that n is an even integer and n ≥ 4, as well as the graph K c n satisfies mon (K c n ) ≤ (n − 2)/2 and cd(v 0 ) ≥ n − ( √ 4n − 3 + 1)/2 for some vertex v 0 of K c n (see Algorithm 3 below). In Algorithm 3, we denote Thus, the graph G satisfies the conditions of Algorithm 2. This implies that we can use Algorithm 2 as a subroutine in Step 2 of Algorithm 3 to construct a compatible Euler tour T of G .
After presenting the pseudocode of the two algorithms, we show the correctness of Algorithm 3 by stating and proving Lemma 3.5. This is followed by a short analysis of the time complexity and some concluding remarks.
Algorithm 2 (Pevzner 1995) Finding a CET in an edge-colored eulerian graph G with Step 1. i ← 1; C ← ∅; Step 2. Choose an arbitrary vertex x 1 of G, and put T 1 = x 1 ; Choose the next vertex x 2 such that c(x 1 x 2 ) is the most frequent color among the edges of E(x 1 ), and put T 2 = x 1 x 2 ; while there exists an edge x j x j+1 suitable for T j in G do Based on T j = x 1 x 2 · · · x j ( j ≥ 2), build up T j+1 = x 1 x 2 · · · x j x j+1 by choosing a vertex x j+1 such that x j x j+1 is suitable for T j in G, and preferentially choosing the vertex x j+1 such that c(x j x j+1 ) = c(x 1 x 2 ) when x j = x 1 ; j ← j + 1; end while C i ← T j (note that T j is a closed trail); Step 3. if E(G) = ∅ then i ← i + 1, and go to Step 2; end if Step 4. To construct T , if C \ {C 1 } = ∅, then start walking along C 1 , until an intersection vertex with another closed trail C p of C is found; Continue walking along C p while preserving the compatibility on the intersection vertex in the case of walking into C p and walking out of C p , until C p is entirely walked out; Then continue walking along the remaining part of C 1 , until C 1 is entirely walked out; We use C 1 to denote the new closed trail that is the combination of C 1 and C p , and continue to combine the remaining elements of C, if any, in this way, until all elements of C have been combined into the closed trail T ; return T .

Conclusions and final remarks
In this work, we considered the existence of more general compatible spanning circuits in edge-colored graphs from an algorithmic perspective. We first proved that the decision problem of determining whether an edge-colored connected graph contains a compatible spanning circuit is NP-complete, even within graphs with maximum degree 3. We then developed two polynomial-time algorithms for finding compatible spanning circuits (with certain properties) in specific edge-colored complete graphs. In particular, our Algorithm 1 returns a compatible spanning circuit (with no restrictions) directly. In previous work from literature, this was done in two steps. We also presented Algorithm 3 for finding compatible spanning circuits visiting every vertex, except for one specific vertex, exactly (n−2)/2 times in edge-colored complete graphs G on even n (n ≥ 4) vertices with mon (G) ≤ (n − 2)/2 and cd(v 0 ) ≥ n − ( √ 4n − 3 + 1)/2 for some vertex v 0 of G.
In future work, we look forward to establishing polynomial-time algorithms for finding compatible spanning circuits in other classes of edge-colored graphs. As another future direction, a more challenging problem is to develop polynomial-time algorithms for finding compatible spanning circuits visiting every vertex exactly (or at least) a specified number of times in some specific classes of edge-colored graphs.