Here is a SageMath code generating caterpillar graphs on $n$ nodes based on enriching a path graph with leaves. As an example it shows all such graphs on 6 nodes.
Max Alekseyev
- 34.3k
- 5
- 74
- 152