left right subtrees

Visto 22 veces
Saltar al primer mensaje no leído

dominique...@univ-lehavre.fr

no leída,
25 nov 2014, 7:56:3525/11/14
a sage-n...@googlegroups.com
Hi,

I would like to get a left and right subtree from a vertice.
First i used Graph abd option layout. The graph don't respect the order of suns.

g=DiGraph({"*":["+","-"],"-":["d","c"],"+":["a","b"]})

g.order(), g.size()
g.vertices()
g.edges()
g.show(layout='tree')

Does someone have an idea? How to plot the tree in order abd get right and left subtrees?
Dominique

kcrisman

no leída,
25 nov 2014, 8:33:3925/11/14
a sage-n...@googlegroups.com,sage-s...@googlegroups.com

Hi!  I don't think this is necessarily a notebook question, so I'm forwarding this to sage-support where it is morel likely to get some responses.  Good luck!

Harald Schilly

no leída,
25 nov 2014, 9:23:3225/11/14
a sage-n...@googlegroups.com,sage-s...@googlegroups.com


On Tuesday, November 25, 2014 2:33:39 PM UTC+1, kcrisman wrote:

Hi!  I don't think this is necessarily a notebook question, so I'm forwarding this to sage-support where it is morel likely to get some responses.  Good luck!

I did the reverse, and invited Nathann to help Dominique. ;-)

--h

Nathann Cohen

no leída,
25 nov 2014, 9:25:2525/11/14
a sage-n...@googlegroups.com
Hello !

> I would like to get a left and right subtree from a vertice.
> First i used Graph abd option layout. The graph don't respect the order of suns.
>
> g=DiGraph({"*":["+","-"],"-":["d","c"],"+":["a","b"]})

No, it does not, for digraphs interpret the list of neighbors of a vertex as a set, not as a list. If you want to get the drawing you expect with this class, I am afraid that you will have to specify the coordinates of each point manually (see g.get_pos(), g.set_pos()).

On the other hand, I believe that there is in Sage a class named BinaryTree:

http://www.sagemath.org/doc/reference/combinat/sage/combinat/binary_tree.html

This being said, it does not seem possible to define labels on its nodes.

Truth is, I am a bit embarassed for I know nothing in Sage which can do that. If it were to be implemented, I think that it should be in one of the classes that you will find in the "Tree" section of the following page

http://www.sagemath.org/doc/reference/combinat/index.html

But my attempts showed me that no specific plot function was defined on them.

You should probably write to sage-devel about that. The data structure that you want, however, is not only a digraph for you insist on having an order on the neighbors of a vertex.

Actually, this information (i.e. an ordering of the neighborhood of each vertex) is called the "combinatorial embedding" of a graph. But then Sage would consider your graph as a planar graph (not a tree) and plot it in consequence... You would find the root anywhere on the picture, the distances would not be respected... Not a good idea either, sorry ^^;

Nathann
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos