On the number of caterpillars

id


Introduction
We use here standard notation and terminology, as in [3]. All graphs considered in this work are finite and simple, that is, with no loops or multiple edges. A graph G of order m and size n is a graph where its vertex set V has cardinality m and its edge set E has cardinality n. A vertex v of G is said to be a leaf when its degree is one, otherwise v is called an internal vertex. A graph G is bipartite if V is the union of two independent sets or stable sets of G. If G is a connected graph and u, v ∈ V , the distance between u and v, denoted by d(u, v), is the length (or size) of the shortest path from u to v; the diameter of G is max{d(u, v) : u, v ∈ V }. For each v ∈ V , deg(v) denotes the degree of v, i.e., the number of edges of G incident to v.
For every m ≥ 1, P m denotes the path of order m, where P 1 ∼ = K 1 and for all m ≥ 2, P m is the tree with exactly two leaves, equivalently, the tree of order m with m − 2 interior vertices. Paths can be seen as members of a larger family of trees, the family of caterpillars. A caterpillar is a tree of order m ≥ 3 with the property that the deletion of all its leaves results in a path; the paths P 1 and P 2 are considered caterpillars in this work.
Harary and Schewnk [2] applied Pólya's enumeration theorem to determine the number of nonisomorphic caterpillars of order m, finding the generating function for the number of caterpillars. A closed formula for the number of caterpillar of order m is 2 m−4 + 2 m−4 2 . The present work includes three enumerations of caterpillars, where the size of a caterpillar is combined with two other parameters: the diameter and the cardinality of the smaller stable set. In Section 2 we introduce the basic results needed to perform the calculations in the upcoming sections. In Section 3 we determine the number a(n, k) of caterpillars of size n with stable sets of cardinality k and n + 1 − k; in Section 4 we study the number b(n, d) of caterpillars of size n and diameter d; we conclude this work in Section 5, where we give the number c(n, d, k) of caterpillars of size n, diameter d, and stable sets of cardinalities k and n + 1 − k.
In this work we use the symbol C(s, r) to represent the binomial coefficients, that is, C(s, r) = s! r!(s − r)! .

The Essential Results
Suppose that Z is a finite set of integers and S is the set of all sequences of length r formed with elements of Z . Let S 1 = {a i } r i and S 2 = {b i } r i be elements of S , we say that S 1 ≈ S 2 if for every i ∈ {1, 2, . . . , r} at least one of the following conditions hold: It is not difficult to see that ≈ is an equivalence relation on the set S . We are interested in finding the number of equivalence classes induced by ≈. Let S ∈ S , the equivalence class of S is denoted by [S]. If S = {a i } r i , its reverse sequence is defined as S −1 = {a r+1−i } r i . Thus, both S and S −1 are in the same equivalence class. The sequence S is said to be reversible if S = S −1 . Therefore [S] = {S} if and only if S is reversible, otherwise [S] = {S, S −1 }. Thus, using Pólya's enumeration theorem, we know that the number of equivalence classes induced by ≈ on S , is half of the addition of the total number of sequences and the total number of reversible sequences. This is the technique used in this work to find the closed formulas for a(n, k), b(n, d), and c(n, d, k).
Consider the following equation, where each x i is an integer. In the following sections we use the number of solutions to this equation to ascertain the specific amount of caterpillars considered there.
The next two theorems can be found in Chapter 3 of the combinatorics book by Allenby and Slomson [1]. We present them omitting their proofs.
If (x 1 , x 2 , . . . , x r ) is a solution of equation (1), where each x i > 0, then (x 1 , x 2 , . . . , x r ) is a partition of s; moreover, it is an ordered partition in the sense that any permutation of its entries provides a solution of (1). In this work the word partition is used to indicate an ordered partition.
In the next theorems we use the following well-known property of the addition of binomial coefficients. Theorem 2.3. For all positive integers, j, t with j ≤ t, If (x 1 , x 2 , . . . , x r ) is a solution of equation (1), then it is an element of S , therefore it is reversible when x i = x r+1−i for each i ∈ {1, 2, . . . , r}. We are interested in the number of reversible solutions of equation (1). As we saw in the first two theorems, the number of solutions of (1) depends on the nature of the x i ; consequently, we need to consider two instances. Let ρ 0 (s, r) denote the number of reversible nonnegative integer solutions, while ρ(s, r) designates the number of reversible positive integer solutions. In order to determine ρ 0 (s, r) and ρ(s, r) we analyze two cases based on the parity of r.
Suppose first that r is even. Since (x 1 , x 2 , . . . , x r ) is reversible, we conclude that equation (1) can be reduced to But equation (2) has integer solutions if and only if s is even because each x i is an integer. Therefore, ρ 0 (s, r) = ρ(s, r) = 0 when s is odd and r is even. Theorems 2.1 and 2.2 can be used to determine ρ 0 (s, r) and ρ(s, r) when s is even. Thus, we know that ρ 0 (s, r) = C s+r−2 2 , r−2 2 and ρ(s, r) = C s−2 2 , r−2

