在日常开发中流程图可能用的最多了,相关的工具也非常丰富。但是要说极客非 graph easy 莫属。上手简单,而且支持非常丰富的表达方式。大家可以参考这个教程试一试。

使用

安装 graph easy

1
2
3
4
5
6
7
8
// 1. 
brew install graphviz

// 2. 安装 cpan,一路「回车」
cpan

// 3. 安装 Graph Easy
sudo cpan Graph:Easy

使用

1
graph-easy <<< '[a] -> [b]'

或者

1
graph-easy ./flow.graph

graph easy 教程

For instance this input:

1
2
3
4
5
[ Bonn ] -> [ Berlin ]
[ Berlin ] -> [ Frankfurt ] { border: 1px dotted black; }
[ Frankfurt ] -> [ Dresden ]
[ Berlin ] ..> [ Potsdam ]
[ Potsdam ] =>{label:'true'} [ Cottbus ]

would be rendered in ASCII as:

1
2
3
4
5
6
7
8
9
+------+     +---------+         .............     +---------+
| Bonn | --> | Berlin | ------> : Frankfurt : --> | Dresden |
+------+ +---------+ :...........: +---------+
:
:
v
+---------+ true +-----------+
| Potsdam | ======> | Cottbus |
+---------+ +-----------+

中文问题修复

参考:https://blog.codingnow.com/2016/12/ascii_graph.html

找到 Graph Easy 的安装目录

mdfind -name Easy.pm

默认:/Library/Perl/5.18/Graph/

修改相关代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git /Library/Perl/5.18/Graph/Easy.pm /Library/Perl/5.18/Graph/Easy.pm
index 0ae40fd..b67bacc 100644
--- a/lib/Graph/Easy.pm
+++ b/lib/Graph/Easy.pm
@@ -1570,7 +1570,9 @@ sub as_ascii
# select 'ascii' characters
$self->{_ascii_style} = 0;

- $self->_as_ascii(@_);
+ my $asc = $self->_as_ascii(@_);
+ $asc =~ s/(\x{FFFF})//g;
+ $asc;
}

sub _as_ascii
diff --git /Library/Perl/5.18/Graph/Easy/Node.pm /Library/Perl/5.18/Graph/Easy/Node.pm
index b58f538..6d7d7c7 100644
--- a/lib/Graph/Easy/Node.pm
+++ b/lib/Graph/Easy/Node.pm
@@ -1503,6 +1503,9 @@ sub label

$label = $self->_un_escape($label) if !$_[0] && $label =~ /\\[EGHNT]/;

+ # placeholder for han chars
+ $label =~ s/([\x{4E00}-\x{9FFF}])/$1\x{FFFF}/g;
+
$label;
}