 # Triangle-creation processes on cubic graphs

An edge switch is an operation which makes a local change in a graph while maintaining the degree of every vertex. We introduce a switch move, called a triangle switch, which creates or deletes at least one triangle. Specifically, a make move is a triangle switch which chooses a path zwvxy of length 4 and replaces it by a triangle vxwv and an edge yz, while a break move performs the reverse operation. We consider various Markov chains which perform random triangle switches, and assume that every possible make or break move has positive probability of being performed. Our first result is that any such Markov chain is irreducible on the set of all 3-regular graphs with vertex set {1,2,..., n}. For a particular, natural Markov chain of this type, we obtain a non-trivial linear upper and lower bounds on the number of triangles in the long run. These bounds are almost surely obtained in linear time, irrespective of the starting graph.

## Authors

##### 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

In the applied field of social networks, the existence of triangles is seen as an indicator of mutual friendships [5, 6]. However, many random graph models, or processes for producing random graphs, tend to produce graphs with few triangles. We introduce and analyse random processes based on Markov chains, which are designed to favour graphs with many triangles. We restrict our attention to cubic (3-regular) graphs, as the questions we seek to answer are already challenging in this setting.

Let be the set of simple 3-regular graphs on the vertex set . Assume that and that is even, as otherwise . A random 3-regular graph on vertices is a graph sampled uniformly at random (u.a.r.) from . The number of cycles of length in a random 3-regular graph is asymptotically Poisson with expected value , see for example Bollobás . A triangle is a 3-cycle, and the expected number of triangles in a random 3-regular graph is asymptotically equal to . We are interested in random processes which produce graphs that contain many more triangles than we would expect from sampling uniformly at random.

Of course, some elements of contain many more triangles than the average. For example, suppose that and let be the set of all graphs consisting of components, each of which is isomorphic to . Then every graph in has triangles, and this is the largest possible number of triangles in a 3-regular graph on vertices. Note that, while any two graphs in are isomorphic, we have

 |Kn|=n!(4!)n/4∼√2πn(ne(24)1/4)n>(n/7)n.

But is an exponentially small proportion of since

 |Gn|∼√2e−2(31/2n3/22e3/2)n

(see ). Therefore, when sampling from uniformly at random, we are exponentially unlikely to see a graph from .

Since the introduction of the random graph models by Erdős and Rényi , and by Gilbert , there has been an ongoing study of models of random graphs and their properties by many authors. Generally speaking, the graph properties follow naturally as a consequence of the generative model, or are introduced artificially into the generative process.

One straightforward but artificial way to generate 3-regular graphs with a fixed number of triangles is as follows. Starting with an -vertex 3-regular graph, choose a random subset of vertices, and replace each of these vertices with a triangle. This gives a 3-regular graph on vertices with approximately triangles.

A more natural method to generate regular graphs with a large number of triangles is to use local transformations. The method of local transformations makes modifications of the graph structure to alter the density of triangles in the long run. If valid transformations are accepted with variable probabilities, this is often called Metropolis sampling.

An established approach to the uniform generation of regular graphs is using local edge transformations known as switches (see for example [2, 8, 9]). A pair of edges , of graph are chosen u.a.r. and replaced with a uniformly chosen perfect matching of the vertices . If the resulting graph is not simple then the move is rejected. See Fig. 1.

Here we use the notation as a shorthand for the edge . On some occasions it is convenient to temporarily assign an orientation to an edge: in these situations, will denote the oriented edge .

If we restrict to a subset of switches, we can ensure that every switch will change the set of triangles in the graph. Fig. 2 illustrates a triangle switch which can be used to make or break triangles.

Suppose that the 4-path is present in the graph and the edges , are absent. Then the make triangle move consists of deleting the edges , and replacing them with edges , , forming the triangle . The make triangle move is illustrated in Fig. 2, reading from left to right. We denote this operation by . As the make move depends only on the 4-path and not its orientation, we treat and as the same make move.

Next, suppose that the triangle and disjoint edge are present in the graph, and edges , are absent. Here we treat both the edge of the triangle and the disjoint edge as oriented edges. The break triangle move deletes the edges , and replaces them with the edges , . This destroys the triangle , but may create other triangles. The break triangle move is illustrated in Fig. 2, reading from right to left. We denote this operation by . Again, by symmetry we will treat and as the same break move.

