Graphviz and ascii output

二次信任 提交于 2020-01-11 15:25:12

问题


Is it possible to draw ASCII diagram using Graphviz?

Something like that:

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

Gives undesired result.

Instead, I would like to get similar ASCII representation:

   this
  /    \
is      a
        |
       test

How to draw ascii diagrams from dot-files format?


回答1:


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 dotfile.dot   | /opt/local/libexec/perl5.12/sitebin/graph-easy



回答2:


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



回答3:


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

on MacOS with homebrew install docker

$ brew install docker

Install whalebrew - https://github.com/whalebrew/whalebrew

$ curl -L "https://github.com/whalebrew/whalebrew/releases/download/0.1.0/whalebrew-$(uname -s)-$(uname -m)" -o /usr/local/bin/whalebrew; chmod +x /usr/local/bin/whalebrew

Install graph-easy via whalebrew

$ whalebrew install tsub/graph-easy

Now run it via

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

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


来源:https://stackoverflow.com/questions/3211801/graphviz-and-ascii-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!