Some Classes of Bipartite Graphs Induced by Gray Codes

A Gray code of length n is a list of all binary words of length n such that each two successive codewords differ in only one bit position. If the first and the last codewords also share this property, the Gray code is called cyclic, otherwise it is called non-cyclic. The numbers indicating bit positions in where two successive codewords differ in the list of Gray codes are called transition numbers, and the sequence of these all numbers is called the transition sequence of the Gray code. In this article, bit positions of a Gray code of length n will be counted from 1 up until n. If a graph with vertex set {1, 2, ..., n} having the property that two vertices i and j are adjacent in the graph if and only if, i and j are consecutive transitions in the transition sequence of a Gray code, then the graph is called induced by the Gray code. Some classes of bipartite graphs are shown to be induced by Gray codes. Particularly, we show that complete bipartite graphs are induced by Gray codes.


Introduction
A Gray code of length n, or shortly an n-bit Gray code, is a list of all binary codewords of length n such that any two successive codewords differ in only one bit position. If this property holds for the last and first codewords in the list, the Gray code is called cyclic. Gray codes of length n can be considered as Hamiltonian paths on the hypercube graphs Q n , and cyclic Gray codes correspond to Hamiltonian cycles. There will be of N = 2 n n-bit codewords in Gray codes of length n, and in this article these codewords will be indexed from 0 to N −1. Codeword of index i will be denoted by x i , 0 ≤ i ≤ N − 1, and for cyclic Gray codes, indexes 0 and N are identified. The transition sequence S(n) = s 1 , s 2 , ..., s N −1 , of an n-bit Gray code G(n) lists the bit positions s i ∈ [n] = {1, 2, ..., n} where x i−1 and x i differ. If G(n) is a cyclic Gray code, then the cyclic transition sequence S(n) of G(n) is the concatenated sequence S(n), s N = s 1 , s 2 , ..., s N −1 , s N , where s N is the bit position where the codewords x N −1 and x 0 differ. We occasionally call s N as the closing transition of S(n). The number of transitions in a sequence will be called the length of the sequence. Especially for the standard Gray code of length n, n ≥ 1, we denote its cyclic transition sequence by S st (n) and it is defined as S st (n) = S st (n), n, for all integers n ≥ 1, where S st (1) = 1 and for n ≥ 2, S st (n) = S st (n − 1), n, S st (n − 1). Based on the above definition we have, for example, the transition sequence of the 4-bit standard Gray code as S(4) = 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 4. The standard Gray code, also known as the reflected Gray code, is the most celebrated topic. This code was a patented invention due to Frank Gray in 1953, and was used to reduce the coding errors in a pulse code communication system [6]. The wide spread utility of standard Gray codes is undisputed [2]. For particular applications, however, additional properties of Gray codes are sometimes desired. For examples, when designing experiments, or when designing and testing electrical circuits and information systems, balanced Gray codes are needed (cf. [3,9]).
The transition sequence of a Gray code defines an (undirected) graph of transitions whose vertex set [n], and whose edge set {{s i , s i+1 } : i ∈ {1, 2, ..., N − 1}}. Given a graph G with n vertices. A G-code is a Hamiltonian path on the n-cube Q n whose graph of transition is a subgraph of G. A cyclic G-code is a Hamiltonian cycle on Q n whose graph of transitions is a subgraph of G. We can see that every G-code has a unique transition sequence of length N if G-code is cyclic, and of length N − 1 otherwise. The graph Γ G(n) induced by a Gray code G(n) has vertex set [n] and edge set {{s i , s i+1 } : i ∈ {1, 2, ..., N − 1}}. If G(n) is cyclic, the cyclic graph Γ G(n) induced by G(n) is the graph Γ G(n) completed with the edge {s N −1 , s N } and {s N , s 1 } which may be already in Γ G(n) . We emphasize here that the graph Γ G(n) (or Γ G(n) ) is an undirected simple graph, i.e. if a consecutive pair {s i , s i+1 } occurs more than once in S(n) (or S(n)), then we consider only one edge joining s i and s i+1 in Γ (G(n) .
We should mention that if a G-code exists for a graph G, it does not mean that a Gray code exists which induces the graph G. As an instance, for the cycle graph of three vertices C 3 , there is a C 3 -code, but we can check by inspection that there is no Gray code which induces C 3 . Furthermore, we can immediately see that the complete bipartite graph K 1,n or the star graph St n with central vertex 1 is induced by the standard Gray code of length n + 1. Motivated by the construction of a particular type of Hamiltonian cycle in the cube-connected-cycle, CCC n , Bultena and Ruskey in [4] observed the existence of G-codes for various type of Graphs G. The cube-connected-cycle is a well known topology in computer networks (see [4]). The following result is due to Bultena and Ruskey in [4]. Theorem 1.1. For any complete multipartite graph G, there is a cyclic G-code.
Besides introducing some graphs G which are G-codes, Wilmer and Ernst in [14] also introduced some graphs which are induced by Gray codes. They in [14] also proposed to put attention to graphs of many edges: should not typical Gray codes induce many edges graphs? Based on this suggestion, Suparta and van Zanten in [12] proved the existence of Gray codes inducing complete graphs. In this paper we will show that some bipartite graphs are induced by Gray codes. Particularly we show that complete bipartite graphs are induced by Gray codes. Before closing this section, we will introduce the following definitions to facilitate the next discussion.

A Construction for Gray codes
In many cases, properties of Gray codes may be studied using their transition sequences (see e.g. [9,11,13]). In this article, we also use transition sequence of Gray code in studying some property of transition graph which is induced by the Gray code like Suparta and van Zanten did in [12].
The following lemma is due to Gilbert in [5] which describes some characteristics of transition sequence of a path or a cycle.  According to the Lemma 2.1, if the sequence S = s 1 , s 2 , ..., s N , with N = 2 n , is a transition sequence of a cyclic Gray code of length n, then we have that every consecutive subsequence of S of length 1, 2, ..., or N −1 contains at least one digit an odd number of times, while in the sequence S itself every digit occurs an even number of times.
The following theorem will leads us to construct the transition sequence of a Gray code of length n based on the transition sequence of a Gray code of length n − 2 for n ≥ 2. A slight different formulation of the theorem and its variation of proofs can be found in [1,8,10,12]. Here we will present a proof in a slightly different way as in [12]. We emphasize here that the number l in the theorem is an odd integer.
Theorem 2.1. Let S(n − 2) := u 0 , s j 1 , u 1 , s j 2 , ..., u l1 , s j l , u l , s 2 n−2 be the transition sequence of an (n − 2)-bit Gray code, and u k be a consecutive subsequence which may be the empty sequence. The sequence S which equals is a transition sequence of an n-bit Gray code.
Proof. Let us consider the sequence S which is listed as l + 2 rows, and each row is a subsequence of S, as is shown in the theorem. Let |u| be the length of the sequence u. We can see that the length of the sequence in the first row is l + 1 + |u 0 | + |u 1 | + . . . + |u l | = 2 n−2 , which is equal to the length of the sequence S(n − 2). Moreover, the length of every subsequence of the next l + 1 rows is 3 + 3|u j | for some j ∈ {0, 1, 2, . . . , l}. Thus, the length of the whole sequence S is equal to 4(l + 1 + |u 0 | + |u 1 | + . . . + |u l |) = 4 × 2 n−2 = 2 n . Furthermore, we can see easily that each digit in S occurs an even number of times. Now we need to show that any non-empty consecutive subsequence of S contains at least one digit an odd number of times. To this end, let t be any non-empty proper consecutive subsequence of S, and O(t) be the set of all integers in t which occur an odd number of times. We want to show that O(t) is not the empty set for any condition for t. If t is a subsequence of S(n − 2), then it is clear that O(t) is not the empty set, since S(n − 2) is a transition sequence (see Lemma 2.1). This implies that for any consecutive subsequence u j of S(n − 2), if t is a non empty subsequence of u j or of u R j , then O(t) is also not the empty set. Now suppose that t is not a subsequence of S(n−2), u j , nor of u R j , for any consecutive subsequence u j of S(n − 2). This means that n − 1 or n belongs to Z(t), the set of all integers in t. We have two cases: i) n − 1 or n belongs to O(t), and ii) both n − 1 and n do not belong to O(t). For case i), we are done, since this means that at least n − 1 or n occurs an odd number of times in t. Now assume that we are in case ii). This case suggests that the integers n − 1 and n occur an even numbers of times in t. Based on the occurrences pattern of the integers n and n − 1 in the theorem, the sequence t does not intersect the sequence of Row 1 in S. Thus, O(t) will be the same as O(u) for some consecutive subsequence u of S(n − 2). Therefore, O(t) is not empty.
The sequence of transitions s j 1 , s j 2 , . . . , s j l in Theorem 2.1 plays an important role for some characteristics of Gray codes defined by the resulting transition sequence S. In the sequel, the sequence of transitions s j 1 , s j 2 , . . . , s j l as in Theorem 2.1, will be denoted using T . If there is no confusion, we will omit commas when presenting transition sequences of Gray codes.
Remark 2.1. The position of digits n − 1 and n in Theorem 2.1 might be interchanged without having to lose the role of the resulting sequence as a transition sequence of a Gray code. In general, interchanging digits i and j, 1 ≤ i, j ≤ n, will only interchange bit positions i and j in the list of Gray code. The resulting Gray code will be said to be equivalent with the original Gray code.

