2.Unlabeled graph problems

Some enumeration problems of labeled graphs are normally addressed by applying the exponential generating functions tool. The enumeration problems of unlabeled graphs are normally addressed by applying the ordinary generating functions but require the application of Pólya's theorem.

One of the first problems of enumerating labeled graphs that may arise is that of how many graphs with *p* vertices and *q* edges can be obtained.

To solve this enumeration problem, let *Gp*ð Þ *x* be the polynomial or ordinary generating function whose coefficient of the term *xk* represents the number of labeled graphs with *p* vertices and *k* edges. If *V* is the set of vertices of cardinality *p*,

there are *<sup>q</sup>* <sup>¼</sup> *<sup>p</sup>* 2 � � pairs of these vertices. In every vertex set *<sup>V</sup>*, each pair is adjacent or not adjacent. The number of labeled graphs with *k* edges is therefore

*q k* � � ¼ *p* 2 ! *k* 0 B@ 1 CA. Thus, the ordinary generating function *Gp*ð Þ *<sup>x</sup>* for labeled graphs

with *p* vertices is given by

$$G\_p(\mathbf{x}) = \sum\_{k=0}^{m} \binom{m}{k} \mathbf{x}^k = (\mathbf{1} + \mathbf{x})^m,\tag{19}$$

where *<sup>m</sup>* <sup>¼</sup> *<sup>p</sup>* 2 � �. Then, the number of labeled graphs with *<sup>p</sup>* vertices is *Gp*ð Þ<sup>1</sup> ; so we have:

$$G\_p = \mathbf{2}^m = \mathbf{2}^{\binom{p}{2}}.\tag{20}$$

For example, if we want to know how many labeled graphs with *p* ¼ 3 vertices can be obtained, we apply Formula (20), and we get:

$$\mathbf{G}\_3 = \mathbf{2} \begin{pmatrix} \mathbf{3} \\ \mathbf{2} \end{pmatrix} = \mathbf{2}^{\frac{3!}{2!1}} = \mathbf{2}^3 = \mathbf{8}.\tag{21}$$

If we want to know how many labeled graphs with *p* ¼ 4 vertices and exactly *<sup>q</sup>* <sup>¼</sup> 5 edges exist, before expression (19), we use the coefficient of the term *<sup>x</sup>*<sup>5</sup>

$$\left[\mathbf{x}^{\mathsf{S}}\right] \mathbf{G}\_{p}(\mathbf{x}) = \left[\mathbf{x}^{\mathsf{S}}\right] \sum\_{k=0}^{6} \binom{6}{k} \mathbf{x}^{k} = \binom{6}{5} = \frac{6!}{5!1!} = 6. \tag{22}$$

### *Combinatorial Enumeration of Graphs DOI: http://dx.doi.org/10.5772/intechopen.88805*

Section 4. The brilliant and unknown mathematician John Howard Redfield [11] discovered many enumeration formulas anticipating some of Pólya's contributions. Some enumeration problems of objects that are not graphs (automata, Boolean functions, or chemical isomers) can be solved by cleverly transforming them to graphs. The generating functions are the tool used for enumerating graphs. There are two types of graphs associated with combinatorial graph enumeration problems:

Some enumeration problems of labeled graphs are normally addressed by applying the exponential generating functions tool. The enumeration problems of unlabeled graphs are normally addressed by applying the ordinary generating func-

One of the first problems of enumerating labeled graphs that may arise is that of

pairs of these vertices. In every vertex set *V*, each pair is

CA. Thus, the ordinary generating function *Gp*ð Þ *<sup>x</sup>* for labeled graphs

. Then, the number of labeled graphs with *p* vertices is *Gp*ð Þ1 ; so

*p* 2 � �

*<sup>x</sup><sup>k</sup>* <sup>¼</sup> ð Þ <sup>1</sup> <sup>þ</sup> *<sup>x</sup> m,* (19)

*:* (20)

<sup>2</sup>!1! <sup>¼</sup> 23 <sup>¼</sup> <sup>8</sup>*:* (21)

¼ 6*:* (22)

<sup>¼</sup> <sup>6</sup>! 5!1!

To solve this enumeration problem, let *Gp*ð Þ *x* be the polynomial or ordinary generating function whose coefficient of the term *xk* represents the number of labeled graphs with *p* vertices and *k* edges. If *V* is the set of vertices of cardinality *p*,

adjacent or not adjacent. The number of labeled graphs with *k* edges is therefore

*m k* � �

*Gp* <sup>¼</sup> <sup>2</sup>*<sup>m</sup>* <sup>¼</sup> <sup>2</sup>

3 2 � �

6

*k*¼0

For example, if we want to know how many labeled graphs with *p* ¼ 3 vertices

¼ 2 3!

If we want to know how many labeled graphs with *p* ¼ 4 vertices and exactly *<sup>q</sup>* <sup>¼</sup> 5 edges exist, before expression (19), we use the coefficient of the term *<sup>x</sup>*<sup>5</sup>

