TITLE: number of weighted trivalent trees
QUESTION [6 upvotes]: Given a trivalent tree (graph without loops with valence of 3+ at each vertex) on N marked points, let's assign to each vertex the number (its valence - 3)!  (note the ! at the end). Take the product of these numbers over all vertices in the graph. Sum the resulting products over all trivalent graphs on N marked points. The answer seems to be $(N-2)^{N-2}$. I would guess this is well-known. Is there something I can reference? Thanks.

REPLY [3 votes]: This is just building off the previous discussion --  I will just give some indication of why Dan's $f$ and $g$  are Legendre transforms of each other.  This is essentially a fleshed out version of some of what Frédéric was saying that I wanted to work out in detail -- it would look too small and ugly as a comment.  
We're going to use some basic facts about the Lambert W-function.Lambert W-function and the Legendre transformation, but nothing past what you can find in those Wikipedia links.
First, showing that $f$ and $g$ are Legendre transforms of each other is essentially showing that their derivatives are compositional inverses of each other.  So we will show this for $f^\prime$ and $g^\prime$, and not use anything else about the Legendre transformation.
The Lambert $W$ function $W(x)$ is defined by the functional equation $x=W e^W$. You recognize it's coming into play when you start seeing $n^n$ terms, as they show up in the taylor expansion of it and simple expressions related to it.  In particular, wikipedia tells us that:
$$\left(\frac{W}{x}\right)^r = e^{-rW}=\sum_{n\geq 0} r(n+r)^{(n-1)} \frac{(-x)^n}{n!}$$
The first equation is the functional equation, and in general to get the taylor expression you want to use  Lagrange inversion and the functional equation.
In any case, if we set $r=-1$, take $0^0=1$ and hopefully not make any sign errors, we should obtain
$$g^\prime(x)=1-e^{W(-x)}.$$
Simple calculus gives
$$f^\prime=-(1-x)\ln(1-x).$$
From these expressions it is immediate that $f^\prime(g^\prime(x))=x$ by using the functional equation for $W$.