# Revision history [back]

### tree ordering in sage

I am using the following code to generate the isomorphism class of trees of order $n$.

sage: from sage.graphs.trees import TreeIterator

sage: def check_trees(n):

....: trees = []

....: for t in TreeIterator(n):

....: if not t.is_tree():

....: return False

....: if t.num_verts() != n:

....: return False

....: if t.num_edges() != n - 1:

....: return False

....: for tree in trees:

....: if tree.is_isomorphic(t):

....: return False

....: trees.append(t)

....: return True

Then when I print the trees in TreeIterator using loops it is giving the trees in a particular order. Can anyone explain to me what is this predefined order on trees of order $n$ on sage?

### tree ordering in sage

I am using the following code to generate the isomorphism class of trees of order $n$.

sage: from sage.graphs.trees import TreeIterator

sage: def check_trees(n):

....: trees = []

....: for t in TreeIterator(n):

....: if not t.is_tree():

....: return False

....: if t.num_verts() != n:

....: return False

....: if t.num_edges() != n - 1:

....: return False

....: for tree in trees:

....: if tree.is_isomorphic(t):

....: return False

....: trees.append(t)

....: return True

Then when I print the trees in TreeIterator using loops it is giving the trees in a particular order.

Can anyone explain to me what is this predefined order on trees of order $n$ on sage?

### tree ordering in sage

I am using the following code to generate the isomorphism class of trees of order $n$.

sage: from sage.graphs.trees import TreeIterator

sage: def check_trees(n):

....: trees = []

....: for t in TreeIterator(n):

....: if not t.is_tree():

....: return False

....: if t.num_verts() != n:

....: return False

....: if t.num_edges() != n - 1:

....: return False

....: for tree in trees:

....: if tree.is_isomorphic(t):

....: return False

....: trees.append(t)

....: return True

Then when I print the trees in TreeIterator using loops it is giving the trees in a particular order.

Can anyone explain to me what is this predefined order on trees of order $n$ on sage?

For n = 6, we have the following order.

(/upfiles/15651618223765723.png)

### tree ordering in sage

I am using the following code to generate the isomorphism class of trees of order $n$.

sage: from sage.graphs.trees import TreeIterator

sage: def check_trees(n):

....: trees = []

....: for t in TreeIterator(n):

....: if not t.is_tree():

....: return False

....: if t.num_verts() != n:

....: return False

....: if t.num_edges() != n - 1:

....: return False

....: for tree in trees:

....: if tree.is_isomorphic(t):

....: return False

....: trees.append(t)

....: return True

Then when I print the trees in TreeIterator using loops it is giving the trees in a particular order.

Can anyone explain to me what is this predefined order on trees of order $n$ on sage?

For n = 6, we have the following order.

(/upfiles/15651618223765723.png)

 5 None Iguananaut 1708 ●8 ●33 ●55

### tree ordering in sage

I am using the following code to generate the isomorphism class of trees of order $n$.

sage: from sage.graphs.trees import TreeIterator TreeIterator
sage: def check_trees(n): check_trees(n):
....:     trees = [] []
....:     for t in TreeIterator(n): TreeIterator(n):
....:         if not t.is_tree(): ....:             return False t.is_tree():
....:             return False
....:         if t.num_verts() != n: ....:             return False n:
....:             return False
....:         if t.num_edges() != n - 1: ....:             return False 1:
....:             return False
....:         for tree in trees: trees:
....:             if tree.is_isomorphic(t): ....:                 return False ....:         trees.append(t) ....:     return Truetree.is_isomorphic(t):
....:                 return False
....:         trees.append(t)
....:     return True


Then when I print the trees in TreeIterator using loops it is giving the trees in a particular order.

Can anyone explain to me what is this predefined order on trees of order $n$ on sage?

For n = 6, we have the following order.

 6 retagged FrédéricC 5151 ●3 ●43 ●112

### tree ordering in sage

I am using the following code to generate the isomorphism class of trees of order $n$.

sage: from sage.graphs.trees import TreeIterator
sage: def check_trees(n):
....:     trees = []
....:     for t in TreeIterator(n):
....:         if not t.is_tree():
....:             return False
....:         if t.num_verts() != n:
....:             return False
....:         if t.num_edges() != n - 1:
....:             return False
....:         for tree in trees:
....:             if tree.is_isomorphic(t):
....:                 return False
....:         trees.append(t)
....:     return True


Then when I print the trees in TreeIterator using loops it is giving the trees in a particular order.

Can anyone explain to me what is this predefined order on trees of order $n$ on sage?

For n = 6, we have the following order.