Example 1
The complete bipartite graph K 2,2 is induced by 4-bit Gray code having the transition sequence S(4) = 212343234143234 (3). Now we illustrate the use of Theorem 2.1 to construct the transition sequence of a 6-bit Gray code. Set the sequence of transitions T := s 3 , s 6 , s 7 , s 10 , s 15 = 2, 3, 2, 1, 4. By applying Theorem 2.1 we can obtain the transition sequence S(6)

2123432341432345654323454323632341436345432563436345432125216125.
We immediately see that this transition sequence induces the complete bipartite graph K 3,3 which has diagram as in Figure 1. Whenever we interchange all positions of digits 5 and 6 in the last transition sequence, we will obtain 6-bit Gray code which is equivalent to the original one.

A procedure for constructing Gray codes inducing bipartite graphs
For some finite set X, as we defined for finite sequences, the number of elements in X will be denoted by |X|. Let G(V, E) be a bipartite graph, and X and Y be the partition sets of the vertex set V . If the graph G(V, E) is connected, |X| = m and |Y | = n, for some positive integers m and n, then this connected bipartite graph will be denoted by B m,n . The complete bipartite graph K m,n is an instance of B m,n .
Assume that some Gray code G(m+n−2) with transition sequence S(m+n−2) induces some bipartite graph B m−1,n−1 . Note that consecutive transitions in the transition sequence S(m+n−2) will occur alternately as the elements of the set X and of the set Y . In other words, s i ∈ X if and only if s i+1 ∈ Y , 1 ≤ i ≤ 2 m+n−2 − 1. The following procedure of construction will result in a transition sequence S of a Gray code inducing a bipartite graph of length m + n.

