How to generate trees with 11 and 12 vertices (with diagrams)?

116 Views Asked by At

I looked at this thread, but I couldn't seem to understand how to use geng and nauty to generate trees and get the diagrams. I need to generate trees with 11 and 12 vertices and possibly with more vertices, and I would need the diagrams because I need to mark the color of each node.

Does anyone know a software where I can generate trees with n vertices (where n > 10) with a diagram? If diagrams are not possible, does anyone have a suggestion as to how I could efficiently mark each node in the tree without a diagram? This is part of my independent study. Thank you in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

One option is to use python, specifically networkx's generate and draw functions. As an example, to draw all (non-isomorphic) trees on 6 vertices, you can do:

import networkx as nx
import matplotlib.pyplot as plt
t = list(nx.nonisomorphic_trees(6))
fig, axs = plt.subplots(1, 6)
[nx.draw(t[i], ax=axs[i]) for i in range(6)]
plt.show()

This gives the following (quite crude!) image:

enter image description here

Which is maybe not the nicest tree layout, but at least shows what we want. Of course, according to A000055 there are 235 trees on 11 vertices so I assume you want them in separate images - this is certainly possible with NetworkX - and colouring the vertices can also be done.