# treegraph – Elegant implementation of a factor graph

Consider the tree graph used in part of my solution to this question:

Each level $$i$$ at $$i!$$ nodes, and the connection rate is $$i + 1$$:

I've kludged all the code to generate this graph (with better code let not reproduced).

Is there an elegant way to generate such a tree graph for an arbitrary number of levels?