As we require the resulting graph to be simple, we will reject any make or break move which would create a repeated edge or where the vertices are not distinct. If a move is rejected then no change is made at that step.

A Markov chain on is called a triangle switch chain if its transition matrix satisfies whenever and differ by a single (make or break) triangle switch. Two general types of Markov chains based on triangle switches are as follows at each step.

• With probability choose a make move, else (with probability ) choose a break move. Carry out a u.a.r. move of the chosen type.

• Sample a vertex and two neighbours . If there is no edge then with probability perform a make move. If the edge is present then with probability perform a break move.

In this paper we prove that switch processes which allow all moves of the type shown in Fig. 2 are irreducible on the set of simple 3-regular graphs

, and estimate (for two particular triangle switch chains) the density of triangles produced in relation to the proportion of make moves.

Whether or not a Markov chain is irreducible depends only on the set of transitions which have nonzero probability, and not on the values of these probabilities. So, in fact, the irreducibility of these chains is independent of exactly how make moves and break moves are chosen, provided all valid moves at any vertex can occur with nonzero probability. Thus a proof of irreducibility for either of the above chains extends to the other, and to all similar chains we might devise.

Our first result, stated below, is proved in Section 2.

###### Theorem 1.

Any triangle switch chain on the space of simple 3-regular graphs is irreducible.

### 1.1 A variety of chains and an alternative Metropolis process

Given a graph , a vertex (of degree at least two) defines a set of triples consisting of paths of length two, where are distinct neighbours of (). Let be the set of all such triples in . Let be the set of those triples for which . Each such triple is a potential site for a make move, as illustrated on the left of Fig. 2. Next let be the set of all triples for which . Each triple in is a potential site for a break move, as illustrated on the right of Fig. 2.

As mentioned previously, there are several ways to design a Markov chain based on triangle switches. The first approach is to decide the type of move (make/break) and then sample from the available moves of that type. One such chain is described below.

Chain O. Repeat for steps: With probability , XX sample a triple u.a.r. from , XX choose and u.a.r., XX perform if valid; otherwise (with probability ), XX sample a triple u.a.r. from , XX choose an oriented edge u.a.r., XX perform if valid.

In Chain O, at each step the probability of attempting a make move is , and the probability of attempting a break move is , regardless of the number of triangles which contain the vertex . Chain O is a time-reversible Markov chain which is somewhat like a biased random walk on the number of triangles. This analogy is not exactly correct, as proposed moves may be invalid, or may add or remove more than one triangle in some cases.

To implement Chain O efficiently we can proceed as follows. For the initial graph , form the sets , in time. After each transition of the chain, update these sets in time. The running time of Chain O is then determined mainly by the number of steps .

An alternative approach is to first choose a vertex, and then choose a move at that vertex in some way. We study two chains with this structure. In the first chain, the probability of a move depends only on its type (make/break), while in the second chain these probabilities depend on the number of triangles in the neighbourhood of the chosen vertex.

Chain I. Choose u.a.r. a vertex

and an ordered pair of distinct edges

. Depending on the presence (or absence) of the edge , choose a break move with probability (resp. a make move with probability ). This chain is defined in more detail in Section 3, see Fig. 18. Chain II. Choose a vertex u.a.r. and let be the number of triangles at . Choose a break move with probability , or a make move otherwise. Moves are chosen u.a.r. from among the valid moves of that type at vertex . See Section 3.1, Fig. 19 for more detail.

Chain II differs from Chain I in that (i) in Chain I the existence of the edge determines the move type, and (ii) Chain II always attempts to perform a move of the chosen type, whereas Chain I only attempts to perform the chosen move with probability or . It follows from the proof of Theorem 1 (see Lemma 1) that, given a vertex which is not in a , there is always a valid make move at which inserts a triangle at . (However, the same move may break some other triangle at .)

We say that an event occurs in the long run, if there exists a positive constant such that for all , the number of steps at which does not hold is almost surely. For Chain II, we give bounds on the long run number of triangles. The following theorem is proved in Section 3.1.

###### Theorem 2.

Let and . There exists a positive constant such that the following statements hold for 3-regular graphs sampled from Chain II.

1. After steps of Chain II, w.h.p. the number of triangles in the current graph is at least , and at most independent of the starting graph .

2. The long run number of triangles is at least , and at most .

Adapting the proof of Theorem 2 we obtain the following corollary.

