| indent2graph - Generate graph out of whitespace-indented hierarchical text |
indent2graph - Generate graph out of whitespace-indented hierarchical text
indent2graph < tree.txt > tree.dot
Take line-based input, and output a directed graph in a given format, eg. dot(1) (see graphviz(1)).
Each input line is a node.
How much the line is indented (by leading spaces or TABs) determines its relation to the nodes of the surrounding lines.
Lines which are indented to the same level, go to the same rank on the tree-like graph in the output.
The graph may contain loops:
lines with the same text (apart from the leading whitespace) are considered the same node
(except when --tree option is set).
Input:
/usr/bin/ssh
libselinux
libpcre2-8
libgssapi_krb5
libkrb5
libkeyutils
libresolv
libk5crypto
libcom_err
libkrb5support
libcrypto
libz
libc
Command:
indent2graph -f clojure | vijual draw-tree -
Output:
+------------+
| /usr/bin/s |
| sh |
+-----+------+
|
+------------------------+----+---------+----------+--------+
| | | | |
+-----+------+ +-----+------+ +-----+-----+ +--+---+ +--+---+
| libselinux | | libgssapi_ | | libcrypto | | libz | | libc |
+-----+------+ | krb5 | +-----------+ +------+ +------+
| +-----+------+
| |
| +----------+-+--------------+--------------+
+-----+------+ | | | |
| libpcre2-8 | +----+----+ +-----+------+ +-----+------+ +-----+------+
+------------+ | libkrb5 | | libk5crypt | | libcom_err | | libkrb5sup |
+----+----+ | o | +------------+ | port |
| +------------+ +------------+
+--------+-----+
| |
+-----+------+ +-----+-----+
| libkeyutil | | libresolv |
| s | +-----------+
+------------+
Output format.
The graphviz(1) (dot(1)) format.
Simple TAB-separated node name pairs, each describes a graph edge, 1 per line.
Clojure-style nested vectors (represented as string).
Useful for vijual(1).
Graph::Easy(3pl)'s own "txt" format. With graph-easy(1) you can transform further into other formats, like GDL, VCG, ...
TODO
Indentation in the input represents ascendents, not descendents. Default is descendent chart. This influences to where arrows point.
Interpret input strictly as a tree with no cycles. By default, without --tree, lines with the same text represent the same node, so you can build arbitrary graph. With --tree, you can build a tree-like graph in which different nodes may have the same text (label).
This is the dot(1) graph's rankdir parameter.
This option is although specific to dot(1) format,
but translated to grapheasy if it is the chosen output format.
DIR is one of TB, BT, LR, RL.
Default is LR ie. left-to-right.
See graphviz(1) documentation for details.
indent2tree(1), graphviz(1), dot(1), vijual(1), Graph::Easy(3pl)