Fast generation of graphs from a tree-like structure can be very useful when making notes in org-mode that require sharing and or beautification for other humans.
I couldn't find any way to do this other than to manually create a dynamic dot/graphviz block.
A translation from a structured tree to a simple directed graph should be fairly straightforward.
I'm looking for a simple way to traverse an org-mode tree (a selected region) and to translate the tree structure (and optionally some information from the contents of the structure) to a dot graph.
I can't possibly be the first to have come up with this. Has this been solved?
input
* la1
** la2
*** la3
*** la4
** la5
and perhaps a variable org-to-dot-preamble
digraph {
rankdir=TB;
splines=true;
node [shape=box];
the output would look like an org-mode dynamic block
#+BEGIN_SRC dot :file out.png :cmdline -Kdot -Tpng
(contents of org-to-dot-preamble)
la1 -> la2
la1 -> la5
la2 -> la3
la2 -> la4
}
#+END_SRC
A more advanced version would first declare all the nodes and allow for some formatting.
input
* la1
firstline
secondline
** la2
firstline
secondline
*** la3
*** la4
firstline
** la5
Some formatting variables
org-to-dot-shape
org-to-dot-font
output
#+BEGIN_SRC dot :file out.png :cmdline -Kdot -Tpng
(contents of org-to-dot-preamble)
la1 [shape=Mrecord, label="{firstline|secondline}", fontname = "helvetica"]
la2 [shape=Mrecord, label="{firstline|secondline}", fontname = "helvetica"]
la3 [shape=Mrecord, label="{firstline|secondline}", fontname = "helvetica"]
la4 [shape=Mrecord, label="{firstline|secondline}", fontname = "helvetica"]
la5 [shape=Mrecord, label="{firstline|secondline}", fontname = "helvetica"]
la1 -> la2
la1 -> la5
la2 -> la3
la2 -> la4
}
#+END_SRC