###### Corollary 1.

The long run number of triangles in Chain I is at least .

The three chains introduced in this section are all reversible, and are irreducible by Theorem 1. Chains O and I are aperiodic, assuming that the probabilities , and the implementation of Chain II described in Section 3.1 is also aperiodic. Therefore, each of these chains has a unique stationary distribution on . In principle by varying we can to use Chain O or Chain I to sample 3-regular graphs with (approximately) a specified number of triangles, with reasonable accuracy. We now discuss this further for Chain I.

Denote the stationary probabilities of and by , , respectively. We claim that the implementation of Chain I described in Section 3 satisfies the following detailed balance equations:

 p12n{\bf Pr}(G)=q9n2{\bf Pr}(G′). (1)

First suppose that the graph can be obtained from the graph only by performing (recalling that we treat this move and its mirror image, , as the same make move). There are ways of choosing the (unoriented) path for a make move, and ways of choosing the oriented path (around a triangle) and oriented edge for a break move, but then we must divide by 2 as and give the same break move. So there are distinct ways to choose a break move. It follows that (1) holds in this case.

If the transition from to can arise from more than one make move then (1) still holds. For example, suppose that contains a 6-cycle . Then the transition from to arises in two distinct ways, as and as (again, identifying each path with its mirror image). Similarly, the reverse transition from to arises in two ways, as and as . See also Fig. 3, giving a situation in which the transition from to arises in four ways. A final possibility is that to can arise from three distinct make moves (similar to Fig. 3 but with edge absent, for example).

In Chain I, if and is close to zero then break moves will dominate. The resulting stationary distribution will favour graphs with few triangles. In particular, when we have . Hence, when and , Chain I simply generates random 3-regular graphs, which have triangles. On the other hand, if is close to one then make moves will dominate, so the stationary distribution will favour graphs with many triangles.

#### 1.1.1 An alternative Metropolis process

Consider next another natural process based on switches. Fix a parameter and let denote the number of triangles in a graph . We choose a switch at random, as in the algorithm of . If the proposed transition is from the current graph to then the move is accepted with probability , and otherwise we stay at . Note that , with an extreme configuration depicted in Fig. 3. Hence the expression belongs to , so it is indeed a probability.

This is a Metropolis process with detailed balance equations

 qΔ(G)−Δ(G′)+4{\bf Pr}(G)=qΔ(G′)−Δ(G)+4{\bf Pr}(G′).

Letting , these equations have solution . Therefore, graphs with many triangles are more likely in the stationary distribution than those with few. It might be possible to show that this chain is rapidly mixing for small values of by modifying the methods of .

However, this chain is likely to be very slow, especially if is chosen so that graphs with linearly many triangles have high stationary probability. For this reason, we prefer to work with Chains O, I and II, which can produce graphs with triangles in time. However, we are unable to determine the exact stationary distribution, or bound the mixing time, of these chains.

The structure of the paper is as follows. In Section 2, we establish the irreducibility of the triangle switch chain, proving Theorem 1. In Section 3.1 we give a detailed definition of Chains I and II. We also prove Theorem 2, giving bounds on the long run expected number of triangles generated by Chain II, and use these bounds to prove Corollary 1 for Chain I.

We refer to the following three induced subgraphs throughout our proofs. Many of our arguments are based on analysis of how the triangle switch creates and destroys these induced substructures.

## 2 Irreducibility

Let be the graph with vertex set and with edges defined as follows: are joined by an edge if there is a make move or break move which takes to . Then is an undirected graph, which is the transition graph of any triangle switch chain . To show that is irreducible, we need to show that is a connected graph.

More generally, given any , let be the vertex-induced subgraph of induced by the set .

For now, we consider the case . First we will prove that there is a path from any to a graph , where is the class of labelled graphs consisting of disjoint copies of . We may assume that , since otherwise is already a . Then we will show that any two graphs in are connected by a path in , completing the proof when . Finally, we will show how to modify the proof for the remaining case .

###### Theorem 3.

If then there is a path in from any to some .

We will prove this using a sequence of lemmas which show that the process can always increase the number of triangles at some vertex, so long as a component remains which is not isomorphic to .

###### Lemma 1.

Let . If has no triangle in its neighbourhood then there is an adjacent in which has a triangle in the neighbourhood of .

###### Proof.

