Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

image description

image description

image description

image descriptionimage description(/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.

image description

image description

image description

image description

image description

image description(/upfiles/15651618223765723.png)

click to hide/show revision 5
None

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 True

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.

image description

image description

image description

image description

image description

image description

click to hide/show revision 6
retagged

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.

image description

image description

image description

image description

image description

image description