## On the probability of existence of a universal cycle or a universal word for a set of words

Herman Z.Q. Chen , Sergey Kitaev , Brian Y. Sun a b c,d a School of Statistics and Data Science, Nankai University, Tianjin 300071,P.R. China b Department of Computer and Information Sciences, University of Strathclyde, Glasgow, G1 1XH, UK c College of Mathematics and System Science, Xinjiang University, Urumqi, Xinjiang 830046, P.R.China d School of Mathematics and Statistics &amp; KLAS, Northeast Normal University,

Changchun 130024, Jilin Province, P.R. China

## Email: a zqchern@163.com , b sergey.kitaev@cis.strath.ac.uk , c brianys1984@126.com

Abstract. A universal cycle, or u-cycle, for a given set of words is a circular word that contains each word from the set exactly once as a contiguous subword. The celebrated de Bruijn sequences are a particular case of such a u-cycle, where a set in question is the set A n of all words of length n over a k -letter alphabet A . A universal word, or u-word, is a linear, i.e. non-circular, version of the notion of a u-cycle, and it is defined similarly.

Removing some words in A n may, or may not, result in a set of words for which u-cycle, or u-word, exists. The goal of this paper is to study the probability of existence of the universal objects in such a situation. We give lower bounds for the probability in general cases, and also derive explicit answers for the case of removing up to two words in A n , or the case when k = 2 and n ≤ 4.

Keywords: universal cycle, u-cycle, universal word, u-word, de Bruijn sequence

## 1 Introduction

A universal cycle , or u-cycle , for a given set S with /lscript words of length n is a circular word u u 0 1 · · · u /lscript -1 that contains each word from S exactly once as a

contiguous subword u u i i +1 · · · u i + n -1 for some 0 ≤ i ≤ -/lscript 1, where the indices are taken modulo n . The notion of a universal cycle was introduced in [4]. The celebrated de Bruijn sequences are a particular case of such a u-cycle, where a set in question is the set A n of all words of length n over a k -letter alphabet A . Also, a universal word , or u-word , for S is a (non-circular) word u u 0 1 · · · u /lscript + n -1 that contains each word from S exactly once as a contiguous subword u u i i +1 · · · u i + n -1 for some 0 ≤ i ≤ /lscript -1. In this paper, we assume that n ≥ 2 and k ≥ 2 to make all of our definitions be well-defined and to avoid trivialities.

There is a long line of research in the literature dedicated to the study of universal cycles and universal words for various sets of combinatorial structures. For example, see [5] and references there in. We note that the existence of a u-cycle trivially implies the existence of a u-word, but not vice versa. Indeed, if u u 0 1 · · · u /lscript -1 is a u-cycle for S then u u 0 1 · · · u /lscript -1 u u 0 1 · · · u n -2 is a u-word for S . In either case, solving problems on u-cycles and u-word is normally done through considering de Bruijn graphs . A de Bruijn graph B n, k ( ) consists of k n nodes corresponding to words in A n and its directed edges are x x 1 2 · · · x n → x 2 · · · x x n n +1 where x i ∈ A for i ∈ { 1 , . . . , n +1 . De } Bruijn graphs are an important structure that is used in solving of a variety of problems, e.g. in combinatorics on words [7] and genomics [13].

Let G = ( V, E ) be a directed graph. A directed path in G is a sequence v , . . . , v 1 t of distinct nodes such that there is an edge v i → v i +1 for each 1 ≤ i ≤ t -1 and v i ∈ V ( G ). Such a path is a Hamiltonian path if it contains all nodes in G . A closed Hamiltonian path ( v t → v 1 is an edge) is a Hamiltonian cycle . If G has a Hamiltonian cycle then G is Hamiltonian . It is well-known, and is not difficult to show, that B n, k ( ) is Hamiltonian, so any Hamiltonian cycle (resp., path) in B n, k ( ) corresponds to a u-cycle (resp., u-word) for A n . For example, the cycle 00 → 01 → 11 → 10 → 00 in B (2 , 2) corresponds to the u-cycle 0011, and we can also get a u-word 00110 from this.

The problem in question. Now, suppose that we remove s &lt; k n words from A n where A is an alphabet of size k . The resulting set S may, or may not have a u-cycle or a u-word. Let P c ( n, k, s ) and P w ( n, k, s ) be the probabilities of the events that S has a u-cycle and u-word, respectively. Then, a natural question is: What are P c ( n, k, s ) and P w ( n, k, s )? Note that by definition, a u-cycle for S must cover at least n distinct words, and thus if s &gt; k n -n then P c ( n, k, s ) = 0.

Table 1.1: Values of P c (2 , 2 , s ) and P w (2 , 2 , s ) for s ≥ 1

| s                | 1   | 2   |   3 |
|------------------|-----|-----|-----|
| P c (2 , 2 , s ) | 1 2 | 1 6 |   0 |
| P w (2 , 2 , s ) | 1   | 5 6 |   1 |

Table 1.2: Values of P c (3 , 2 , s ) and P w (3 , 2 , s ) for s ≥ 1

| s                | 1   | 2      | 3        | 4       | 5    | 6     |   7 |
|------------------|-----|--------|----------|---------|------|-------|-----|
| P c (3 , 2 , s ) | 1   | 1      | 1        | 3       | 1 28 | 0     |   0 |
| P w (3 , 2 , s ) | 4 1 | 14 5 7 | 28 13 28 | 70 5 14 | 5 14 | 13 28 |   1 |

