6

Here, an endpoint is a vertex of degree $1$. For $n=1,2,3,\ldots$ the number of such graphs is $1,1,2,15,314,\ldots\;$. This is sequence A059167 in Sloane's OEIS. The exponential generating function (e.g.f.) is given in the OEIS entry:

$$\exp\left(\frac{x^2}2\right)\sum_{n=0}^\infty\frac1{n!}\left(\frac{x}{e^x}\right)^n2^{\binom{n}2}$$

Is there some way to easily arrive at the generating function by applying symbolic derivation methods such as those described in Flajolet and Sedgewick Analytic Combinatorics?

I understand the factor $\exp(\frac{x^2}{2})$. I also see that the summation WITHOUT THE FACTOR $\exp(-x)$ would be the e.g.f. for the total number of simple labeled graphs.

Brian M. Scott
  • 616,228

1 Answers1

3

Remark. The OEIS entry A059167 sends us to Harary and Palmer, Graphical Enumeration, which in turn sends us to Some unusual enumeration problems by Read. There really is no reason not to consult these sources.

Here are some ideas on the subject. Let $\mathcal{G}$ be the species of all labeled graphs and $\mathcal{A}$ be the species of labeled graphs with no endpoints and $\mathcal{B}$ be the species of connected labeled graphs with no endpoints. Finally let $\mathcal{T}$ be the species of rooted labeled trees. Also introduce $\mathcal{U},$ unrooted labeled trees. We have by inspection that

$$\def\textsc#1{\dosc#1\csod} \def\dosc#1#2\csod{{\rm #1{\small #2}}} \mathcal{G} = \textsc{SET}(\mathcal{U} + \mathcal{B}_{\ge 3}(\mathcal{T})) \quad\text{and}\quad \mathcal{A} = \textsc{SET}(\mathcal{B})$$

Translating to generating functions we get