Construction
Let m and n be positive integers, with m, n ≥ 2. Consider the transition sequence S(m+n−2) of a Gray code of length (m + n − 2) which induces bipartite graph B m−1,n−1 . Then, continue with the following steps. Assume that S(n − 2) induces a bipartite Graph in Theorem 2.1. Observe the consecutive subsequence s j i , u i , s j i+1 of S(n − 2), with s j l+1 := s 2 n−2 , for some 1 ≤ i ≤ l. Since s j i ∈ X if and only if s j i+1 ∈ Y in the Contruction, we conclude that the number of components in u i is even. First, assume that u i is not the empty sequence. Let v and w be the first and the last component of u i . It is clear that v ∈ X if and only if w ∈ Y . Therefore, after applying step 3 of the Construction, we have that v and m + n − 1 as well as w and m + n are consecutive in the resulting sequence S(m + n). If u i is empty, then s j i+1 and m + n − 1 as well as s j i+1 and m + n will be consecutive in the sequence S(m + n).
In the Construction, the consecutiveness of transitions in sequence T is not restricted. In practice, the sequence T might be chosen as a consecutive subsequence of S(m + n − 2). In Example 1, if T is chosen as the consecutive subsequence 4143234 of 2123432341432343, then we obtain the following transition sequence S(6) = 2123432341432345654563652563654561654323432125212343236323432125.
Let B m−1,n−1 be a connected bipartite graph with partition sets of vertices X and Y . B m,n is called derived from B m−1,n−1 if the edges {m + n − 1, m + n}, {m + n, x}, and {m + n − 1, y} are in graph B m,n , for some pair of adjacent vertices x and y in graph B m−1,n−1 . We also say that B m−1,n−1 derives B m,n or B m,n is a derivation of B m−1,n−1 .
We can see that the Construction can be applied to derive some graph B m,n from some related graph B m−1,n−1 , as shown in the following theorem. Proof. First, we should emphasize that the sequence T in the Construction is always possible to be obtained. This is because each transition number s i ∈ [m + n − 2] occurs at least twice in S(m + n − 2). Therefore, after discarding a closing transition from S(m + n − 2), each transition number will remains at least one in S(m + n − 2). Take the sequnce T which contains 2k − 1 transition numbers s j 1 , s j 2 , s j 3 , . . . , s j 2k−2 , s 2 m+n−2 −1 satisfying condition 2) in the Construction. According to Theorem 2.1 we conclude that the resulting sequence S := S(m + n) is the transition sequence of some (m + n)-bit Gray code. Since the transition s 2 m+n−2 −1 is in T , it implies that transitions m + n − 1 and m + n occur consecutively in S(m + n). This means that the edge {m + n, m + n − 1} is indeed in the graph induced by S(m + n). Futhermore, again based on Theorem 2.1, we can see that transition x which occurs consecutively with some s j k ∈ X in S(m + n − 2), will occur consecutively with m + n − 1 in S(m + n). Similarly, the transition y which occurs consecutively with some s j l ∈ Y in S(m + n − 2), will occur consecutively with m + n in S(m + n). This implies that edges {x, m + n − 1} and {y, m + n} are in the graph induced by S(m + n).