It is not difficult to see that if s = 1, or s = k n -1, then with probability 1 a u-word exists. Indeed, if s = 1 then removing a word in A n corresponds to removing a node in B n, k ( ) that turns a Hamiltonian cycle passing through it to a Hamiltonian path giving a u-word, while if s = k n -1 then only one word remains and it is a u-word. Similarly, it is not difficult to see that if s = 1 then with probability 1 /k n -1 a u-cycle exists. Indeed, if s = 1 then one can only remove words of the form xx · · · x called loops, and there are k such words, while if s = k n -1 then the only u-cycle of length n can be a loop.

In Tables 1.1, 1.2 and 1.3 we present the values of P c ( n, 2 , s ) and P w ( n, 2 , s ) for n = 2 3 4 obtained by Mathematica 11.3. Even though these tables were , , obtained by computer, it is possible to check them by hand for n = 2 3 by , considering the existence of a Hamiltonian path in B n, ( 2). Moreover, in the case of n = 4, one can consider Eulerian cycles/paths (to be introduced below) in B (3 , 2) and be also able to check Table 1.3 by hand.

Table 1.3: Values of P c (4 , 2 , s ) and P w (4 , 2 , s ) for s ≥ 1

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.01116v1-figure-b7503428-ed4f-4573-9570-c18c7fc79fb9.jpg)

| s   | 1   | 2     | 3        | 4       | 5        | 6         | 7          | 8         | 9          | 10        | 11      | 12       | 13       | 14     |   15 |
|-----|-----|-------|----------|---------|----------|-----------|------------|-----------|------------|-----------|---------|----------|----------|--------|------|
| P c | 1 8 | 1 60  | 1 140 13 | 3 910 1 | 1 546 23 | 1 728 355 | 1 1144 199 | 1 1287 62 | 1 1430 153 | 1 1144 31 | 1 728 3 | 3 1820 1 | 1 280 13 | 0      |    0 |
| P w | 1   | 13 30 | 70       | 10      | 364      | 8008      | 5720       | 2145      | 5720       | 1144      | 91      | 20       | 140      | 29 120 |    1 |

Our results in this paper. In this paper, we not only provide lower bounds for P c ( n, k, s ) and P w ( n, k, s ) for any values of n, k, s (summarized in Table 1.4), but also give exact values in the case of s = 2 in Theorem 4.3. For example, we will show that for k ≥ 3 and n ≥ 2,

$$P _ { w } ( n, k, 2 ) = \frac { 2 ( 2 k ^ { n } - 3 k + 1 ) } { k ^ { n - 1 } ( k ^ { n } - 1 ) }.$$

Weremark that some of our proofs require rather subtle considerations, which tend to be more difficult in the case of the binary alphabet.

Table 1.4: References for the lower bounds for P c ( n, k, s ) and P w ( n, k, s ). The gray cells refer to exact values.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.01116v1-figure-bf668acc-27db-41ed-8e0b-4bd77da5130b.jpg)

| ❍ ❍ ❍ ❍ ❍ k   | 2         | 3         | 4         | ≥ 5     |
|---------------|-----------|-----------|-----------|---------|
| 2             | Table 1.1 | Table 1.2 | Table 1.3 | Thm 3.1 |
| ≥ 3           | Thm 2.3   | Thm 2.1   | Thm 2.1   | Thm 2.1 |

Preliminaries. In this paper, B n,k ′ ( ) denotes the graph obtained from B n, k ( ) after removing s nodes, or s edges depending on the context.

A directed graph is strongly connected if there exits a directed path from any node to any other node. A directed graph is connected if for any pair of nodes a and b there exists a path in the underlying undirected graph. A trail in a directed graph G is a sequence v , . . . , v 1 t of nodes such that there is an edge v i → v i +1 for each 1 ≤ i ≤ t -1 and edges are not visited more than once. An Eularian trail in G is a trail that goes through each edge exactly once. A closed Eulerian trail is an Eulerian cycle . A directed graph is Eulerian (resp., semi-Eulerian ) if it has an Eulerian cycle (resp., Eulerian trail). Let d + ( v ) (resp., d -( v )) denote the out-degree (resp., in-degree) of a node v . The following result is well-known and is not hard to prove.

Theorem 1.1. A directed graph G is semi-Eulerian if and only if at most one vertex v has d + ( v ) -d -( v ) = 1 , at most one vertex u has d -( u ) -d + ( u ) = 1 , every other vertex w has d + ( w ) = d -( w ) , and G is connected. A graph is Eulerian if and only if it is balanced and (strongly) connected.

The line graph L G ( ) of a directed graph G is the directed graph whose vertex set corresponds to the edge set of G , and L G ( ) has an edge e →

v if in G , the head of e meets the tail of v . It is well-know, and is not difficult to show, that B n, k ( ) = L B n ( ( -1 , k )), and thus a Hamiltonian path (resp., cycle) in B n, k ( ) corresponds to an Eulerian trail (resp., cycle) in B n ( -1 , k ), and this property will be often used throughout this paper to show the existence of u-cycles and u-words.

Nodes of the form x n , as well as edges of the form x n → x n , are loops . Nodes of the form yx n -1 are out-special and nodes of the form x n -1 y are inspecial . Out-special and in-special nodes together are special . The following theorem will be used by us in the paper multiple times.

Theorem 1.2 ([1]) . Let u and v be two distinct non-loop nodes in B n, k ( ) . Then, there exist k distinct node-disjoint paths from u to v if and only if u is not out-special and v is not in-special.

Organization of the paper. In Sections 2 and 3 we provide the lower bounds for P c ( n, k, s ) and P w ( n, k, s ) in the cases of k ≥ 3 and k = 2, respectively. In Section 4 we give exact values of P c ( n, k, 2) and P w ( n, k, 2), and in Section 5 we provide some concluding remarks.

## 2 The case of the alphabet of size k ≥ 3

