-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrpy2dot.sh
executable file
·56 lines (55 loc) · 1.19 KB
/
rpy2dot.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env zsh
if [ $# -lt 1 ] ; then set *.rpy ; fi
for item in "$@" ; do
echo "subgraph $(echo $item | sed 's/\.rpy$//')"
cat "$item" |
sed 's/^ *//g' |
egrep '^(label|jump)' | egrep -v '[\."]' |
tr -d ':\r' |
grep -v 'label _' | awk '
/^label / {
print "\"" $2 "\""
#if(curr_label)
# print "\"" curr_label "\" -> \"" $2 "\";"
curr_label=$2
}
/^jump/ {
print curr_label " -> " $2 ";"
}' | grep '[A-Za-z]' | sort | uniq
done | awk '
BEGIN {
print "digraph path {"
}
/^subgraph /{
curr_subgraph=$2
next
}
{
if(x[$1]) x[$1]=x[$1] $0
else {
x[$1]=$0
c[$1]=curr_subgraph
}
}
END {
print "subgraph cluster_" c["start"] " {"
print "start;"
print "style=\"rounded,dashed\";"
print "color=blue;"
print "labelalloc=b;"
print "label=\"" c["start"] "\";"
print "}"
print x["start"]
for (i in x)
if(i!="start") {
print "subgraph cluster_" c[i] "{"
print i ";"
print "style=\"rounded,dashed\";"
print "color=blue;"
print "labelalloc=b;"
print "label=\"" c[i] "\";"
print "}"
print x[i]
}
print "}"
}' | gvpr -c 'N[outdegree==0]{ color="red"}' | gvpr -c 'N[indegree==0]{ color="blue"}'