$$G(z) = \exp(U(z) + B_{\ge 3}(T(z)) \quad\text{and}\quad A(z) = \exp(B(z)).$$

and the goal is to compute $A(z).$ We get for $G(z)$

$$G(z) = \exp\left(U(z) - T(z) + B(T(z))\right) \\ = \exp\left(U(z) - T(z) + \log A(T(z))\right) \\ = \sum_{n\ge 0} 2^{n\choose 2} \frac{z^n}{n!}.$$

Here we have made use of the fact that the number of connected graphs with no endpoints is one for the singleton node and zero for graphs on two nodes.

Now we have for $\mathcal{T}$ that

$$\mathcal{T} = \mathcal{Z} \times \textsc{SET}(\mathcal{T})$$

which yields

$$T(z) = z \exp T(z) \quad \text{or} \quad z = T(z) \exp (-T(z)).$$

Furthermore we have combinatorially

$$T(z) = \sum_{n\ge 1} n^{n-1} \frac{z^n}{n!} \quad \text{and} \quad U(z) = \sum_{n\ge 1} n^{n-2} \frac{z^n}{n!}.$$

We now claim that $$U(z) = T(z) - \frac{1}{2} T(z)^2.$$

This yields for the coefficient $[z^n] U(z)$ where $n\ge 1$

$$[z^n] U(z) = \frac{1}{2\pi i} \int_{|z|=\epsilon} \frac{1}{z^{n+1}} \left(T(z) - \frac{1}{2} T(z)^2\right) \; dz.$$

Using $T(z) = w$ and $z = w \exp(-w)$ and $dz = (\exp(-w) - w\exp(-w)) \; dw$ we obtain (this is a standard computation)

$$\frac{1}{2\pi i} \int_{|w|=\gamma} \frac{\exp((n+1)w)}{w^{n+1}} \left(w-\frac{1}{2}w^2\right) \exp(-w) (1-w) \; dw \\ = \frac{1}{2\pi i} \int_{|w|=\gamma} \frac{\exp(nw)}{w^{n}} \left(\frac{1}{2} w^2 - \frac{3}{2} w + 1\right) \; dw.$$

This is for $n\ge 3$ (the small $n$ are left to the reader)

$$\frac{1}{2}\frac{n^{n-3}}{(n-3)!} - \frac{3}{2}\frac{n^{n-2}}{(n-2)!} + \frac{n^{n-1}}{(n-1)!} \\ = \frac{n^{n-2}}{n!} \times \left(\frac{1}{2} \frac{n(n-1)(n-2)}{n} - \frac{3}{2} n (n-1) + n^2\right) = \frac{n^{n-2}}{n!}.$$

This verifies the claim. Use this on $G(z)$ to get

$$G(z) = \exp\left(-\frac{1}{2}T(z)^2 + \log A(T(z))\right) = A(T(z)) \exp(-T(z)^2/2)$$

or

$$A(T(z)) = G(z) \exp(T(z)^2/2).$$

In order to conclude we put $T(z)=w$ and use the functional equation of $T(z)$ which yields $z=w/\exp(w)$ to obtain

$$A(w) = G(w/\exp(w)) \exp(w^2/2).$$

This is

$$\bbox[5px,border:2px solid #00A000]{ A(w) = \exp\left(\frac{w^2}{2}\right) \sum_{n\ge 0} \left(\frac{w}{e^w}\right)^n \frac{2^{n\choose 2}}{n!}.}$$

The following memory-efficient Perl script computes the first eight values for comparison with the generating function.

#! /usr/bin/perl -w
#

sub enumerate {
    my ($n, $deg, $sofar, $data, 
        $pos, $match, $verif) = @_;

    my $vert;
    if($verif == 1){
        for($vert=1; $vert <= $n; $vert++){
            last if $deg->[$vert] == 1;
        }

        $$match++ if $vert == $n+1;
    }

    return if $pos >= scalar(@$data);

    return if $pos > 0 &&
        $data->[$pos]->[0] > $data->[$pos-1]->[0] &&
        $deg->[$data->[$pos-1]->[0]] == 1;

    enumerate($n, $deg, $sofar, $data, $pos+1, $match, 0);

    my ($u, $v) = @{$data->[$pos]};

    $deg->[$u]++; $deg->[$v]++;
    push @$sofar, $data->[$pos];

    enumerate($n, $deg, $sofar, $data, $pos+1, $match, 1);

    pop @$sofar;
    $deg->[$u]--; $deg->[$v]--;

    1;
}

 MAIN: {
     my $mx = int(shift || 5);

     for(my $n=1; $n <= $mx; $n++){
         my @srcdata;

         for(my $u=1; $u <= $n; $u++){
             for(my $v=$u+1; $v <= $n; $v++){
                 push @srcdata, [$u, $v];
             }
         }

         my $noendp = 0; my @degsrc = (0) x ($n+1);
         enumerate($n, \@degsrc, [], 
                   \@srcdata, 0, \$noendp, 1);

         print "$n: $noendp\n";
     }

     1;
}

The output was the following table:

1: 1
2: 1
3: 2
4: 15
5: 314
6: 13757
7: 1142968
8: 178281041

On the other hand Maple says:

> XGF := exp(z^2/2)*add((z/exp(z))^n*2^binomial(n,2)/n!, n=0..12):
> seq(n!*coeftayl(XGF, z=0, n), n=0..8);
                  1, 1, 1, 2, 15, 314, 13757, 1142968, 178281041

We would use recurrence relations to extract higher values.

Addendum, Sep 26, 2016. As per request we now treat the case of graphs having one endpoint. The species equation now becomes

$$\textsc{SET}(\mathcal{Z}) \times \textsc{SET}(-\mathcal{Z} + \mathcal{B}(\mathcal{Z}))^{\Large\star} \times \mathcal{P}(\mathcal{Z}).$$

This reads from left to right (the star denotes marking), first, a set of singletons, second a set of connected graphs with no endpoints where a node is marked and third, a rooted path (species $\mathcal{P}$), not empty, that is attached at the marked node. Now observe that there are $n!$ rooted paths on $n$ nodes and hence

$$P(z) = \sum_{n\ge 1} n! \frac{z^n}{n!} = \frac{z}{1-z}.$$

We thus obtain for the generating function (we mark using the operator $z\frac{d}{dz}$)

$$\exp(z) \frac{z}{1-z} z \left(\exp \left(-z + \log A(z)\right)\right)' \\ = \exp(z) \frac{z}{1-z} z \left(A(z) \exp(-z)\right)' \\ = \exp(z) \frac{z}{1-z} z (A'(z) \exp(-z) - A(z) \exp(-z)) \\ = \frac{z^2}{1-z} (A'(z)-A(z)).$$

These data can be verified with the following Perl script (not the simplest possible but optimized to produce the value for $n=8$).

#! /usr/bin/perl -w
#

sub enumerate {
    my ($n, $k, $endp, $deg, $sofar, $data, 
        $pos, $match, $verif) = @_;

    $$match++ if ($verif == 1 && $endp == $k);

    return if $pos >= scalar(@$data);

    if($pos > 0 &&
       $data->[$pos]->[0] > $data->[$pos-1]->[0]){
        my $epcount = 0;

        for(my $vert = 1; 
            $vert < $data->[$pos]->[0]; $vert++){
            $epcount++ if $deg->[$vert] == 1;
        }

        return if $epcount > $k;
    }

    enumerate($n, $k, $endp, $deg, 
              $sofar, $data, $pos+1, $match, 0);

    my ($u, $v) = @{$data->[$pos]};

    $deg->[$u]++; $deg->[$v]++;

    $endp++ if $deg->[$u] == 1;
    $endp-- if $deg->[$u] == 2;

    $endp++ if $deg->[$v] == 1;
    $endp-- if $deg->[$v] == 2;    

    push @$sofar, $data->[$pos];

    enumerate($n, $k, $endp, $deg, 
              $sofar, $data, $pos+1, $match, 1);

    pop @$sofar;

    $endp-- if $deg->[$u] == 1;
    $endp++ if $deg->[$u] == 2;

    $endp-- if $deg->[$v] == 1;
    $endp++ if $deg->[$v] == 2;    

    $deg->[$u]--; $deg->[$v]--;

    1;
}

 MAIN: {
     my $mx = int(shift || 5);
     my $epsrch = int(shift || 0);

     for(my $n=1; $n <= $mx; $n++){
         my @srcdata;

         for(my $u=1; $u <= $n; $u++){
             for(my $v=$u+1; $v <= $n; $v++){
                 push @srcdata, [$u, $v];
             }
         }

         my $noendp = 0; my @degsrc = (0) x ($n+1);
         enumerate($n, $epsrch, 0, \@degsrc, [], 
                   \@srcdata, 0, \$noendp, 1);

         print "$n: $noendp\n";
     }

     1;
}

This produced the following table:

1: 0
2: 0
3: 0
4: 12
5: 320
6: 10890
7: 640836
8: 68362504

Maple says:

> XS := series(z^2/(1-z)*(diff(XGF, z)-XGF), z=0, 9):
> seq(n!*coeff(XS, z, n), n=1..8);
                   0, 0, 0, 12, 320, 10890, 640836, 68362504

We can also treat the problem of enumerating labeled graphs with two endpoints. Now there are three cases: first case, a set of singletons, an unrooted path on at least two nodes and a set of connected components with no endpoints. We get

$$\exp(z) \times \frac{1}{2} \frac{z^2}{1-z} \times \exp(-z + \log A(z)) = \frac{1}{2} \frac{z^2}{1-z} A(z).$$

Second, a set of singletons and two rooted paths attached to two different nodes from a set of connected components with no endpoints. This yields

$$\exp(z) \times \frac{z^2}{(1-z)^2} \times \frac{1}{2} z^2 \frac{d}{dz} \frac{d}{dz} \exp(-z + \log A(z)) \\ = \exp(z) \times \frac{z^2}{(1-z)^2} \times \frac{1}{2} z^2 \frac{d}{dz} \frac{d}{dz} \exp(-z) A(z) \\ = \exp(z) \times \frac{z^2}{(1-z)^2} \times \frac{1}{2} z^2 \frac{d}{dz} (\exp(-z) A'(z) - \exp(-z) A(z)) \\ = \exp(z) \times \frac{z^2}{(1-z)^2} \\ \times \frac{1}{2} z^2 (\exp(-z) A''(z) - 2\exp(-z) A'(z) + \exp(-z) A(z)) \\ = \frac{1}{2} \frac{z^4}{(1-z)^2} (A''(z) - 2A'(z) + A(z)).$$

Third, a set of singletons and a fork attached to a node of a set of connected components with no endpoints. The fork is

$$\frac{1}{2} \frac{1}{1-z} \frac{z^2}{(1-z)^2}$$

(the first term is the handle) which yields

$$\exp(z) \times \frac{1}{2} \frac{z^2}{(1-z)^3} \times z\frac{d}{dz} \exp(-z + \log A(z)) \\ = \exp(z) \times \frac{1}{2} \frac{z^2}{(1-z)^3} \times z\frac{d}{dz} \exp(-z) A(z) \\ = \exp(z) \times \frac{1}{2} \frac{z^2}{(1-z)^3} \times z(\exp(-z) A'(z) - \exp(-z) A(z)) \\ = \frac{1}{2} \frac{z^3}{(1-z)^3} (A'(z) - A(z)).$$

Collecting everything we obtain

$$\frac{1}{2} \frac{z^2}{1-z} A(z) \\ + \frac{1}{2} \frac{z^4}{(1-z)^2} (A''(z) - 2A'(z) + A(z)) \\ + \frac{1}{2} \frac{z^3}{(1-z)^3} (A'(z) - A(z)).$$

The Perl script will produce the following table:

1: 0
2: 1
3: 6
4: 30
5: 260
6: 5445
7: 228564
8: 17288852

while Maple says:

> K1 := 1/2*z^2/(1-z)*XGF:
> K2 := 1/2*z^4/(1-z)^2*(diff(XGF, z$2)-2*diff(XGF,z)+XGF):
> K3 := 1/2*z^3/(1-z)^3*(diff(XGF, z)-XGF):
> XS := series(K1+K2+K3, z=0, 9):
> seq(n!*coeff(XS, z, n), n=1..8);
                   0, 1, 6, 30, 260, 5445, 228564, 17288852

All of these need careful checking as it is possible that errors in the species decomposition might only become apparent with large values of $n.$

Addendum, Sep 27, 2016. To enhance this post and make it more useful we now treat the case of graphs having three endpoints. Observe that these calculations are conjectural in nature and require independent verification, most likely through recurrence relations.

First case, set of singletons, a star (union of three paths) and a set of connected components with no endpoints. We get

$$\exp(z)\times \frac{1}{6} z \frac{z^3}{(1-z)^3} \times \exp(-z+\log A(z)) = \frac{1}{6} \frac{z^4}{(1-z)^3} A(z).$$

Second case, a set of singletons, an unrooted path and a set of connected components with one node marked to which a path is attached. We have

$$\exp(z)\times \frac{1}{2}\frac{z^2}{1-z} \times \frac{z}{1-z} \times z\frac{d}{dz} \exp(-z+\log A(z)) \\ = \frac{1}{2}\frac{z^4}{(1-z)^2} (A'(z)-A(z)).$$

Third case, a set of singletons and three rooted paths attached to three marked nodes from the set of connected components with no endpoints.

$$\exp(z)\times \frac{z^3}{(1-z)^3} \times \frac{1}{6} z^3\frac{d}{dz}\frac{d}{dz}\frac{d}{dz} \exp(-z+\log A(z)) \\ = \frac{1}{6} \frac{z^6}{(1-z)^3} (A'''(z)-3A''(z)+3A'(z)-A(z)).$$

Fourth case, a set of singletons, a rooted path and a fork attached to two marked sites among the components with no endpoints (no symmetry between the path and the fork):

$$\exp(z) \times \frac{z}{1-z} \times \frac{1}{2} \frac{1}{1-z} \frac{z^2}{(1-z)^2} \times z^2 \frac{d}{dz}\frac{d}{dz} \exp(-z+\log A(z)) \\ = \frac{1}{2} \frac{z^5}{(1-z)^4} (A''(z)-2A'(z)+A(z)).$$

Fifth case, singletons, and a triple fork attached to a marked site among the components with no endpoints.

$$\exp(z)\times \frac{1}{6} \frac{1}{1-z}\frac{z^3}{(1-z)^3} \times z\frac{d}{dz} \exp(-z+\log A(z)) \\= \frac{1}{6} \frac{z^4}{(1-z)^4} (A'(z)-A(z)).$$

Finally, a repeat, but with the fork branching two times, which is the handle, possibly empty, to which are attached two paths, one of which forks:

$$\frac{1}{1-z} \times \frac{z}{1-z} \frac{z}{1-z} \times \frac{1}{2} \frac{z}{1-z}\frac{z}{1-z}$$

for a contribution of

$$\exp(z)\times \frac{1}{2} \frac{z^4}{(1-z)^5} \times z\frac{d}{dz} \exp(-z+\log A(z)) \\= \frac{1}{2} \frac{z^5}{(1-z)^5} (A'(z)-A(z)).$$

Collect these six to get the desired EGF.

Here the Perl script will produce the table

1: 0
2: 0
3: 0
4: 4
5: 80
6: 1860
7: 64680
8: 3666600

and Maple says

> K1 := 1/6*z^4/(1-z)^3*XGF:
> K2 := 1/2*z^4/(1-z)^2*(diff(XGF,z)-XGF):
> K3 := 1/6*z^6/(1-z)^3*(diff(XGF, z$3)-3*diff(XGF, z$2)+3*diff(XGF,z)-XGF):
> K4 := 1/2*z^5/(1-z)^4*(diff(XGF, z$2)-2*diff(XGF,z)+XGF):
> K5 := 1/6*z^4/(1-z)^4*(diff(XGF,z)-XGF):
> K6 := 1/2*z^5/(1-z)^5*(diff(XGF,z)-XGF):
> XS := series(K1+K2+K3+K4+K5+K6, z=0, 9):
> seq(n!*coeff(XS, z, n), n=1..8);
                       0, 0, 0, 4, 80, 1860, 64680, 3666600
Marko Riedel
  • 61,317
  • @ Marko Riedel. Thank you. I was going to suggest that you add this as a link in the OEIS entry but I see that you have. This will be very helpful to a lot of people as it was for me. – Geoffrey Critzer Sep 24 '16 at 21:57
  • Thank you for the kind remark. I enjoyed consulting the paper by Read referenced by Harary which is from an era where some mathematical papers were typeset on a typewriter. (Difficult to imagine a world without LaTeX, just think how error-prone this process must have been especially if the author did not typeset their own paper.) Nonetheless all the ideas presented above are already present in this work (the paper by Read). – Marko Riedel Sep 24 '16 at 22:05
  • As a follow-up question: I want to count the number of labeled graphs with exactly one vertex of degree one. Would you agree that the e.g.f. is: – Geoffrey Critzer Sep 25 '16 at 12:39
  • A(z) * z * z * d[B(z) - z]/dz For n=0,1,2,... this gives the coefficients 0,0,0,0,12,260,8970. But this sequence is not in OEIS. – Geoffrey Critzer Sep 25 '16 at 12:48
  • Thank you for pointing me to this additional problem and returning to what we have, in fact there were some issues with what I had posted which are now fixed. I hope you will be able to verify the generating function for the case of one endpoint. – Marko Riedel Sep 26 '16 at 03:11
  • I have also treated the case of two endpoints. – Marko Riedel Sep 26 '16 at 04:41
  • In the second sentence in the Addendum. You have "... first, a set of singletons ... I think it should be a set of connected graphs with no endpoints. In other words I think the e.g.f is A(z)z/(1-z)z*d[B(z)-z)]/dz. – Geoffrey Critzer Sep 26 '16 at 14:19
  • I will look into this but note that the series from your EGF produces $72$ graphs with no endpoints on four nodes, which is more than the $2^{4\choose 2} =64$ available graphs, so it cannot possibly be right. Did you notice that my data from the Perl script match the EGF? – Marko Riedel Sep 26 '16 at 17:25
  • Using the e.g.f : A(z)z/(1-z)z*d[B(z)-z)]/dz. I get the first few terms (indexed from n=0): 0, 0, 0, 0, 12, 320, 10890, 640836, 68362504, 13369203792, 4852623272670, 3314874720579180, 4318786169776866612, 10854838945689940034808. I verified the terms for n=4,5,6,7 using Mathematica's built in graph data. I also verified the cases up to n=7 for graphs with exactly 2 endpoints with what you have posted above. – Geoffrey Critzer Sep 26 '16 at 22:37
  • I must have made a mistake when I computed the series. Using what I have $$\frac{z^2}{1-z} (A'(z)-A(z))$$ and $A(z) = \exp B(z)$ we obtain $$\frac{z^2}{1-z} (A(z) B'(z) - A(z)) = \frac{z^2}{1-z} A(z) \frac{d}{dz} (B(z)-z)$$ which is your version. Perfect. Of course your species equation is correct too. Do you want to write the two OEIS entries (one endpoint, two endpoints) or should I? – Marko Riedel Sep 26 '16 at 22:47
  • In case you are interested I went through my archives and discovered I had made a mistake entering your EGF into Maple. Maple agrees with your data once the error is corrected. – Marko Riedel Sep 26 '16 at 22:58
  • I present the case of three endpoints for your consideration. – Marko Riedel Sep 27 '16 at 04:40
  • @ Marko Riedel. Thanks for your excellent work here. If you will submit these sequences to OEIS I will add a Mathematica code and perhaps an example that might embellish the entries. – Geoffrey Critzer Sep 27 '16 at 16:25
  • These three are now in the draft queue with IDs A277072, A277073, A277074. – Marko Riedel Sep 27 '16 at 23:08
  • I do hope with them being visible on the OEIS that someone checks my work on three endpoints, possibly with a diagram of the six cases. – Marko Riedel Sep 27 '16 at 23:21
  • I do not understand your species equation for graphs with exactly one endpoint. You write "This reads from left to right (the star denotes marking), first, a set of singletons, second a set of connected graphs with no endpoints where a node is marked and third, a rooted path (species P), not empty, that is attached at the marked node." How does this give us a graph with one endpoint? The species equation translation for my e.g.f would read: A set of connected graphs with no endpoints with exactly one such graph (of size 3 or more) having marked vertices to which a rooted path is joined. – Geoffrey Critzer Oct 01 '16 at 21:37
  • I honestly don't know what to say, I thought this follows by inspection. The one endpoint is of course the free end of the path. We cannot attach to the singletons because that would produce two endpoints. – Marko Riedel Oct 01 '16 at 21:41
  • OK, I just now "got it". You are right. It does follow by inspection. It is interesting to note the two different ways to make the construction. – Geoffrey Critzer Oct 01 '16 at 22:50