Some bipartite graphs which are induced by Gray codes
In this section we will discuss some classes of bipartite graphs which are induced by some Gray codes using the Construction. One of the classes is complete bipartite graphs class.

Example 2
The Gray code with transition sequence S(3) = 12321232 with closing transition 2 (in the parentheses), induces the complete bipartite graph K 1,2 . Choose T = 123 (boldface transitions in S(3)). By applying Construction we get the sequence S(5) = 12321234543452541232141232523214 which defines a 5-bit Gray code inducing the complete bipartite graph K 2,3 .
Let m and n be any positive integers, with n > m. Assume that we want to construct a Gray code of length m + n which induces the complete bipartite graph K m,n . It is well known that the standard Gray code of length n − m + 2 induces the complete bipartite graph K 1,n−m+1 . By applying the Construction m − 1 times recursively to the previously resulting sequences, we will obtain a Gray code of length m + n inducing the complete bipartite graph K m,n .
How about the complete bipartite graph K n,n , n ≥ 1? For n = 1 is clear, since S st (2) induces K 1,1 . We can check by inspection that the transition sequence S(4) = 1234323414323432 defines a 4-bit Gray code inducing the complete bipartite graph K 2,2 . Now let us start from the S(4). By applying the Construction n − 2 times recursively to the resulting sequences which are resulted in from S(4), we will get a transition sequence S(2n) which induces the complete bipartite graph K n,n . So, for n ≥ 2 we can conclude that K n,n is induced by some 2n-bit Gray code. Thus, based on this observation we then have the following main result.
www.ejgta.org Proof. Using Example 2, Corollary 4.1, and all explanation just right before the theorem, then we are done. Now, we want to continue our observation to a class of bipartite graphs which has diagram shown in Figure 2. Assume that the integers n ≥ 2 and k ≥ 1. This bipartite graph has n + 2k + 1 vertices. One partition set has 1 + k vertices, and the other one has n + k vertices. Moreover, the graph has one vertex of degrees n + k, one vertex of degrees k + 1, n − 1 vertices of degree 1, and 2k vertices of degrees 2. Let us name this graph as bipartite graph of type 1, and denote by B (1) n+k,1+k . The diagram in Figure 3 is an example of a bipartite graph of type 1, B 3,2 , having 5 vertices. Furthermore, by setting the sequence T = s 31 = 1 (the boldface digit in S(5)), and then applying Construction, we will get the following transition sequence S(7) = 1213121454121312141213125213121676121312521312141213121454121312 1612131214541213121412131252131272131252131214121312145412131216 which induces the bipartite graph B 4,3 the graph of which is shown in Figure 4. In the next discussion we will show that for any integers n ≥ 2 and k ≥ 1, there exists a Gray code which induces the bipartite graph B (1) n+k,1+k . To this end, we recall about the standard Gray codes which was discussed at glance above. It is mentioned, just right before Theorem 1.1, that the star graph of n + 1 vertices, St n , is induced by the n + 1-bit standard Gray code. According to the definition of the transition sequence of the n-bit standard Gray code as in Eq. (1), we have for example the transition sequence S st (4) := 1213121412131214 for the 4-bit standard Gray code. This transition sequence induces the star graph of 4 vertices, with vertex of label 1 as the center of the star.
Consider the (n + 1)-bit standard Gray code, n ≥ 2, which induces the star graph of order n + 1 with the transition sequence S st (n + 1). The technique we do for constructing S(n + 3) which induces B (1) n+1,2 is by taking the sequence T consisting of only one term s 2 n+1 −1 = 1 in S st (n + 1). Using this sequence T for the Construction, we will obtain the transition sequence S(n + 3) := S st (n + 1), n + 2, n + 3, n + 2, S st (n + 1) R , n + 2, S * (n + 1), n + 3, S * (n + 1) R , n + 2, where S * (n + 1) is the sequence obtained from S st (n + 1) after lifting out the last transition. According to Eq. 1, the first and the last transitions of S st (n + 1) and of S st (n + 1) R are 1. From here we conclude that 1 and n + 2 are consecutive in S(n + 3). While the last transition of the sequence S * (n + 1) is the same as the first transition of S * (n + 1) R which is the transition 2. This implies that the transition 2 and n + 3 are consecutive in S(n + 3). Moreover we can see immediately that the transitions n + 2 and n + 3 are consecutive in S(n + 3). Thus, we can finally conclude that the transition sequence S(n + 3) induces the bipartite graph B (1) n+1,2 . By recursively applying this technique we have proven the following theorem. n+k,1+k . Below we will discuss another class of connected bipartite graphs induced by Gray codes. This class consists of graphs of 2k vertices, k ≥ 2, where each partition set of vertices has k vertices. Further characteristics of the graphs are that they have 2 vertices of degrees k, and 2k − 2 vertices of degrees 2. The diagram of this class of graphs is shown in Figure 5, and will be denoted by B (2) k,k .