Let where the sum is taken over all s 1 +2 s 2 + · · · +( n -2) s n -2 = s with s i ≥ 0 and 1 ≤ i ≤ n -2. In the next theorem, we will obtain the following lower bounds for k ≥ 3 and n ≥ 3:

$$S ( k, s ) \coloneqq \sum \binom { k } { s _ { 1 } } \prod _ { i = 2 } ^ { n - 2 } \binom { ( i - 1 ) \binom { k } { 2 } } { s _ { i } } \\ \text{m is taken over all } s _ { 1 } + 2 s _ { 2 } + \cdots + ( n - 2 ) s _ { n - 2 } =$$

$$P _ { c } ( n, k, s ) & \geq \frac { S ( k, s ) } { \binom { k ^ { n } } { s } } \\ \frac { 1 } { \dots } \Big ( S ( k. s ) + \sum \alpha \Big ( k \Big ) \prod \alpha \Big ( k ^ { n - 2 } \Big ( ( i - 1 ) \binom { k } { 2 } } \Big )$$

where α = k n -s + s 1 -k +1 and the sum is taken over all s 1 +2 s 2 + · · · + ( n -2) s n -2 = s -1 with s i ≥ 0 and 1 ≤ i ≤ n -2. The case of n = 2 and k ≥ 3 will be considered in Theorem 2.3 below.

$$P _ { w } ( n, k, s ) & \geq \frac { 1 } { \binom { k ^ { n } } { s } } \left ( S ( k, s ) + \sum \alpha \binom { k } { s _ { 1 } } \prod _ { i = 2 } ^ { n - 2 } \binom { ( i - 1 ) \binom { k } { 2 } } { s _ { i } } \right ) \quad ( 2. 2 ) \\ & \text{where } \alpha = k ^ { n } - s + s _ { 1 } - k + 1 \text{ and the sum is taken over all } s _ { 1 } + 2 s _ { 2 } + \cdots + \\ & ( n - 2 ) s _ { n - 2 } = s - 1 \text{ with } s _ { i } \geq 0 \text{ and } 1 \leq i \leq n - 2. \text{   The case of } n = 2 \text{ and}$$

Theorem 2.1. For k, n ≥ 3 , the lower bounds in (2.1) and (2.2) hold.

Proof. Assume k ≥ 3. We observe that removing all i -cycles in B n ( -1 , k ), 1 ≤ i ≤ n -2, of the binary form, that is, involving only nodes x 1 · · · x n -1 for x j ∈ { x, y } for 1 ≤ j ≤ n and x, y ∈ { 1 , . . . , k } , results in a strongly connected and balanced graph B n ′ ( -1 , k ). Indeed, clearly B n ′ ( -1 , k ) is balanced. To justify that B n ′ ( -1 , k ) is strongly connected, we need to show that for any edge e = A → B belonging to a removed binary cycle, there is a directed path P AB from A to B which does not go through any other edge from the removed binary cycles. Then, in a path P XY in B n ( -1 , k ) from a node X to a node Y , we can replace any such e with P AB , so that it gives a path in B n ′ ( -1 , k ) from X to Y .

/negationslash

Suppose A = x 1 · · · x n -1 and B = x 2 · · · x n where all x j ∈ { x, y } for some x and y . Let z = x, y . Then, P AB is given by

$$A \to x _ { 2 } \cdots x _ { n - 1 } z \to x _ { 3 } \cdots x _ { n - 1 } z x _ { 2 } \to x _ { 4 } \cdots x _ { n - 1 } z x _ { 2 } x _ { 3 } \to \cdots \to B$$

since no of the edges in P AB belongs to an i -cycle for i &lt; n -1. So, B n ′ ( -1 , k ) is Eulerian, and thus its line graph B n,k ′ ( ) is Hamiltonian, and there exists a u-cycle corresponding to it.

To justify (2.1), we consider i -cycles, 2 ≤ i ≤ n -2, of the form

$$x ^ { m } y ^ { j } x ^ { m } y ^ { j } \dots \to x ^ { m - 1 } y ^ { j } x ^ { m } y ^ { j } \dots \to x ^ { m - 2 } y ^ { j } x ^ { m } y ^ { j } \dots \to \cdots$$

where x &lt; y , m + j = i and 1 ≤ m,j ≤ -i 1. Note that no two of such cycles can share an edge. Thus, we can remove in B n ( -1 , k ) s i such i -cycles for 1 ≤ i ≤ n -2 so that the total number of removed edges (corresponding to the total number of removed nodes in B n, k ( )) is s . Clearly, the number of such 1-cycles is k , and for i ≥ 2, the number of such i -cycles is ( i -1) k 2 .

( ) To justify (2.2) we note that if all of the s removed edges come from the binary cycles considered above, then the same lower bound as in (2.1) will be obtained. This bound, can be improved as follows. Begin with removing s -1 edges coming from the binary i -cycles as above, which will result in an Eulerian graph, so that we can remove any edge e in such a graph and obtain a semi-Eulerian graph corresponding to a u-word. To count the possibilities to remove such an e , we do not want e to be a loop, because this will result in some double counting. However, if e is not a loop, all the cases will be different from already considered cases, because before we were removing

entire i -cycles for some i . This explains the term α = k n -( s -1) -( k -s 1 ) in (2.2).

In the proof of the next theorem we need the following simple lemma. There, by a circular binary string we mean a number of digits 0 and 1 placed around a circle in positions labeled by 1 , 2 , . . . .

Lemma 2.2. For k ≥ 2 , the number of circular binary strings with i 1 s and k -i 0 s, 0 ≤ i ≤ k , in which no two 1 s stay next to each other is given by

$$\binom { k - i - 1 } { i - 1 } + \binom { k - i } { i }.$$

Proof. Let h k, i ( ) be the number of binary (non-circular) strings with i 1s in which no two 1s stay next to each other. Then, h k, i ( ) = ( k -i +1 i ) . Indeed, h k, i ( ) clearly counts placing i 1s in a binary string of length k -i +1 and then replacing each 1, but the rightmost 1, by 10. For the circular case, if 0 is in position 1, then we clearly have h k ( -1 , i ) such strings. On the other hand, if 1 is in position 1 in the circular case, then we have h k ( -3 , i -1) such strings since then positions k and 2 must be occupied by 0s. This completes the proof.

Theorem 2.3. Let n = 2 and k ≥ 3 , f ( k, s ) := ∑ k k ( -3) / 2 i =0 ( k k ( -3) 2 i )( k s -2 i ) ,

$$g ( k, s ) \coloneqq & \sum _ { i \geq 3 } ( i - 1 )! \left ( \binom { k - i - 1 } { i - 1 } + \binom { k - i } { i } \right ) \binom { k } { s - i }, \\ \nu \nu, \quad \nu, \quad \cdots \circ \nu, \quad \cdots, \quad \cdots, \quad \cdots,$$

U k, s ( ) := f ( k, s ) + 2 f ( k, s -k ) + g k, s ( ) + 2 g k, s ( -k ) and

$$V ( k, s ) \coloneqq k ( k - 3 ) \left ( \binom { k } { s - 1 } + 2 \binom { k } { s - k - 1 } \right ).$$

Then,

Also,

$$P _ { c } ( 2, k, s ) & \geq \frac { U ( k, s ) } { \binom { k ^ { 2 } } { s } }. & & ( 2. 3 ) \\ & \cdot \. &$$

$$P _ { w } ( 2, k, s ) & \geq \frac { U ( k, s ) + V ( k, s ) + 2 k \sum _ { j = 1 } ^ { k - 1 } ( f ( k, s - j ) + g ( k, s - j ) ) } { \binom { k ^ { 2 } } { s } } \quad ( 2. 4 ) \\ 7$$

Proof. Instead of removing s nodes in B (2 , k ), we consider removing s edges in B (1 , k ), whose nodes are k loops 1 , . . . k , and for every pair of nodes x and y , both x → y and y → x are present. We call a 2-cycle in B (1 , k ) special if it involves nodes x and x +1 for 1 ≤ x ≤ k -1, or 1 and k . Clearly, the number of non-special 2-cycles is k k ( -3) 2 .

To justify (2.3), note that removing all the edges in any i of non-special 2-cycles in B (1 , k ), and then removing s -2 i loops results in a balanced and strongly connected graph showing the existence of a u-cycle in this case. The number of ways to proceed in this way is clearly given by f ( k, s ). Moreover, we can proceed in the same way after first removing the k edges either from the cycle 1 → 2 → ·· · → k → 1, or from the cycle k → ( k -1) → ·· · → k → 1, which explains the term of 2 f ( k, s -k ).

To produce a more subtle estimate, we will be removing just a single i -cycle for a fixed i ≥ 3 from B (1 , k ), which is clearly not counted previously. The only condition on removing such an i -cycle is that it must not involved any of the edges in a special 2-cycle for us to guarantee strong connectivity of the obtained graph. The number of ways to selected i nodes to form such an i -cycle is given by Lemma 2.2, and since there are edges in both directions between any pair of selected nodes, there are ( i -1)! ways to choose a cycle on the chosen nodes. The remaining s -i edges to be removed after removing i -edges in an i -cycle can be chosen among the k loops. This explains the term of g k, s ( ). Finally, removing the k edges in either the cycle 1 → 2 → · · · → k → 1, or the cycle k → ( k -1) →··· → k → 1, and then removing an i -cycle as above results in a balanced and strongly connected graph, and explains the term 2 g k, s ( -k ). This completes justification of (2.3).

To justify (2.4), first note that all cases considered in proving (2.3) can be used in the case of u-words. To improve the bound, we note that a directed path (on distinct nodes) of length j , 1 ≤ j ≤ k -1, consisting of edges coming from special 2-cycles, can be removed, and then some other cycles can be removed as discussed in the case of u-cycles, which will result in a semi-Eulerian graph and thus corresponds to a u-word. There are 2 ways to pick the direction of such a path on special 2-cycles, and k ways to pick its start, justifying the term of 2 k ∑ k -1 j =1 ( f ( k, s -j ) + g k, s ( -j )). Finally, the following two options also result in semi-Eulerian graph not considered above:

- · remove any non-loop edge among the k k ( -3) edges coming not from

special 2-cycles, and the remaining edges can be removed from loops. This gives k k ( -3) ( k s -1 ) possibilities;

This explains the term of V ( k, s ) and completes the proof of (2.4).

- · remove the k edges in either the cycle 1 → 2 → ··· → k → 1, or the cycle k → ( k -1) → ··· → k → 1, and then remove one more non-loop edge among the k k ( -3) edges coming not from special 2cycles, and the remaining edges can be removed from loops, which gives 2 k k ( -3) ( k s - -k 1 ) possibilities.

## 3 The case of the alphabet size k = 2

Recall that in Tables 1.1, 1.2 and 1.3 we present the values of P c ( n, 2 , s ) and P w ( n, 2 , s ) for n = 2 3 4. , ,

Let where the sum is taken over all s 1 +2 s 2 +( n -1) s n -1 = s with 0 ≤ s 1 ≤ 2, 0 ≤ s 2 ≤ 1 and 0 ≤ s n -1 ≤ 2. Then, for k = 2 and n ≥ 5, we will show in the next theorem that

$$T ( n, s ) = \sum \binom { 2 } { s _ { 1 } } \binom { 1 } { s _ { 2 } } \binom { 1 } { s _ { n } } \\ \text{taken over all } s _ { 1 } + 2 s _ { 2 } + ( n - 1 ) s _ { n - 1 } = s$$

$$\text{hat} & P _ { c } ( n, 2, s ) \geq \frac { T ( n, s ) } { \binom { 2 ^ { n } } { s } }. & \quad \text{(3.1)} \\ s ) \geq \frac { T ( n, s ) + \sum ( 2 ^ { n } - s + s _ { 1 } - 1 ) \binom { 2 } { s _ { 1 } } \binom { 1 } { s _ { 2 } } \binom { 1 } { s _ { n } } } { \gamma ^ { n } \vee } & \quad \text{(3.2)}$$

