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

2019-06-22 14:05发布

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.

标签: graphviz dot
2条回答
Bombasti
2楼-- · 2019-06-22 14:52

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.

查看更多
戒情不戒烟
3楼-- · 2019-06-22 15:00

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.

查看更多
登录 后发表回答