Example 3
We can verify that the sequence S(4) = 1232123432123214 is the transition sequence of Gray code which induces the graph B 3,3 , two vertices (vertices 1 and 2) are of degrees 3, and 4 vertices (vertices 3, 4, 5, and 6) are of degrees 2. By observing carefully how the Construction works, we can easily see that the degrees of vertices 1 and 2 each will increase by 1 each time we construct the next derivation graph. Thus, the characteristics of being B (2) k,k are maintained.
Remark 4.1. The interchange of digits 5 and 6 in the transition sequence is only for maintaining the adjacency of odd-even labels in the related graph. This does not influence the structure of the graph.
Based on the above observation, we have the following theorem.
2,2 . Note that in that S(4) we have the subsequences s 1 , s 2 = 1, 2 and s 2 4 −2 , s 2 4 −1 = s 14 , s 15 = 2, 1. Preceding the theorem, we described some technique how we obtain a Gray code of length 6 inducing the bipartite graph B 3,3 . Using the technique we get the transition sequence S(6) of the 6-bit Gray code which maintains the propertiy that the subsequences s 1 , s 2 = 1, 2 and s 2 6 −2 , s 2 6 −1 = s 62 , s 63 = 2, 1. This condition results in the degrees of vertices 1 and 2 to increase by 1, and keep the degrees of other vertices when we construct the next derivation graph using the Construction. Thus, in B Assume that the transition sequence S(2k) of length 2k, k ≥ 2, exists which defines a Gray code inducing B (2) k,k , and has the characteristics that the subsequences s 1 , s 2 = 1, 2, s 2 2k −2 , s 2 2k −1 = 2, 1, deg(1) = deg(2) = k, and 2k − 2 other vertices are of degrees 2. For constructing a Gray code of length 2k + 2 = 2(k + 1) inducing B (2) k+1,k+1 , we can accomplish by taking T := s 2 2k −1 = 1. Then, by applying the Construction, we will obtain a transition sequence S(2k + 2) which induces B (2) k+1,k+1 . Based on Theorem 2.1, we can conclude that in B (2) k+1,k+1 , deg(1) = deg(2) = k + 1. According to mathematical induction principle, we have proven the theorem. The last class of bipartite graphs which is induced by Gray code has diagram as in Figure 6. This bipartite graph class has 2k vertices, for some positive integer k ≥ 3, and has characteristics as follows: the graph has k + 1 vertices of degrees 2, 2 vertices of degrees 3, and k − 3 vertices of degrees 4. This type of graphs will be denoted by B

Example 4
The transition sequence S(6) := 3212321412321235653212321412321235321232141232126212321412321235 defines a 6-bit Gray code which induces B 3,3 and has the following diagram. This graph has the characteristics described above: k + 1 = 4 vertices of degrees 2, 2 vertices of degrees 3, and k − 3 = 0 vertex of degree 4.