where the sum is taken over all s 1 +2 s 2 +( n -1) s n -1 = s -1 with 0 ≤ s 1 ≤ 2, 0 ≤ s 2 ≤ 1 and 0 ≤ s n -1 ≤ 2.

$$P _ { w } ( n, 2, s ) \geq \frac { T ( n, s ) + \sum ( 2 ^ { n } - s + s _ { 1 } - 1 ) \binom { 2 } { s _ { 1 } } \binom { 1 } { s _ { n } } } { \binom { 2 ^ { n } } { s } } \quad \ ( 3. 2 ) \\ \text{where the sum is taken over all } s _ { 1 } + 2 s _ { 2 } + ( n - 1 ) s _ { n - 1 } = s - 1 \text{ with } 0 \leq s _ { 1 } \leq 2, \\ 0 < s, \, < 1 \text{ and } 0 < s _ { n - 1 } < 2.$$

Theorem 3.1. For n ≥ 5 , the lower bounds in (3.1) and (3.2) hold.

Proof. We have k = 2 and n ≥ 5. We observe that removing two loops, the 2-cycle, and the two ( n -1)-cycles of the form

$$x ^ { n - 2 } y \rightarrow x ^ { n - 3 } y x \rightarrow x ^ { n - 4 } y x ^ { 2 } \rightarrow \dots \rightarrow x y ^ { n - 2 } \rightarrow x ^ { n - 2 } y$$