The situation is depicted in Fig. 5(a). The vertices must be distinct, with no edges between , since is not in a triangle. The vertices must be distinct from , but not necessarily from each other, and from , since is not in a triangle. Note also that since is a simple graph, the pair must be distinct, and similarly the pair and the pair .

We use the notation to indicate that vertices and coincide (that is, ). The following cases concern the extent to which vertices coincide. For clarity, when describing an edge or path involving a vertex of the form , we will put parentheses around this vertex.

Vertex is treated as a distinguished vertex. We separate out various cases to examine the effect of identification of vertices in . In each case, if is triangle-free then we can insert at least one of the edges . The following cases are exhaustive, as all others are excluded by 3-regularity.

1. [itemsep=0pt,topsep=0pt,label=()]

2. None of coincide. See Fig. 5(a). Consider any 2-path from , say . There are four possible make moves involving , using the 2-paths , , and . Each of these will be a valid make move, unless the edge , , or , respectively, is present. But only two of these edges can be present, or would have degree greater than 3. Thus there is at least one valid make move producing a triangle involving . See Fig. 5(a), where the edges , are present.

3. Exactly one pair of vertices coincide. Suppose that coincide and that the three vertices , and are distinct. As there are at most two edges from to these vertices, we can find at least two valid make moves. See Fig. 5(b) with identified, and edges present. Then or gives a valid make move.

4. Exactly two pairs of vertices coincide. Suppose, without loss of generality, that and coincide and that and coincide. Then either of or will give a valid make move, unless both and are neighbours of , as in Fig. 5(c). But in this case we can use vertex and perform or .

5. Three pairs of vertices coincide. Suppose, without loss of generality, that and coincide, and coincide and and coincide. As there can be at most one extra edge incident with , from to for example, we can perform at least one of or . See Fig. 5(d).

6. Three vertices all coincide. Suppose , and denote this vertex as . Because are all neighbours of there can be no edge from to any of and we can use paths such as or . See Fig. 5(e). ∎

###### Lemma 2.

Suppose that form a triangle in a component of order at least 8 in . Then there is a vertex such that induce a diamond in a graph which is at distance at most two from in .

###### Proof.

If induce a diamond for some vertex then we are done. So we may assume that the triangle is not contained in a diamond. The situation is depicted in Fig. 6(a). Vertices must be distinct, since otherwise there is already a diamond or is not a simple graph. For the same reasons, there can be no edges between and .

Since is 3-regular and has at least 8 vertices, at least one of must be adjacent to a vertex . By symmetry, we may assume that is adjacent to .

Now is a make move which creates a diamond with , and is valid unless the edge is present. So we will assume that the edge is present for the remainder of the proof. Similarly, the make move is a make move which creates a diamond with , and is valid unless the edge is present. Again we will assume that the edge is present, so the situation is now as depicted in Fig. 6(b).

Since is 3-regular, requires exactly one more neighbour. We consider two cases: in the first case, is adjacent to or (but not both, as then would have degree 4), while in the second case, is adjacent to a vertex .

In the first case we may assume that is adjacent to , by symmetry. Now must be adjacent to a vertex , or some vertex would have degree at least 4. For the same reason, cannot be adjacent to any vertex in . But now gives a valid make move, creating a diamond with . See Fig. 6(c).

It remains to consider the second case, namely that is adjacent to a vertex . Now is a make move which creates a diamond on and is valid unless the edge is present. So we will assume that the edge is present. Similarly, the make move creates a diamond on , and is valid unless the edge is present. So again we will assume that the edge is present, giving the situation is shown in Fig. 6(d). Since every vertex in this figure has degree 3, the subgraph shown is a connected component of with 8 vertices. There is no make move which will create a diamond in in one step, so we will require two steps.

First, redraw Fig. 6(d) as in Fig. 7(a) below. A make move on gives Fig. 7(b), and then a make move on gives Fig. 7(c),which has a diamond on . ∎

Now we have reduced the connectivity question to graphs containing at least one diamond. We show that any diamond can be transformed to a in at most two steps.

###### Lemma 3.

If vertices span a diamond in then is connected in to a graph such that induce a component. The path from to in has length at most two.

###### Proof.

