indent2graph - Generate graph out of whitespace-indented hierarchical text



NAME

indent2graph - Generate graph out of whitespace-indented hierarchical text


SYNOPSIS

indent2graph < tree.txt > tree.dot


DESCRIPTION

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


EXAMPLE

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      | +-----------+
       +------------+


OPTIONS

-f, --format FORMAT

Output format.

dot (default)

The graphviz(1) (dot(1)) format.

pairs

Simple TAB-separated node name pairs, each describes a graph edge, 1 per line.

clojure

Clojure-style nested vectors (represented as string). Useful for vijual(1).

grapheasy

Graph::Easy(3pl)'s own "txt" format. With graph-easy(1) you can transform further into other formats, like GDL, VCG, ...

mermaid

TODO

-a, --ascendent

Indentation in the input represents ascendents, not descendents. Default is descendent chart. This influences to where arrows point.

-t, --tree

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

-d, --rankdir DIR

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.


SEE ALSO

indent2tree(1), graphviz(1), dot(1), vijual(1), Graph::Easy(3pl)

 indent2graph - Generate graph out of whitespace-indented hierarchical text