in B n ( -1 , k ) results in a strongly connected and balanced graph B n ′ ( -1 , k ). Indeed, clearly B n ′ ( -1 , k ) is balanced. To justify that B n ′ ( -1 , k ) is strongly strongly connected, we need to show that for any edge e = A → B belonging to a removed cycle, there is a directed path P AB from A to B which does not go through any other edge from the removed cycles. Then, in a path P XY in B n ( -1 , k ) from a node X to a node Y we can replace any such e with P AB giving a path in B n ′ ( -1 , k ) from X to Y .We consider two cases.

Case 1. A = x yx i n - -i 2 and B = x i -1 yx n - -i 3 for 0 ≤ i ≤ n -2. If i = 0 then P AB = A → x n -1 → B . If i = 1 then P AB is given by

$$A \to y x ^ { n - 3 } y \to x ^ { n - 3 } y y \to \dots \to y ^ { n - 1 } \to y ^ { n - 2 } x \to y ^ { n - 3 } x ^ { 2 } \to \dots \to B.$$

If i = n -2, then P AB is given by

$$A \rightarrow x ^ { n - 3 } y y \rightarrow \dots \rightarrow y ^ { n - 1 } \rightarrow y ^ { n - 2 } x \rightarrow y ^ { n - 3 } x ^ { 2 } \rightarrow \dots \rightarrow B.$$

In all other cases, P AB is given by

$$A \rightarrow r ^ { i - 1 } u r ^ { n - i - 2 } u \rightarrow r ^ { i - 2 } u r ^ { n - i - 2 } u ^ { 2 } \rightarrow r ^ { i - 3 } u r ^ { n - i - 2 } u ^ { 2 } r \rightarrow$$

$$A \to x ^ { i - 1 } y x ^ { n - i - 2 } y \to x ^ { i - 2 } y x ^ { n - i - 2 } y ^ { 2 } \to x ^ { i - 3 } y x ^ { n - i - 2 } y ^ { 2 } x \to \\ x ^ { i - 4 } y x ^ { n - i - 2 } y ^ { 2 } x ^ { 2 } \to \dots \to y ^ { 2 } x ^ { i - 1 } y x ^ { n - i - 4 } \to y x ^ { i - 1 } y x ^ { n - i - 3 } \to B.$$

/negationslash

Case 2. A = x x 1 2 · · · xyxy and B = x 2 · · · yxyx are in the 2-cycle where x = y . Then, for even n , P AB is given by

$$A \to x _ { 2 } \dots y x y y \to x _ { 3 } \dots x y y x \to x _ { 4 } \dots y y x y \to x _ { 5 } \dots y x y x \to \dots \to B,$$

and for odd n , P AB is given by

$$A \to x _ { 2 } \dots y x y y \to x _ { 3 } \dots x y y x \to x _ { 4 } \dots y y x x \to x _ { 5 } \dots y x x y \to \\ x _ { 6 } \dots x x y x \to x _ { 7 } \dots x y x y \to \dots \to B.$$

So, B n ′ ( -1 , k ) is Eulerian, and thus its line graph B n,k ′ ( ) is Hamiltonian, and there exists a u-cycle corresponding to it.

To justify (3.1), we note that no two of the two loops, one 2-cycle and two ( n -1)-cycles considered above can share an edge. Thus, we can remove in B n ( -1 , k ) s i such i -cycles for i ∈ { 1 2 , , n - } 1 so that the total number of removed edges (corresponding to the total number of removed nodes in B n, k ( )) is s .