> 6 *k* � �

*xk* <sup>¼</sup> <sup>6</sup> 5 � �

1.Labeled graph problems

*Probability, Combinatorics and Control*

there are *<sup>q</sup>* <sup>¼</sup> *<sup>p</sup>*

0

B@

¼

*q k* � �

2.Unlabeled graph problems

2 � �

1

2 � �

*p* 2

*k*

with *p* vertices is given by

where *<sup>m</sup>* <sup>¼</sup> *<sup>p</sup>*

we have:

**228**

!

tions but require the application of Pólya's theorem.

how many graphs with *p* vertices and *q* edges can be obtained.

*Gp*ð Þ¼ *<sup>x</sup>* <sup>X</sup>*<sup>m</sup>*

can be obtained, we apply Formula (20), and we get:

*G*<sup>3</sup> ¼ 2

*<sup>x</sup>*<sup>5</sup> � �*Gp*ð Þ¼ *<sup>x</sup> <sup>x</sup>*<sup>5</sup> � �X

*k*¼0

A question that arises naturally when working with labeled graphs is in how many ways can this be constructed from a certain number of vertices and edges. In order to give a possible answer, the number of symmetries or automorphisms must be taken into account. It is said that there is isomorphism between two graphs *G* and *G*<sup>1</sup> if there is a one-to-one map *A* : *V G*ð Þ↦*V G*ð Þ<sup>1</sup> between them that preserve adjacency. When *G*<sup>1</sup> ¼ *G*, then the mapping *A* is called automorphism of *G*. The set of all the automorphisms of *G*, represented by Γð Þ *G* , is called the group of *G*. The elements of Γð Þ *G* are permutations over *V*. Let *s G*ð Þ¼ ∣Γð Þ *G* ∣ be the order of the group or number of symmetries of *G*. Therefore, the number of ways in which a graph *G* of order *p* can be labeled is

$$l(\mathbf{G}) = \frac{p!}{\mathfrak{s}(\mathbf{G})}.\tag{23}$$

Another example of graph enumeration problem is to count the number of differently labeled connected graphs. The notion of path of length *n* is defined as a sequence of vertices f g *v*0*; v*1*;* …*; vn* where the edges *vi* f g *; vi*þ<sup>1</sup> for *i* ¼ 0*,* …*n* that belong to the path are distinct. It is said that a graph is connected if for any pair of vertices there is a path between them. To obtain the formula that counts all the connected graphs *Cp* of order *p*, it will be necessary to make use of the concept of subgraph. It is said that a *H* is a subgraph of a graph *G* if *V H*ð Þ⊂*V G*ð Þ and *E H*ð Þ⊂*E G*ð Þ. A subgraph that is maximally connected is called component. A rooted graph is a graph that has a distinguished vertex called root. When there exists an injective mapping *f* : *V H*ð Þ<sup>1</sup> ↦*V H*ð Þ<sup>2</sup> between two rooted graphs *H*<sup>1</sup> and *H*<sup>2</sup> that preserves the adjacency among vertices as well as the roots, it is said that the two rooted graphs are isomorphic. Let us make the assumption that *ak* for *k* ¼ 1*;* 2*;* 3*,* … represents the number of ways in which we can label all graphs of order that accomplish the property *P a*ð Þ and whose exponential generating function is

$$a(\mathbf{x}) = \sum\_{k=1}^{\infty} \frac{a\_k \mathbf{x}^k}{k!}. \tag{24}$$

Let us also assume that *bk* for *k* ¼ 1*;* 2*;* 3*,* … is the number of ways of labeling all graphs of order that accomplish the property *P b*ð Þ and whose exponential generating function is

$$b(\mathbf{x}) = \sum\_{k=1}^{\infty} \frac{b\_k \mathbf{x}^k}{k!}. \tag{25}$$

If we make the product of series (24) and (25), the coefficients of *<sup>x</sup><sup>k</sup> <sup>k</sup>*! in *a x*ð Þ*b x*ð Þ is the number of ordered pairs ð Þ *G*1*; G*<sup>2</sup> of two disjoint graphs, where *G*<sup>1</sup> meets the property *P a*ð Þ, *G*<sup>2</sup> fulfills the property *P b*ð Þ, *k* is the number of vertices in *G*<sup>1</sup> ∪ *G*2, and the labels from 1 to *k* have been distributed over *G*<sup>1</sup> ∪ *G*2. If *C x*ð Þ is the exponential generating function for labeled connected graphs

$$C(\mathbf{x}) = \sum\_{k=1}^{\infty} \frac{C\_k \mathbf{x}^k}{k!},\tag{26}$$

then *C x*ð Þ*C x*ð Þ becomes the generating function that counts all the ordered pairs of connected graphs with labels. If you divide by 2, equation (26) that is, we divide it by 2, we get the generating function for labeled graphs that have exactly two components.

