Is there a way to draw B-Trees on Graphviz?

梦想与她 提交于 2019-12-10 14:41:59

问题


I am trying to generate something similar to this:

https://upload.wikimedia.org/wikipedia/commons/6/65/B-tree.svg

From a btree in memory... is there any way to generate a graph like that on Graphviz, so that I can generate the *.dot file?

Thanks.


回答1:


Go to http://ysangkok.github.io/js-clrs-btree/btree.html and press "init simple". In the textarea you see Graphviz code for the tree shown above. The algorithm is simple, as you can see.




回答2:


Yes

You can use rankdir and such to set the direction it lays stuff out in.

If you have a directed graph (digraph) that forms a tree (no cycles if direction is ignored) it'll pick up on this for you, you can change the dir of individual nodes using A -> B [dir="backwards"].

That creates a link from A to B but displayed as fro B to A

If you just have "forward links" (not sure on name of graph) where there are no cycles if direction is considered but there can be if direction is ignored (A->B->C and A->D->C is an example of this) it'll still put it in layers for you.

Once again: yes.



来源:https://stackoverflow.com/questions/19985946/is-there-a-way-to-draw-b-trees-on-graphviz

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!