To justify (3.2) we note that if all of the s removed edges come from the cycles considered above, then the same lower bound as in (3.1) will be obtained. This bound, can be improved as follows. Begin with removing s -1 edges coming from the i -cycles as above, which will result in an Eulerian graph, so that we can remove any edge e in such a graph and obtain a semi-Eulerian graph corresponding to a u-word. To count the possibilities to remove such an e , we do not want e to be a loop, because this will result in some double counting. However, if e is not a loop, all the cases will be different from already considered cases, because before we were removing entire i -cycles for some i . This explains the factor of 2 n -( s -1) -(2 -s 1 ) in (3.2).

## 4 Exact values of Pc ( n, k, 2) and Pw n, k, ( 2)

Theorem 4.1. We have P c (2 , 2 2) = , 1 6 and for n ≥ 3 and k ≥ 2 ,

$$P _ { c } ( n, k, 2 ) = \frac { k ( k - 1 ) } { \binom { k ^ { n } } { 2 } }. \\ \vdots \text{removed in } B ( 2, 2 ), \text{the only } F$$

Proof. If two nodes are removed in B (2 , 2), the only possibility for the graph to stay Hamiltonian (and thus to correspond to a u-cycle) is if the removed nodes are loops, which explains that P c (2 , 2 2) = , 1 6 . On the other hand, if n ≥ 3 and k ≥ 2 then in order to obtain an Eulerian graph by removing two edges in B n ( -1 , k ) we must either remove two loops, or remove a 2cycle. Each of these gives ( ) k 2 possibilities thus explaining the formula for P c ( n, k, 2).

The proof of Theorem 4.3 relies on the following theorem, which looks like an intuitively true statement, but its proof is rather involved and requires consideration of many cases, and we were not able to find this result in the literature.

Theorem 4.2. Let e = a → b be an edge in B n, k ( ) . Then, there exists a Hamiltonian cycle in B n, k ( ) that goes through e , with the only exception when k = 2 , a is out-special and b is in-special.

Proof. If k = 2, a = yx n -1 and b = x n -1 y then no Hamiltonian cycle can cover the loop x n and go through e because the only edge coming to x n comes from a . This is not the case for k ≥ 3.

/negationslash

If either a or b is a loop x n , then the statement is true. Indeed, if k = 2 then there is only one edge coming in to x n , and one edge coming out of x n , so these edges will be part of any Hamiltonian cycle. On the other hand, if k ≥ 3, then suppose a = yx n -1 and b = x n ; the case when a = x n can be considered similarly. Since B n, k ( ) has a Hamiltonian cycle and the corresponding u-cycle U , it will go through an edge zx n -1 → x n , x = z . If y = z we are done. Otherwise, we can swap all y 's and z 's in U to obtain the desired Hamiltonian cycle from the new u-cycle.

Thus, we can assume that neither a nor b is a loop.

/negationslash

In what follows, we will use the following approach. We will be considering edges e 1 = A → B and e 2 = B → C in B n ( -1 , k ) corresponding to a and b , respectively. Next, we will demonstrate that after removing e 1 and e 2 (corresponding to removing a and b in B n, k ( )) the obtained graph B n ′ ( -1 , k ) remains connected. This is done via finding alternative directed paths P XY from X to Y , X = Y , where X,Y ∈ { A, B } or X,Y ∈ { B,C } . Together with the fact that B n ′ ( -1 , k ) is balanced if A = C , or otherwise A has one extra edge coming in, and C has one extra edge coming out, B n ′ ( -1 , k ) has an Eulerian trail corresponding to a Hamiltonian path in B n,k ′ ( ) obtained from B n, k ( ) after removing a and b . Such a Hamiltonian path can clearly be extended to a Hamiltonian cycle in B n, k ( ) by adding back the removed edge e .

Suppose that n = 3. If k = 2 then we have 8 possibilities for e (loops are not involved, and we cannot have a be out-special and b be in-special). Each of the 8 possible choices of e can be found in one of the following two Hamiltonian cycles in B (3 , 2) giving the desired result:

100 → 000 → 001 → 010 → 101 → 011 → 111 → 110 → 100

$$0 0 1 \rightarrow 0 1 1 \rightarrow 1 1 1 \rightarrow 1 1 0 \rightarrow 1 0 1 \rightarrow 0 1 0 \rightarrow 1 0 0 \rightarrow 0 0 0 \rightarrow 0 0 1$$

/negationslash

Thus we can assume k ≥ 3. Let a = xyz and b = yzh . Then A = xy , B = yz and C = zh . Letting t = x, z we see that P AB = A → yt → ty → B if ty = yz , or else P AB = A → yt → B . P BC is found in the same way.

/negationslash

In what follows, we assume that n ≥ 4 (and a and b are not loops).

/negationslash

If A = C then A, B, C form a 2-cycle, and for n ≥ 3 none of these vertices is special. Thus, P AB and P BC exist by Theorem 1.2. So, we can assume that A = C .

Suppose that one of A B , , or C is a loop.

/negationslash

Case 1. A = x n -1 is a loop, B = x n -2 y , C = x n -3 yz , and y = x . P BC exist by Theorem 1.2, and for k ≥ 3, P AB is given by

$$A = x ^ { n - 1 } \rightarrow x ^ { n - 2 } t \rightarrow x ^ { n - 3 } t x \rightarrow x ^ { n - 4 } t x ^ { 2 } \rightarrow \cdots \rightarrow t x ^ { n - 2 } \rightarrow B = x ^ { n - 2 } y$$