By applying this operation *n* times, the coefficient of *xk <sup>k</sup>*! that corresponds to the number of labeled graphs of order *k* is obtained with exact *n* components

$$G(\mathbf{x}) = \sum\_{n=1}^{\infty} \frac{G^n(\mathbf{x})}{n!}. \tag{27}$$

end

end

**Table 1**.

**Table 1.** *Order 1–20.*

**231**

>> for i=1:20

*Combinatorial Enumeration of Graphs DOI: http://dx.doi.org/10.5772/intechopen.88805*

%% calling the function from the matlab prompt for the calculation of the

The calculations obtained by the execution of MATLAB code are shown in

graphs *Cp* grows very fast in terms of the number *p* of vertices. It should be mentioned that (29) and (30) are recurrence relations instead of a closed formula. The recurrences (29) or (30) can be used for the calculation of *Cp* with a computer program. The generating functions can be used to solve recurrences and obtain a closed mathematical expression for the *n*th term of the succession associated with the recurrence. It can happen that calculation of the solution of some recurrences becomes very hard to be solved and in the worst cannot be solved at all. An

From the results of 1, it can be observed that the number of possible connected

alternative method for obtaining an approximate value for big values of *p* is to recur to the application of methods used in analytic combinatorics and calculate accurate approximations of the *p*th coefficient of the generating function. The generating functions algebraic structure allows to reflect the structure of combinatorial classes.

*p Cp* 1 1 2 1 3 4 4 38 5 728 6 26,704 1,866,256 251,548,592 66,296,291,072 34,496,488,594,816 35,641,657,548,953,344 <sup>7</sup>*:*<sup>335460</sup> 1019 <sup>3</sup>*:*<sup>012722</sup> <sup>10</sup><sup>23</sup> <sup>2</sup>*:*<sup>471649</sup> <sup>10</sup><sup>27</sup> <sup>4</sup>*:*<sup>052768</sup> <sup>10</sup><sup>31</sup> <sup>1</sup>*:*<sup>328579</sup> <sup>10</sup><sup>36</sup> <sup>8</sup>*:*<sup>708969</sup> 1040 <sup>1</sup>*:*<sup>41641</sup> 1046 <sup>2</sup>*:*<sup>992930</sup> 1051 <sup>1</sup>*:*<sup>569216</sup> <sup>10</sup><sup>57</sup>

%% evaluation from graphs of order 1 to 20

R(1,i)=CuentaGrafConnEtiq( i );

From (27), we obtain the following relation

$$\mathbf{1} + \mathbf{G}(\mathbf{x}) = \mathbf{e}^{\mathbf{C}(\mathbf{x})}.\tag{28}$$

Riordan in [12] obtained the relation *Cp* ¼ *Jp*ð Þ2 , where *Jp*ð Þ *x* enumerates the trees by inversions, and then deduced

$$\mathbf{C}\_{p} = \sum\_{k=1}^{p-1} \binom{p-2}{k-1} (2^k - 1) \mathbf{C}\_{k} \mathbf{C}\_{p-k} \,. \tag{29}$$

From (29), it should be noted that if the exponential generating function for the graph class is known in advance, then the exponential generating function for the class of graphs will be the logarithm of the first series, just as in (28). It should also be mentioned that another equivalent recurrence function can be obtained for the enumeration of the connected graphs that have order tags *p* (p. 7 in [13]) and that can be expressed mathematically as

$$\mathbf{C}\_{p} = 2\binom{p}{2} - \frac{1}{p} \sum\_{k=1}^{p-1} k \binom{p}{k} 2^{p - \binom{k}{2}} \mathbf{C}\_{k} . \tag{30}$$

From (30), the following MATLAB code can be implemented for calculating the number of connected graphs *Cp* of orders going from *p* ¼ 1 to *p* ¼ 20.

```
function y = CuentaGrafConnEtiq( p )
% recurrence satisfied by the number of connected graphs
% Harary Graph Enumeration pag. 7
% C_p= 2ˆ{combinations(p,2)}-1/p* \sum_{k=1}ˆ{p-1} k*
% combinations(p,k)*2ˆ{combinations(p-k,2)}*C_{k}
C(1:p)=0;
C(1,1)=1;
for k=2:p
  acum=0;
  for j=1:k
    acum = acum + j * combinaciones(k,j) * CuentaGrafEtiq(k-j) * C(1,j);
  end
  C(1,k) = CuentaGrafEtiq(k)-(1/k)*acum;
end
y=C(1,p);
sprintf('end function z=combinaciones(n,k) z= factorial(n)/(factorial(k)
*factorial(n-k));
end
function z=combinaciones(n,k)
   z= factorial(n)/(factorial(k)*factorial(n-k));
```
*Combinatorial Enumeration of Graphs DOI: http://dx.doi.org/10.5772/intechopen.88805*
