user360872
user360872

Reputation: 1361

Graphviz and ASCII output

Is it possible to draw an ASCII diagram using Graphviz?

Something like this as input...

digraph d
{
  this -> is
  this -> a
  a -> test
}

...gives undesired result.

Instead, I would like to get similar ASCII representation as desired output:

   this
  /    \
is      a
        |
       test

How to draw ASCII diagram output from DOT file input?

Upvotes: 90

Views: 26795

Answers (5)

spenthil
spenthil

Reputation: 3493

Try Perl graph-easy via homebrew

If you are not perl averse, graph-easy (and the associated Graph::Easy package) can do exactly that:

http://search.cpan.org/~tels/Graph-Easy/

http://search.cpan.org/~tels/Graph-Easy/bin/graph-easy

On Mac you can install this with Homebrew and cpan:

brew install cpanminus
cpan Graph::Easy

It's easy to invoke after installation:

$ cat this-is-a-test.dot
digraph d
{
  this -> is
  this -> a
  a -> test
}
$ $ cat this-is-a-test.dot | /opt/local/libexec/perl5.12/sitebin/graph-easy
+----+     +------+
| is | <-- | this |
+----+     +------+
             |
             |
             v
           +------+
           |  a   |
           +------+
             |
             |
             v
           +------+
           | test |
           +------+

Upvotes: 56

Cpp Forever
Cpp Forever

Reputation: 970

Try Perl graph-easy via apt

Here is equivalent commands for linux:

First install cpanminus

sudo apt install cpanminus

After you can install GraphEasy

sudo cpanm Graph::Easy

Here is a sample usage

cat input.dot | graph-easy --from=dot --as_ascii

Upvotes: 16

mirageglobe
mirageglobe

Reputation: 3104

Try graph-easy via docker

Using graph-easy via docker. You can install whalebrew and use it to run graph-easy without installing too much dependancies on your local machine other than whalebrew and docker.

on MacOS with homebrew install docker

$ brew install docker
$ docker -v      # check if docker is running

Install whalebrew - https://github.com/whalebrew/whalebrew (check installation alternatives)

$ brew install whalebrew

Install graph-easy via whalebrew

$ whalebrew install tsub/graph-easy

Now run it via

$ echo '[a]->[b]' | graph-easy

+---+     +---+
| a | --> | b |
+---+     +---+

Upvotes: 13

Georgi Gerganov
Georgi Gerganov

Reputation: 1066

Another option to use Graph::Easy's ASCII functionality is directly from your browser through this small service that I hosted:

https://dot-to-ascii.ggerganov.com

Upvotes: 17

Christian Fritz
Christian Fritz

Reputation: 21364

By now, in ubuntu, you can install and use graph-easy directly:

> sudo apt install libgraph-easy-perl
[...]

> graph-easy dotfile.dot 
+----+     +------+
| is | <-- | this |
+----+     +------+
             |
             |
             v
           +------+
           |  a   |
           +------+
             |
             |
             v
           +------+
           | test |
           +------+

Upvotes: 21

Related Questions