/negationslash where t = y, x . For k = 2, we note that P AB does not exist in this case. However, it is sufficient for us to prove that there exists P BA that does not use the edge e 2 ( e 1 clearly will not be used). Such a path is given by

$$B = x ^ { n - 2 } y \rightarrow x ^ { n - 3 } y \bar { z } \rightarrow x ^ { n - 4 } y \bar { z } x \rightarrow x ^ { n - 4 } y \bar { z } x ^ { 2 } \rightarrow \cdots \rightarrow A = x ^ { n - 1 }$$

where ¯ denotes the letter distinct from z z . In the case z = x the path above has one extra step than otherwise.

/negationslash

Case 2. B = y n -1 is a loop, A = xy n -2 , C = y n -2 z , y = x , and z = y . For k ≥ 3, P BC is essentially P AB in Case 1, and P AB is given by

/negationslash

$$A = x y ^ { n - 2 } \rightarrow y ^ { n - 2 } t \rightarrow y ^ { n - 3 } t y \rightarrow y ^ { n - 4 } t y ^ { 2 } \rightarrow \dots \rightarrow t y ^ { n - 2 } \rightarrow B = y ^ { n - 1 }$$

/negationslash where t = y, x . The case k = 2 corresponds to a being out-special, and b being in-special, and it is the exception in the statement of the theorem (the loop B becomes non-reachable from any other node).

/negationslash

Case 3. C = z n -1 is a loop, A = xyz n -3 , B = yz n -2 , and y = z . P AB exist by Theorem 1.2, and for k ≥ 3 P BC is given by

$$B = y z ^ { n - 2 } \rightarrow z ^ { n - 2 } t \rightarrow z ^ { n - 3 } t z \rightarrow z ^ { n - 4 } t z ^ { 2 } \rightarrow \dots \rightarrow t z ^ { n - 2 } \rightarrow C = z ^ { n - 1 }$$

/negationslash where t = y, x . Similarly to Case 1, for k = 2, P BC does not exist, but we can find P CB not using e 1 and e 2 :

$$C = z ^ { n - 1 } \rightarrow z ^ { n - 2 } \bar { x } \rightarrow z ^ { n - 3 } \bar { x } y \rightarrow z ^ { n - 4 } \bar { x } y z \rightarrow z ^ { n - 5 } \bar { x } y z ^ { 2 } \rightarrow \dots \rightarrow B = y z ^ { n - 2 }$$

where ¯ is the letter different from x x so the last step is not the edge e 1 .

Thus, we can assume that none of A B , , or C is a loop. Moreover, we only need to consider the following two cases, because otherwise, P AB and P BC are given by Theorem 1.2.

/negationslash

Case i. A = yx n -2 is out-special and B = x n -2 z is in-special, where x = y, z . In this case, P AB = yx n -2 → x n -1 → B = x n -2 z .

/negationslash

Case ii. B = yx n -2 is out-special and C = x n -2 z is in-special, where x = y, z . This is essentially Case i.

Theorem 4.3. We have P w (2 , 2 2) = , 5 6 and for n ≥ 3 ,

$$P _ { w } ( n, 2, 2 ) = \frac { 2 ^ { n } - 3 } { ( 2 ^ { n } - 1 ) 2 ^ { n - 3 } }$$

Moreover, for k ≥ 3 and n ≥ 2 , we have

$$P _ { w } ( n, k, 2 ) = \frac { 2 ( 2 k ^ { n } - 3 k + 1 ) } { k ^ { n - 1 } ( k ^ { n } - 1 ) }.$$

Proof. If n = 2 and k = 2, then it is easy to see that the graph obtained from B (2 , 2) by removing two nodes has a Hamiltonian path unless the removed nodes are 01 and 10. This gives P w (2 , 2 2) = , 5 6 .

So, we can assume that either n ≥ 3 and k ≥ 2 or n ≥ 2 and k ≥ 3.

Let a and b be the nodes in B n, k ( ) corresponding to the removed words of length n over k -letter alphabet. Note that B n ′ ( -1 , k ) is semi-Eulerian (in particular, respecting the conditions on in-degrees and out-degrees) if and only if

- · either a or b is a loop, in which case clearly a Hamiltonian path in B n,k ′ ( ) exists, or
- · a → b (or b → a ) is an edge in B n, k ( ), in which case a Hamiltonian path in B n,k ′ ( ) exists by Theorem 4.2 with one exception.

Thus, exactly one of the following four cases of choosing a can occur in order for B n,k ′ ( ) to have a Hamiltonian path.

Case 1. a is a loop, in which case b can be any node. Clearly, there are k k ( n -1) ways to choose such a and b .

/negationslash

/negationslash

Case 2. (i) a = xyxy · · · x or (ii) a = xyxy · · · y . b can only be of the form, in case (i) tt · · · t or yxyx · · · y or zxyxy · · · y or yxyx · · · xz where z = y , and in case (ii) tt · · · t or yxyx · · · y or zxyxy · · · x or yxyx · · · yz where z = y .

In either case, b can be chosen in k + 1 + ( k -1) + ( k -1) = 3 k -1 ways depending on the respective choices of t and z . There are k k ( -1) choices to pick a giving in total for this case k k ( -1)(3 k -1) possibilities.

Case 3. a = yx n -1 is out-special or a = x n -1 y is in-special. In either case, b can be either a loop, or the other end point of an edge coming into a or going out of a . There are k loops, k edges coming in, and k edges coming out of a , but one of these edges is connected to a loop. Thus, in this case we have 3 k -1 choices for b , and in total 2 k k ( -1)(3 k -1) possibilities (2 corresponds to the choices of being out-special or in-special). However, the last formular only works for k ≥ 3, because when k = 2, we cannot remove a and b connected by an edge, when both of them are special (in this case a loop becomes isolated). So, if k = 2 we have 2 k k ( -1)(3 k -1 -1) = 16 possibilities.