2
. Suppose now that r is odd. Since (x 1 , x 2 , . . . , x r ) is reversible, equation (1) can be written as which is equivalent to Note that the right side of equation (4) is an integer if and only if s and x r+1 2 have the same parity. This implies that in addition to the nature of each x i we also need to consider the parity of s to calculate the value of ρ 0 (s, r) and ρ(s, r). We analyze now the four different scenarios.

www.ijc.or.id
On the number of caterpillars | C. Barrientos (a) When s is even and each x i is a nonnegative integer. Since each x i is a nonnegative integer, we have that x r+1 2 ∈ {0, 2, . . . , s} = {2j : 0 ≤ j ≤ s 2 }. Let xr+1 2 = 2j for some j ∈ {0, 1, . . . , s 2 }, then equation (4) can be written as The number of nonnegative integer solutions of this last equation can be calculated, using Theorem 2.1, to be equal to C s 2 − j + r−3 2 , r−3

2
. Seeing that j ∈ {0, 1, . . . , s 2 }, Theorem 2.3 tells us that (b) When s is even and each x i is a positive integer. Considering that each x i is a positive integer, we have that xr+1 , then the number of positive integer solutions of equation (5) is, determined using Theorem 2.2, to be C s (c) When s is odd and each x i is a nonnegative integer. Since each x i is a nonnegative integer and both x r+1 2 and s have the same parity, we get that x r+1 2 ∈ {1, 2, . . . , s} = {2j + 1 : 0 ≤ j ≤ s−1 2 }. Let x r+1 2 = 2j − 1 for some j ∈ {0, 1, . . . , s−1 2 }, then equation (4) can be written as The number of nonnegative integer solutions of equation (6) can be calculated, using Theorem 2.1, to be equal to C s−1 . Based on the fact that j ∈ {0, 1, . . . , s−1 2 }, Theorem 2.3 tells us that (d) When s is odd and each x i is a positive integer. As in the previous cases, xr+1 2 and s have the same parity; the fact that each x i is a positive integer implies that the right side of equation (6) must be at least equal to the number of terms in this equation, i.e., s−1 Thus we have proven the next two theorems.  (1) is: i. ρ 0 (s, r) = 0 when s is odd and r is even, when both s and r are even, when s is even and r is odd, when both s and r are odd. Suppose that s is even. If r is even, then r ∈ {2, 4, . . . , s} and the sum of all values of ρ(s, r) On the number of caterpillars | C. Barrientos

