How to count vertices (or edges) using `anytree`?

123 Views Asked by At

I would like to determine the size of a tree by number of vertices.

Clearly,

len(list(PreOrderIter(root)))

gives me this number.

Is this the way to do it?

In other words, is there a recommended dedicated function or something for this in anytree?

Can the above be possibly more efficient somehow?

0

There are 0 best solutions below