Case 4. In all other cases of a , b can be any of 2 k nodes connected to a by an edge, or any of k loops. So, we have

$$3 k ( k ^ { n } - k - k ( k - 1 ) - 2 k ( k - 1 ) ) = 3 k ( k ^ { n } - 3 k ^ { 2 } + 2 k )$$

possibilities.

Since every pair ( a, b ) appears twice in our arguments, Cases 1-4 give

$$P _ { w } ( n, 2, 2 ) = \frac { 2 ( 2 ^ { n } - 1 ) + 1 0 + 1 6 + 6 ( 2 ^ { n } - 8 ) } { ( 2 ^ { n } - 1 ) 2 ^ { n } }$$

and for k ≥ 3, P w ( n, k, 2) =

$$\frac { k ( k ^ { n } - 1 ) + k ( k - 1 ) ( 3 k - 1 ) + 2 k ( k - 1 ) ( 3 k - 1 ) + 3 k ( k ^ { n } - 3 k ^ { 2 } + 2 k ) } { ( k ^ { n } - 1 ) k ^ { n } }.$$

## 5 Directions of further research

A universal cycle (or a universal word) for an arbitrary set S is a cyclic sequence (or a non-circular sequence) whose substrings of length n encode | S | distinct instances in S . U-cycles and u-words have been studied for a

wide variety of combinatorial objects including permutations [9, 10], partitions [3], subsets [8], multisets [6], labeled graphs [2], various functions and passwords; for more information, the reader is referred to [12]. There are much study on universal cycles or universal words because of their applications including dynamic connections in overlay networks [11], genomics [13], software calculation of the ruler function in computer words [12], etc. An interesting direction of research would be extending our studies of P c ( n, k, s ) and P w ( n, k, s ) to other combinatorial structures. Also, it would be interesting to explore new methods to compute the exact values of P c ( n, k, s ) and P w ( n, k, s ). Finally, our bounds for the general case presented in (2.1) and (2.2) can be improved by conducting a more subtle analysis of the removed cycles in the proof of Theorem 2.1, and exploring how far the improvement could go is another interesting direction.

## Acknowledgements

The first author was supported by the Fundamental Research Funds for the Central Universities, Nankai University (Grant Nnumber 63191349). The third author was partially supported by the National Natural Science Foundation of China (Grant Numbers 11701491, 11726629 and 11726630) and the China Postdoctoral Science Foundation (Grant Number 2017M621188).

## References

- [1] M. Baumslag. An algebraic analysis of the connectivity of DeBruijn and shuffle-exchange digraphs. Discrete Appl. Math. 61 (1995), no. 3, 213227.
- [2] G. Brockman, B. Kay and E. Snively. On universal cycles of labeled graphs. Electron. J. Combin. 17 (2010), no. 1, 1-9.
- [3] Karel Casteels and Brett Stevens. Universal cycles of ( n -1)-partitions of an n -set. Discrete Math. 309 (2009), no. 17, 5332-5340.
- [4] F. Chung, P. W. Diaconis and R. L. Graham. Universal cycles for combinatorial structures. Discrete Math. 110 (1992), no. 1-3, 43-59.

- [5] K. B. Gardner and A. Godbole. Universal cycles of restricted words. J. Combin. Math. Combin. Comput. 106 (2018), 153-173.
- [6] Glenn Hurlbert, Tobias Johnson and Joshua Zahl. On universal cycles for multisets. Discrete Math. 309 (2009), no. 17, 5321-5327.
- [7] E. Moreno. De Bruijn sequences and De Bruijn graphs for a general language. Inform. Process. Lett. 96 (2005), no. 6, 214-219.
- [8] B. Jackson. Universal cycles of k -subsets and k -permutations. Discrete Math. 117 (1993), 114-150.
- [9] J. R. Johnson. Universal cycles for permutations. Discrete Math. 309 (2009), no. 17, 5264-5270.
- [10] S. Kitaev, V. N. Potapov and V. Vajnovszki. On shortening u-cycles and u-words for permutations. Discrete Appl. Math. , in press, 2019.
- [11] M. A. Sridhar and C. S. Raghavendra. Fault-tolerant networks based on the de Bruijn graph. IEEE Trans. Computers 40 (1991), no. 10, 1167-1174.
- [12] D. Wong. Novel universal cycle constructions for a variety of combinatorial objects (Ph.D. thesis). University of Guelph, Canada (2015).
- [13] D. Zerbino and E. Birney. Velvet: algorithms for de novo short read assembly using de Bruijn graphs. Genome Res. 18 (2008), no. 5, 821829.
Herman Z. Q. Chen Sergey Kitaev Brian Y. Sun
On the probability of existence of a universal cycle or a universal word for a set of words
A universal cycle, or u-cycle, for a given set of words is a circular word
that contains each word from the set exactly once as a contiguous subword. The
celebrated de Bruijn sequences are a particular case of such a u-cycle, where a
set in question is the set $A^n$ of all words of length $n$ over a $k$-letter
alphabet $A$. A universal word, or u-word, is a linear, i.e. non-circular,
version of the notion of a u-cycle, and it is defined similarly.
  Removing some words in $A^n$ may, or may not, result in a set of words for
which u-cycle, or u-word, exists. The goal of this paper is to study the
probability of existence of the universal objects in such a situation. We give
lower bounds for the probability in general cases, and also derive explicit
answers for the case of removing up to two words in $A^n$, or the case when
$k=2$ and $n\leq 4$.