The situation is depicted in Fig. 8. Vertices must be adjacent to some vertex not in the diamond, since otherwise either is already a or some vertex does not have degree 3. There are two cases, shown in Fig. 8. In case (a), the final neighbour of is and the final neighbour of is , where . Whether or not is an edge, must have another neighbour . For the same reason, must be adjacent to some vertex (regardless of whether the edge is present). So the situation is as depicted in Fig. 8(a). In case (b), both and are adjacent to the same vertex . Now must be adjacent to some vertex , by 3-regularity. Similarly, must be adjacent to some vertex , and must be adjacent to some vertex . So the situation is as depicted in Fig. 8(b).

First consider case (a). The operation will insert edges , and delete edges , . Then will induce a component. The make move will be valid provided that . So we will assume that the edge is present. See Fig. 9(i). Now a make move using will insert edges , and delete edges , . This move will be valid unless , since or could not have degree 3. If then the make move will give the graph in Fig. 9(ii). Now the make move using will insert , and delete , . This is valid, since or else could not have degree 3. After these operations, vertices induce a component.

Now suppose that , as in Fig. 10(i). Then must be adjacent to some vertex , or could not be 3-regular. The make move using will insert , and delete , . This move is valid, since 3-regularity implies that , and produces the graph shown in Fig. 10(ii).

Now the make move using will insert and delete . This move will be valid since ,or would not have degree 3. Then will again induce a component.

Finally, consider case (b), shown in Fig. 11(i). The make move using will insert , and delete . This move is valid, since by 3-regularity. The make move gives the graph in Fig. 11(ii).

Now the make move using will insert and delete . This move will be valid since ,or would not have degree 3. Then will again induce a component. ∎

We can now complete the proof of Theorem 3.

###### Proof of Theorem 3.

Suppose that . The procedure implied by Lemmas 13 shows that, for any with a component of order at least 8, there is a path of length at most 4 in from to a graph having a component isomorphic to . Applying this inductively to must result in a graph which has components only of order 4 or 6. Suppose there are two components of order 6, as shown in Fig. 12(a) below. Perform the break move , leading to Fig. 12(b). Now we can perform the make move to create a diamond on vertices . Note that we have created a diamond in two moves, in agreement with Lemma 2. The remaining 8 vertices form a component of the type shown in Fig. 7(b). A further make move gives a component with a diamond, as shown in Fig. 7(c). We can then use Lemma 3 to create a .

The final configuration must consist of components isomorphic to and a residual component of order . But is the only 3-regular labelled graph on 4 vertices, so consists of components, each of which is a . ∎

### Proof of Theorem 1

In order to establish that any triangle switch chain is irreducible, it remains to prove that any two graphs in are connected by a path in .

###### Theorem 4.

If then any two graphs in are connected by a path in .

###### Proof.

Suppose that are any two graphs in . Let have components and have components . If and are two components of then we can exchange any pair of vertices , using the following moves.

The break move deletes the edges , and inserts the edges . See Fig. 13(ii). Next, the make move deletes the edges and inserts the edges . The resulting graph is shown in Fig. 13(iii). Finally, the make move deletes the edges , and inserts the edges , , leading to the graph shown in Fig. 13(iv). Observe that and have been exchanged between the two ’s, and that by symmetry, any chosen pair of vertices could be exchanged in this way.

We can use this procedure to transform to so that its first component is . We simply locate the (at most four) components of which contain the vertices in , and switch these vertices into . Then we apply the same argument inductively to the graphs and . This gives a recursive construction for a path from to in . ∎

This gives the required result.

###### Theorem 5.

If then is connected.

###### Proof.

This follows directly from Theorems 3 and 4. ∎

We must now consider the case . Necessarily, , or there are no 3-regular simple graphs with vertices. We redefine to be be the class of labelled graphs comprising components isomorphic to and one component of order 6. Thus we must consider . Unlike , this is not a single graph. In fact, it contains two non-isomorphic graphs, the complete bipartite graph , and the triangular prism, . The graph is the complement of a 6-cycle, hence the notation.

In fact, there are 10 different labellings for and 60 for , so , though we will not need these numbers. But we need to show that is connected. Let be the set of labelled graphs in which are isomorphic to , and let be the set which are isomorphic to . First we show

###### Lemma 4.

Every graph in is adjacent in to a graph in .

###### Proof.

The graph in Fig. 15(i) belongs to . In this graph, perform the break move , which deletes the edges and inserts the edges . The resulting graph is shown in Fig. 15(ii), and redrawn as in Fig. 15(iii).∎