First Enumeration: Stable Sets
As we mentioned in the Introduction, we are aware of only one enumeration of caterpillars, which was performed by Harary and Schwenk [2], where they determined the number of caterpillars of order m ≥ 3 to be c m = 2 m−4 + 2 m−4 2 . The sequence formed by the consecutive values of c p is A005418 in OEIS. If instead of using the order of the caterpillars we use the size, the formula given in [2] can be written for every n ≥ 3 as: In Table 1 we show the first values of c(n) for 3 ≤ n ≤ 20. Let G be a caterpillar of size n ≥ 1 where the stable sets are A = {u 1 , u 2 , . . . , u k } and B = {v 1 , v 2 , . . . , v l }. Without loss of generality, we assume that k ≤ l. We want to determine the number a(n, k) of non-isomorphic caterpillars of size n such that the smallest stable set has cardinality k. This implies that 1 ≤ k ≤ n 2 when n is even and 1 ≤ k ≤ n+1 2 when n is odd. Consequently, n 2 k=1 a(n, k) = c(n).
Caterpillars have a characteristic that distinguish them from any other type of tree, they can be drawn in such a way that the vertices can be organized on two parallel lines (or rows), one for each stable set, and the edges connecting these vertices, represented by line segments between the two rows, never cross. We refer to this representation of a caterpillar as its 2-row representation. In Figure 1 we show the 10 non-isomorphic caterpillars of size 6, organized in levels according to the three possible values of k. The elements of the stable set A are in black. On each caterpillar, the leftmost elements are u 1 and v 1 , while the rightmost elements are u k and v l . The number on top of each black vertex is its degree.
If deg(u i ) = d i , then every caterpillar can be described by the sequence d 1 , d 2 , . . . , d k , where each d i ≥ 1 and d 1 +d 2 +· · ·+d k = n. But the same caterpillar can also be described by the reverse sequence, that is, d k , d k−1 , . . . , d 1 . Thus, the problem of counting non-isomorphic caterpillars of size n which smaller stable set has k elements, is equivalent to count sequences of length k which entries are positive integers where the addition of all entries equals n and the sequence and its reverse are considered the same. Note that each of these sequences is a solution of equation (1) with r = k and s = n. Since each d i > 0, the values of ρ(n, k) obtained in Theorem 2.5 are used to calculate a(n, k). www.ijc.or.id Theorem 3.1. The number a(n, k) of non-isomorphic caterpillars of size n which smaller stable sets has cardinality k ≤ n−1 . . , v l } be the stable sets of a caterpillar of size n, where k ≤ l, which is assumed to be depicted using the 2-row representation. Suppose that for each i ∈ {1, 2, . . . , k}, deg(u i ) = x i . Since caterpillars are trees and trees are bipartite graphs, the following equation holds: which has the structure of equation (1).
If (x 1 , x 2 , . . . , x k ) is a solution of (7), then its reverse sequence (x k , x k−1 , . . . , x 1 ) is also a solution. Thus every caterpillar is associated to two of these solutions. Since some of these solutions are reversible, the number of non-isomorphic caterpillars of size n with smaller stable set of cardinality k is given by half of the sum of the number of solutions of (7) and the number of reversible solutions.
The number of positive integer solutions of (7) is C(n − 1, k − 1) and the number of reversible solutions is ρ(n, k). Therefore, a(n, k) = 1 2 (C(n − 1, k − 1, +ρ(n, k)). When n is even, the stable sets of any caterpillar of size n have different cardinality; this implies that Theorem 3.1 tells us the exact value of a(n, k). The same occurs when n is odd and k = n+1 2 . However the situation is different when n is odd and k = n+1 2 . This case is different of the other cases because both stable sets have the same cardinality, this means that there are up to four solutions of equation (1) that can represent the same graph. To explain the problem, let us consider the three caterpillars of size n = 9 shown in Figure 2.

www.ijc.or.id
On the number of caterpillars | C. Barrientos Even when graphs are not geometrical objects, consider the following rigid representations of G 1 , G 2 , and G 3 depicted in Figure 3. Figure 3. Rigid representations to the caterpillars G 1 , G 2 , and G 3 We may observe that G 1 his asymmetric, while G 2 and G 3 are symmetric; in the case of G 2 we may rotate the figure 180 • around a horizontal axis, G 3 may be rotated 180 • around a central point. Thus, the family of all caterpillars of odd size n with stable sets of cardinality k = n+1 2 can be partitioned into three classes according to these symmetries and the amount of partitions of n associated with them. We use the following notation: [G 1 ] is the set that includes all the caterpillars associated with four different partitions, [G 2 ] includes all the caterpillars associated with two different reversible partitions, and [G 3 ] includes all the caterpillars associated with two different but not reversible partitions. Consequently, to know the value of a n, n+1 2 we need to determine the cardinality of these three sets. Based on the fact that the equation d 1 +d 2 +· · ·+d k = n has C(n − 1, k − 1) solutions, we just need to find the cardinalities of [G 2 ] and [G 3 ]. But the partitions associated to the elements in [G 2 ] are reversible, hence, we just need to determine the cardinality of [G 3 ], because the cardinality of [G 2 ] is given by ρ(n, k).
Suppose that P = (p 1 , p 2 , . . . , p k ) is a partition of n into k parts such that for every 1 ≤ i ≤ k − 1, p i ≥ p i+1 . A Ferrer diagram is a pictorial representation of P that uses k rows of dots, where the number of dots on the ith row is p i . In this way, the number of dots per row does not increase as we go from any row to the one below it. Since our partitions of n not necessarily satisfy d i ≥ d i+1 , we cannot use Ferrer diagrams but we can use the same principle, that is, the ith row on the diagram contains d i dots. Consider the partitions (2, 1, 3, 2, 1) and (1, 3, 1, 2, 2) of n = 9, because they have the same parts, they correspond to the same standard partition; in Figure 4 we www.ijc.or.id On the number of caterpillars | C. Barrientos show the associated Ferrer diagram together with their ordered diagram and a matrix representation of (1, 3, 1, 2, 2).

Ferrer diagram
(2, 1, 3, 2, 1) (1, 3, 1, 2, 2) Matrix Recall that when D = (d 1 , d 2 , . . . , d k ) is a solution of equation (1), D is an ordered partition of n. Let M be a 0-1 matrix of order k × k, where k = n+1 2 , such that for every 1 ≤ i ≤ k, the ith row of M has exactly d i nonzero entries that occupy consecutive cells and the nonzero entries, on each row, are organized according to: 1. the last d 1 entries on row 1 are nonzero.
2. for each 2 ≤ i ≤ k, the last nonzero entry on row i occupies a cell on the same column that contains the first nonzero entry on the previous row.
As an example of this representation, the matrices associated with the caterpillars G 1 , G 2 , and G 3 are shown below. The symmetries of the rigid representations of the graph can be also seen within the corresponding matrix. Since our goal is to determine the number of caterpillars associated with exactly two non-reversible partitions, we concentrate our attention on matrices like M 3 . First, observe that in the example, we have that M 3 = M t 3 , that is, the matrix M 3 is symmetric. In addition, M t is the matrix associated with the same caterpillar when the stable sets are swapped and the degrees of the vertices are read from right to left. Another property that we can observe in all these matrices is that there is only one nonzero entry on each descending diagonal. Thus, the task is to find out the number of symmetric 0-1 matrices of order k × k such that the cell m 1,1 is occupied by a zero, m k,1 = m 1,k = 1, and on each row, the 1's are in consecutive cells.
If we outline the distribution of 1's on any of these matrices, a path is revealed, which can be understood as a symmetric path on the x-y plane from (0, 0) to (k − 1, k − 1), where every step of the path is a move one unit to the right or one unit up. Since the symmetry is with respect to the main diagonal of the matrix, we can calculate the number of symmetric paths from (0, 0) to (k − 1, k − 1) by adding the integers C(k − 1, i) over all the possible values of i, that is, the number of these paths from (0, 0) to (k − i, i). Since k−1 i=0 C(k − 1, i) = 2 k−1 , we can say that the number of symmetric 0-1 matrices of order k × k satisfying the conditions is 2 k−1 . Therefore, the number of caterpillars of size n associated with exactly two non-reversible partitions is 2 k−1 .
In Table 2 we show the first values of a(n, k), for every 1 ≤ n ≤ 20 and 1 ≤ k ≤ 10. Note that the entries in the last column correspond to the entries of c(n) in Table 1. We conclude this section verifying this last statement.  ρ(n, k) Since the case n odd can be proven similarly, we omit its proof.

Second Enumeration: Diameter
Let G be a caterpillar of size n and diameter d.
To avoid any confusion with the terminology, we refer to v 0 and v d as the extreme vertices and pendent vertex to any other vertex of degree 1. If for each i ∈ {1, 2, . . . , d − 1}, x i = deg(v i ) − 2, then x i is the number of pendent vertices attached to v i . Therefore, In this section we want to determine the number b(n, k) of non-isomorphic caterpillars of size n and diameter d. As we did in Section 3, we start counting the number of solutions of (8). Note that now each x i is a nonnegative integer because deg(v i ) could be equal to 2, implying that x i = 0. Based on the result in Theorem 2.1, we know that the number of nonnegative integer solutions of (8) is C(n − d + d − 2, d − 2) = C(n − 2, d − 2). As in the previous case, if (x 1 , x 2 , . . . , x d−1 ) is a solution of (8) where each x i ≥ 0, then (x d−1 , x d−2 , . . . , x 1 ) is also a solution of (8). This indicates that we need to find the number of reversible solutions of this equation. But this number can be obtained using Theorem 2.4 with s = n − d and r = d − 1. Therefore, the number b(n, d), of non-isomorphic caterpillars of size n and diameter d is given by   The number b(n, d), of non-isomorphic caterpillars of size n and diameter d is: i. 1 2 C(n − 2, d − 2) when n is even and d is odd, when both n and d are odd, when both n and d are even, when n is odd and d is even.
As an example for this theorem, in Figure 5 we exhibit the 20 caterpillars of size 7 classified by their diameter. In addition, in Table 3 we show the first values of b(n, d) for 2 ≤ n ≤ 20 and 2 ≤ d ≤ n 2 . The remaining values of b(n, d) can be easily obtained using the fact that b(n, d) = b(n, n + 2 − d). We must also mention here that the sequence formed by the values of b(n, d) form the rows of Losanitsch's triangle, that is, the sequence A034851 in OEIS.

Third Enumeration: Stable Sets and Diameter
In this last section we combine the ideas of the two previous sections by determining the number of caterpillars of size n, diameter d, and smaller stable set of cardinality k, this number is denoted by c(n, d, k). As it is expected, this enumeration is more complicated that the previous calculations; however, the technique is essentially the same: we find first the number of ways to distribute the pendent vertices among the internal vertices, we add to this amount the number of reversible distributions, and we divide this sum by two.
Let v 0 , v 1 , . . . , v d be the consecutive vertices of a path P of maximum length in a caterpillar of size n, then there are n − d pendent vertices that need to be attached to the interior vertices. For each i ∈ {1, 2, . . . , d − 1}, the number of pendent vertices attached to v i is x i 2 when i is even and y i+1 2 when i is odd. Note that in any caterpillar of size n and diameter d, the amount of interior vertices with an even index is d−2 2 when d is even and d−1 2 when d is odd, and the amount of interior vertices with an odd index is d 2 when d is even and d−1 2 when d is odd. Furthermore, for every n ≥ 2, there is only one caterpillar of size n and diameter d = 2, this tree is the star S n ∼ = K 1,n ; thus, c(n, 2, 1) = 1. In a caterpillar of diameter d = 3, the n − 3 pendent vertices are distributed among the two interior vertices, each possible distribution corresponds to a partition of n − 3 into two parts. If we consider that one of these parts can be zero, then there are n−2 2 of these partitions when n is even and n−1 2 when n is odd. Therefore, when n is even, for each k ∈ {2, 3, . . . , n 2 }, c(n, 3, k) = 1; when n is odd, for each k ∈ {2, 3, . . . , n+1 2 }, c(n, 3, k) = 1. Consequently, starting at this point, we assume that d ≥ 4. We analyze two major cases that depend of the parity of the parameter d. In both cases, the parameter f is the number of pendent vertices attached to the interior vertices with odd index and the parameter g is the number of pendent vertices attached to the interior vertices with even index.
Case 1: When d is odd. The following equations must be satisfied by the x i and y i : For the path P that contains the vertices v 0 , v 1 , . . . , v d , there is an automorphism φ that trans- }. Consequently, the cardinality of the smaller stable set is k = d+1 2 + f , i.e., k ∈ { d+1 2 , d+3 2 , . . . , n 2 }. Since there is no automorphism of P that transforms a vertex with an even (or odd) index into another vertex with an even (or odd) index, it is impossible to have a reversible distribution of the pendent vertices. Thus, c(n, d, k) is obtained by the product of the number of solutions of equations (9) and (10), that is, for each k = d+1 2 + f , i.e., for each k ∈ { d+1 2 , d+3 2 , . . . , n 2 }, Since k = d+1 2 + f and g = n − d − f , this equation can be written in the following form Using the formula for σ 0 (s, r) in Theorem 2.1, we can reduce this last expression into The only difference with the previous case occurs when f = g = n−d 2 , i.e., when k = n+1 2 . Suppose that f = n−d 2 and that (x 1 , x 2 , . . . , x d−1
Theorem 5.1. Let d ≥ 5 be an odd integer, k ≥ d+1 2 , and n ≥ d. The number of nonisomorphic caterpillars of size n, diameter d, and smaller stable set of cardinality k is: when n is odd and k = n+1 2 .
ii. c(n, d, k) = C k − 2, d−3 www.ijc.or.id On the number of caterpillars | C. Barrientos Case 2: When d is even. The major difference with Case 1 is that now, in any caterpillar of even diameter, the path P contains more vertices with an even index than vertices with an odd index. Anyway, the distributions of the pendent vertices are associated to the solutions of the following equations: The fact that these equations do not have the same number of terms implies that f ∈ {0, 1, . . . , n − d} and g ∈ {n − d, n − d − 1, . . . , 0}. We must observe that in this case, there is an automorphism of P that transform the vertex v i into v d−i ; because d is even, i and d − i have the same parity. In other words, a reversible solution of (11), combined with a reversible solution of (12), produces a reversible distribution of the pendant vertices among all the interior vertices. Then, The parity of n plays an important part in the number of solutions of equations (11) and (12). Suppose first that f < n − d.