### Example: Piping geng

#### by Derrick Stolee

I realized shortly after writing yesterday’s post about using `gtools`

that I did not properly explain the piping procedure for `geng`

. To remedy that deficiency, I will provide a concrete example of how I used this method in actual research.

In this example, we will exactly characterize the infinite class of *-extremal graphs* for . We’ll start by talking about the mathematics, and at the very end we will go into the concrete piping example. Theoretically, you could skip straight to the code, but you’ll miss out on the fact that the computer is simultaneously *discovering and proving* a structure theorem for an infinite class of graphs!

### The Theory

A perfect matching is a set of edges which covers every vertex exactly once. Dudek and Schmitt defined the function to be the maximum number of edges in a graph on vertices with exactly perfect matchings. An unpublished theorem of Hetyei states and there is a unique graph attaining this bound for all even . Dudek and Schmitt proved

**Theorem (Dudek, Schmitt, 2012).** For all , there are constants and such that .

This implies that no matter how many perfect matchings we want to cram into our graph, we can only change the maximum number of edges by some constant. We call the difference the *excess* of a graph . Thus, we are attempting to maximize the excess over graphs with perfect matchings.

A graph is *-extremal* if it has vertices, perfect matchings, and edges. Dudek and Schmitt were able to determine for and characterized the -extremal graphs for .

With Hartke, West, and Yancey, we developed a structural characterization of the infinite class of -extremal graphs for every fixed . There was just one missing component: we described a way to build every -extremal graph if you know a finite list of *building blocks*.

Here is a brief description of these blocks and how to glue them together. An edge is *extendable* if it is contained in a perfect matching; otherwise it is *free*. A graph is a *chamber* if the subgraph of extendable edges is connected. In a chamber, the subgraph of free edges is a set of disjoint cliques.

Given a non-chamber graph, its vertex set is partitioned into chambers by the connected components of the extendable subgraph. An important property of any graph is that the number of perfect matchings is the product of the number of perfect matchings in each chamber.

One way to build a graph with perfect matchings is to start with a list of chambers where has perfect matchings and . The disjoint union of these chambers has perfect matchings, but is very sparse. We can add free edges between the chambers by taking a clique of free edges in some and adding edges between all vertex in and vertices in for all . This construction is called a *spire*, a very specific instance of a *cathedral*, as in Lovász’s Cathedral Theorem (see Lovász and Plummer, Chapter 5). To maximize the excess of the spire, we must select the largest clique of free edges in and satisfy the inequality . Given such a spire , the excess is bounded as with equality if and only if for all .

So, to finish the structural characterization, we must find the chambers with maximum excess and find out which have large cliques of free edges. It is not hard to observe that the only chamber with a unique perfect matching is , the graph of exactly one edge. So, given any -extremal graph on vertices, we can always extend to a -extremal graph on vertices by creating a new spire with an extra copy of as the first chamber.

An important fact that I have not yet discussed is that a chamber with perfect matchings and excess at least has at most vertices (a non-trivial fact!). Now this is a finite computation!

### The Computation

Download the C file permcount.c and place it in the `nauty`

directory along with `geng`

. To compile the program, type

`gcc nausparse.o gtools.o nautil.o permcount.c -o permcount.exe -I./`

This will create the executable `permcount.exe`

. It has three parameters: which provide the minimum number of perfect matchings, the maximum number of perfect matchings, and the minimum excess value. If you run

`./geng 8 | ./permcount.exe 1 1 0`

You will get the output

`>A ./geng -d0D7 n=8 e=0-28`

1 0 G?bN^{

>Z 12346 graphs generated in 0.01 sec

This means that `geng`

generated all 12,346 graphs of order 8 but exactly one had a unique perfect matching and non-negative excess. So, we have just verified Hetyei’s theorem for this order!

Now, let’s find the maximum excess for a graph with perfect matchings. We proved that chambers with between one and seven perfect matchings have at most 10 vertices. So, we can find the maximum excess for these graphs by running

`geng 10 | ./permcount.exe 1 7 0`

Running with these parameters will output 471 graphs! However, some of these are unnecessary, as they are all graphs with one to seven perfect matchings and non-negative excess. But looking through the list, we find the following values for :

1 | 2 | 3 | 4 | 5 | 6 | 7 | |

0 | 1 | 2 | 2 | 2 | 3 | 3 |

Hence, to find the list of -extremal graphs for , we can instead run the following commands (given with output):

`./geng 8 | ./permcount.exe 1 1 0`

>A ./geng -d0D7 n=8 e=0-28

1 0 G?bN^{

>Z 12346 graphs generated in 0.01 sec./geng 8 | ./permcount.exe 2 2 1

>A ./geng -d0D7 n=8 e=0-28

2 1 G?bN~{

2 1 G?bn^{

2 1 G?rN^{

>Z 12346 graphs generated in 0.01 sec./geng 8 | ./permcount.exe 3 5 2

>A ./geng -d0D7 n=8 e=0-28

4 2 G?bn~{

4 2 G?rN~{

4 2 G?rn^{

5 2 GCR]~{

5 2 GCrM~{

3 2 GCe]~{

>Z 12346 graphs generated in 0.01 sec./geng 8 | ./permcount.exe 6 7 3

>A ./geng -d0D7 n=8 e=0-28

6 3 G?b~~{

6 3 G?zn^{

7 3 GCr]~{

6 3 GCe^~{

6 3 GCf]~{

>Z 12346 graphs generated in 0.01 sec

We can extend this just a little bit farther. When we proved that -extremal chambers have at most 12 vertices. Generating all graphs of order 12 and counting the number of perfect matchings on each one will take too long. Instead, we will limit the graphs we generate by specifying the number of edges. A graph on 12 vertices with excess has edges. By checking all graphs of order 10, we can quickly determine that there exist graphs with 8 perfect matchings and excess 3, and graphs with 9 or 10 perfect matchings and excess 4. The following lemma from Dudek and Schmitt is helpful in this case:

**Lemma (Dudek, Schmitt, 2012).** If for all , then .

That is, the excess can increase by at most one over all previous excess values. Therefore, by our previous determinations of we now know that and once we determine , we will know . Again, once we determine we will know . Thus, we can run the following two commands:

`./geng 12 39:40 | ./permcount.exe 8 8 3`

./geng 12 40:41 | ./permcount.exe 9 10 4

Now, by looking at the output graphs, we can extract the list of chambers. From those chambers we can determine the structure theorems for -extremal graphs for all . Here is a picture that demonstrates the spire structures that determine all -extremal graphs:

Unfortunately, our bound on the order of 11-extremal chambers is at most 14 vertices. Generating all graphs of order 14 (even restricting to the number of edges) is intractable, even for a supercomputer. To find the -extremal chambers for larger values of , we must do something drastically different. That will be the subject of a later blog post, which will first require a description of canonical deletion (the algorithm behind `geng`

).

#### References

A. Dudek, J. Schmitt, On the size and structure of graphs with a constant number of 1-factors. *Discrete Math.* 312 (2012) 1807-1811.

S. G. Hartke, D. Stolee, D. B. West, M. Yancey, Extremal graphs with a given number of perfect matchings. To appear in *Journal of Graph Theory*.

L. Lovász, M. Plummber, *Matching Theory*. (AMS Chelsea Publishing; Providence, RI, 2009), xxxiii+547 pp.