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.
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.
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 usingA -> 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.
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.