是否可以使用Graphviz绘制ASCII图?
像这样的东西:
digraph
{
this -> is
this -> a
a -> test
}
Run Code Online (Sandbox Code Playgroud)
给出以下图片:
图http://img15.imageshack.us/img15/6985/asciia.png
但我想获得ASCII表示:
this
/ \
is a
|
test
Run Code Online (Sandbox Code Playgroud)
也许你知道其他工具可以理解点文件格式并可以绘制ascii图表吗?
spe*_*hil 41
如果你不是厌恶,那么graph-easy(以及相关的Graph::Easy包)可以做到这一点:
http://search.cpan.org/~tels/Graph-Easy/
http://search.cpan.org/~tels/Graph-Easy/bin/graph-easy
在Mac上,您可以使用Homebrew和cpan安装它:
brew install cpanminus
cpan Graph::Easy
Run Code Online (Sandbox Code Playgroud)
安装后很容易调用:
cat dotfile.dot | /opt/local/libexec/perl5.12/sitebin/graph-easy
Run Code Online (Sandbox Code Playgroud)
通过 docker 使用 graph-easy。您可以安装whalebrew 并使用它来运行graph-easy,而无需在本地机器上安装whalebrew 和docker 以外的太多依赖项。
在 MacOS 上使用 homebrew install docker
$ brew install docker
$ docker -v # check if docker is running
Run Code Online (Sandbox Code Playgroud)
安装whalebrew - https://github.com/whalebrew/whalebrew(检查安装替代方案)
$ brew install whalebrew
Run Code Online (Sandbox Code Playgroud)
通过whalebrew安装graph-easy
$ whalebrew install tsub/graph-easy
Run Code Online (Sandbox Code Playgroud)
现在通过
$ echo '[a]->[b]' | graph-easy
+---+ +---+
| a | --> | b |
+---+ +---+
Run Code Online (Sandbox Code Playgroud)
这是Linux的等效命令:
首先安装cpanminus
sudo apt install cpanminus
Run Code Online (Sandbox Code Playgroud)
可以安装GraphEasy之后
sudo cpanm Graph::Easy
Run Code Online (Sandbox Code Playgroud)
这是一个示例用法
cat input.dot | graph-easy --from=dot --as_ascii
Run Code Online (Sandbox Code Playgroud)
至此,在ubuntu中,您可以直接安装和使用graph-easy:
> sudo apt install libgraph-easy-perl
[...]
> graph-easy dotfile.dot
+----+ +------+
| is | <-- | this |
+----+ +------+
|
|
v
+------+
| a |
+------+
|
|
v
+------+
| test |
+------+
Run Code Online (Sandbox Code Playgroud)