Wow, I feel really lame right now. I was able to do with sage in 2
minuets what took me all day yesterday. Sage has some clear additions
to their graphing library that I complete overlooked. Here is a simple
binary tree with sage. That was too easy.
BinaryTree={0:[1,2,3,4],1:[],2:[],3:[],4:[]}
T=Graph(BinaryTree)
TREE=T.plot(graph_border=True,vertex_size=120, layout="tree",
tree_orientation="down",tree_root=0,vertex_colors="green",edge_colors="red")
TREE.show()
> On Fri, Dec 4, 2009 at 6:55 PM, Trentonknight <
trentonkni...@gmail.com> wrote:
> > Does anyone have the best way to approach creating a binary tree that
> > will allow for the root node to remain on top above the children nodes
> > while the child nodes can be placed smartly on the left and right. It
> > seem strange to me that there are layouts for a massive array of
> > intricate graphs and I cannot even make a proper binary tree. I have
> > played a little with using the pos[0]=[0,0] but I cannot seem to see
> > any reaction from my graphs. Any advice would be greatly appreciated.
> > Any tricks for sage of python graphing at all will also be greatly
> > appreciated. I'm ready to give up and start looking at Boost. Thank
>
> I think you are saying that you want to draw binary tree. NetworkX
> isn't primarily a graph drawing package but you can make some simple
> drawings (seehttp://
networkx.lanl.gov/gallery.html
> )
>
> In particular if you might use the Graphviz "dot" layout algorithm to
> draw a binary tree. You'll need Graphviz + PyGraphviz, or Pydot
> to do that. Here is a slightly modified version ofhttp://
networkx.lanl.gov/examples/drawing/circular_tree.html