ruby-graphviz 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +13 -0
- data/examples/HTML-Labels.rb +2 -2
- data/examples/arrowhead.rb +1 -1
- data/examples/maketest.sh +24 -11
- data/examples/sample01.rb +1 -1
- data/examples/sample02.rb +1 -1
- data/examples/sample03.rb +1 -1
- data/examples/sample04.rb +1 -1
- data/examples/sample05.rb +1 -1
- data/examples/sample07.rb +6 -5
- data/examples/sample08.rb +1 -1
- data/examples/sample09.rb +1 -1
- data/examples/sample10.rb +1 -1
- data/examples/sample11.rb +1 -1
- data/examples/sample12.rb +1 -1
- data/examples/sample13.rb +1 -1
- data/examples/sample14.rb +1 -1
- data/examples/sample15.rb +23 -0
- data/examples/sample16.rb +8 -0
- data/examples/sample17.rb +92 -0
- data/examples/sample18.rb +24 -0
- data/examples/sample19.rb +59 -0
- data/examples/sample20.rb +47 -0
- data/examples/shapes.rb +4 -3
- data/examples/testorder.rb +1 -1
- data/examples/testxml.rb +1 -1
- data/lib/graphviz.rb +120 -23
- data/lib/graphviz/constants.rb +36 -17
- data/lib/graphviz/edge.rb +24 -1
- data/lib/graphviz/node.rb +30 -1
- metadata +8 -7
- data/examples/s10.png +0 -0
- data/examples/s12.png +0 -0
- data/examples/s13.png +0 -0
- data/examples/s14.png +0 -0
- data/examples/sample-dsl-10.rb +0 -33
data/ChangeLog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
0.9.0 :
|
|
2
|
+
* Add fdp example (sample 15)
|
|
3
|
+
* Add edge between cluster and node and cluster and cluster support
|
|
4
|
+
* GraphViz.add_node now support array (sample 16)
|
|
5
|
+
* Bug correction in GraphViz.output (sample 19)
|
|
6
|
+
* Add GraphViz#default to set default options (:use, :path and :output)
|
|
7
|
+
* Add possibility to set node or edge attribut via :
|
|
8
|
+
node.<attribut>=<value> or node.<attribut>( <value> )
|
|
9
|
+
adge.<attribut>=<value> or adge.<attribut>( <value> )
|
|
10
|
+
* Add GraphViz::Edge.set and GraphViz::Node.net
|
|
11
|
+
* Add sample 20
|
|
12
|
+
* Add GraphViz.node_count and GraphViz.edge_count by Daniel Cadenas Nión
|
|
13
|
+
|
|
1
14
|
0.8.2 :
|
|
2
15
|
* Update Node, Edge and Graph Attributes (see http://www.graphviz.org/doc/info/attrs.html)
|
|
3
16
|
* Bugs corrections
|
data/examples/HTML-Labels.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$:.unshift( "../lib" );
|
|
2
2
|
require "graphviz"
|
|
3
3
|
|
|
4
|
-
g = GraphViz::new( "structs",
|
|
4
|
+
g = GraphViz::new( "structs", :output => "png" )
|
|
5
5
|
|
|
6
6
|
g.node["shape"] = "plaintext"
|
|
7
7
|
|
|
@@ -17,4 +17,4 @@ g.add_edge( "struct1:f2", "struct3:here" )
|
|
|
17
17
|
|
|
18
18
|
g.add_edge( "HTML", "struct1" )
|
|
19
19
|
|
|
20
|
-
g.output(
|
|
20
|
+
g.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
data/examples/arrowhead.rb
CHANGED
data/examples/maketest.sh
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
-
ruby
|
|
4
|
-
ruby
|
|
5
|
-
ruby sample03.rb $1 > sample03.png
|
|
6
|
-
ruby sample04.rb $1 > sample04.png
|
|
3
|
+
ruby shapes.rb $1
|
|
4
|
+
ruby arrowhead.rb $1
|
|
7
5
|
|
|
8
|
-
ruby
|
|
9
|
-
ruby
|
|
10
|
-
ruby
|
|
6
|
+
ruby sample01.rb $1
|
|
7
|
+
ruby sample02.rb $1
|
|
8
|
+
ruby sample03.rb $1
|
|
9
|
+
ruby sample04.rb $1
|
|
10
|
+
ruby sample05.rb $1
|
|
11
|
+
|
|
12
|
+
ruby sample07.rb $1
|
|
13
|
+
ruby sample08.rb $1
|
|
14
|
+
ruby sample09.rb $1
|
|
15
|
+
ruby sample10.rb $1
|
|
16
|
+
ruby sample11.rb $1
|
|
17
|
+
ruby sample12.rb $1
|
|
18
|
+
ruby sample13.rb
|
|
19
|
+
ruby sample14.rb
|
|
20
|
+
ruby sample15.rb
|
|
21
|
+
ruby sample16.rb
|
|
22
|
+
ruby sample17.rb
|
|
23
|
+
ruby sample18.rb
|
|
24
|
+
ruby sample19.rb
|
|
11
25
|
|
|
12
|
-
ruby
|
|
13
|
-
|
|
14
|
-
ruby
|
|
15
|
-
ruby arrowhead.rb $1 > arrowhead.png
|
|
26
|
+
ruby testorder.rb $1
|
|
27
|
+
ruby testxml.rb $1
|
|
28
|
+
ruby HTML-Labels.rb
|
data/examples/sample01.rb
CHANGED
data/examples/sample02.rb
CHANGED
data/examples/sample03.rb
CHANGED
data/examples/sample04.rb
CHANGED
data/examples/sample05.rb
CHANGED
data/examples/sample07.rb
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
$:.unshift( "../lib" );
|
|
4
4
|
require "graphviz"
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
GraphViz::options( :output => "png", :use => "dot" )
|
|
7
|
+
|
|
7
8
|
if ARGV[0]
|
|
8
|
-
|
|
9
|
-
else
|
|
10
|
-
g = GraphViz::new( "structs", "output" => "png" )
|
|
9
|
+
GraphViz::options( :path => ARGV[0] )
|
|
11
10
|
end
|
|
12
11
|
|
|
12
|
+
g = GraphViz::new( "structs", "output" => "png" )
|
|
13
|
+
|
|
13
14
|
g.node["shape"] = "record"
|
|
14
15
|
|
|
15
16
|
g.add_node( "struct1", "shape" => "record", "label" => "<f0> left|<f1> middle|<f2> right" )
|
|
@@ -19,4 +20,4 @@ g.add_node( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<h
|
|
|
19
20
|
g.add_edge( "struct1:f1", "struct2:f0" )
|
|
20
21
|
g.add_edge( "struct1:f2", "struct3:here" )
|
|
21
22
|
|
|
22
|
-
g.output()
|
|
23
|
+
g.output( :file => "#{$0}.png" )
|
data/examples/sample08.rb
CHANGED
data/examples/sample09.rb
CHANGED
data/examples/sample10.rb
CHANGED
data/examples/sample11.rb
CHANGED
data/examples/sample12.rb
CHANGED
data/examples/sample13.rb
CHANGED
|
@@ -45,4 +45,4 @@ GraphViz::new( "G", "output" => "png" ) { |graph|
|
|
|
45
45
|
graph.cluster0.a3 << graph.cluster0.a0
|
|
46
46
|
graph.cluster0.a3 << graph.endn
|
|
47
47
|
graph.cluster1.b3 << graph.endn
|
|
48
|
-
}.output( :path => '/usr/local/
|
|
48
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
data/examples/sample14.rb
CHANGED
|
@@ -41,4 +41,4 @@ GraphViz::new( "G", "output" => "png" ) { |graph|
|
|
|
41
41
|
graph.cluster0.a3 << graph.cluster0.a0
|
|
42
42
|
graph.cluster0.a3 << graph.endn
|
|
43
43
|
graph.cluster1.b3 << graph.endn
|
|
44
|
-
}.output( :path => '/usr/local/
|
|
44
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
# fdp example
|
|
4
|
+
# see : http://www.graphviz.org/Gallery/undirected/fdpclust.html
|
|
5
|
+
|
|
6
|
+
$:.unshift( "../lib" );
|
|
7
|
+
require "graphviz"
|
|
8
|
+
|
|
9
|
+
GraphViz::new( "G", :type => "graph", :output => "png", :use => "fdp" ) { |graph|
|
|
10
|
+
graph.e
|
|
11
|
+
graph.clusterA { |cA|
|
|
12
|
+
cA.a << cA.b
|
|
13
|
+
cA.clusterC { |cC|
|
|
14
|
+
cC._c( :label => "C" ) << cC._d( :label => "D" )
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
graph.clusterB { |cB|
|
|
18
|
+
cB.d << cB.f
|
|
19
|
+
}
|
|
20
|
+
graph.clusterB.d << graph.clusterA.clusterC._d
|
|
21
|
+
graph.e << graph.clusterB
|
|
22
|
+
graph.clusterA.clusterC << graph.clusterB
|
|
23
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift( "../lib" );
|
|
4
|
+
require "graphviz"
|
|
5
|
+
|
|
6
|
+
GraphViz::new( "G", :type => "graph", :output => "png", :rankdir => "LR" ) { |graph|
|
|
7
|
+
graph.add_edge( [graph.a, graph.b, graph.c], [ graph.d, graph.e, graph.f ] )
|
|
8
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift( "../lib" );
|
|
4
|
+
require "graphviz"
|
|
5
|
+
|
|
6
|
+
GraphViz::new( "G", :type => "graph", :output => "png", :rankdir => "LR", :bgcolor => "#808080" ) { |graph|
|
|
7
|
+
graph.edge[:dir] = "none"
|
|
8
|
+
|
|
9
|
+
graph.node[:width] = "0.3"
|
|
10
|
+
graph.node[:height] = "0.3"
|
|
11
|
+
graph.node[:label] = ""
|
|
12
|
+
|
|
13
|
+
_ = {}
|
|
14
|
+
|
|
15
|
+
("1".."8").each do |v|
|
|
16
|
+
_[v] = graph.add_node( v, :shape => "circle", :style => "invis")
|
|
17
|
+
end
|
|
18
|
+
["10","20","30","40","50","60","70","80"].each do |v|
|
|
19
|
+
_[v] = graph.add_node( v, :shape => "circle", :style => "invis")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
("a".."x").each do |v|
|
|
23
|
+
_[v] = graph.add_node( v, :shape => "circle")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
("A".."X").each do |v|
|
|
27
|
+
_[v] = graph.add_node( v, :shape => "diamond")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
(_["1"] << _["a"])[:color]="#0000ff"
|
|
31
|
+
(_["a"] << _["A"])[:color]="#0000ff"
|
|
32
|
+
(_["a"] << _["B"])[:color]="#0000ff"
|
|
33
|
+
(_["2"] << _["b"])[:color]="#ff0000"
|
|
34
|
+
(_["b"] << _["B"])[:color]="#ff0000"
|
|
35
|
+
(_["b"] << _["A"])[:color]="#ff0000"
|
|
36
|
+
(_["3"] << _["c"])[:color]="#ffff00"
|
|
37
|
+
(_["c"] << _["C"])[:color]="#ffff00"
|
|
38
|
+
(_["c"] << _["D"])[:color]="#ffff00"
|
|
39
|
+
(_["4"] << _["d"])[:color]="#00ff00"
|
|
40
|
+
(_["d"] << _["D"])[:color]="#00ff00"
|
|
41
|
+
(_["d"] << _["C"])[:color]="#00ff00"
|
|
42
|
+
(_["5"] << _["e"])[:color]="#000000"
|
|
43
|
+
(_["e"] << _["E"])[:color]="#000000"
|
|
44
|
+
(_["e"] << _["F"])[:color]="#000000"
|
|
45
|
+
(_["6"] << _["f"])[:color]="#00ffff"
|
|
46
|
+
(_["f"] << _["F"])[:color]="#00ffff"
|
|
47
|
+
(_["f"] << _["E"])[:color]="#00ffff"
|
|
48
|
+
(_["7"] << _["g"])[:color]="#ffffff"
|
|
49
|
+
(_["g"] << _["G"])[:color]="#ffffff"
|
|
50
|
+
(_["g"] << _["H"])[:color]="#ffffff"
|
|
51
|
+
(_["8"] << _["h"])[:color]="#ff00ff"
|
|
52
|
+
(_["h"] << _["H"])[:color]="#ff00ff"
|
|
53
|
+
(_["h"] << _["G"])[:color]="#ff00ff"
|
|
54
|
+
|
|
55
|
+
graph.edge[:color]="#ff0000:#0000ff"
|
|
56
|
+
_["A"] << _["i"]; _["i"] << [_["I"], _["K"]]
|
|
57
|
+
_["B"] << _["j"]; _["j"] << [_["J"], _["L"]]
|
|
58
|
+
|
|
59
|
+
graph.edge[:color]="#00ff00:#ffff00"
|
|
60
|
+
_["C"] << _["k"]; _["k"] << [_["K"], _["I"]]
|
|
61
|
+
_["D"] << _["l"]; _["l"] << [_["L"], _["J"]]
|
|
62
|
+
|
|
63
|
+
graph.edge[:color]="#00ffff:#000000"
|
|
64
|
+
_["E"] << _["m"]; _["m"] << [_["M"], _["O"]]
|
|
65
|
+
_["F"] << _["n"]; _["n"] << [_["N"], _["P"]]
|
|
66
|
+
|
|
67
|
+
graph.edge[:color]="#ff00ff:#ffffff"
|
|
68
|
+
_["G"] << _["o"]; _["o"] << [_["O"], _["M"]]
|
|
69
|
+
_["H"] << _["p"]; _["p"] << [_["P"], _["N"]]
|
|
70
|
+
|
|
71
|
+
graph.edge[:color]="#00ff00:#ffff00:#ff0000:#0000ff"
|
|
72
|
+
_["I"] << _["q"]; _["q"] << [_["Q"], _["U"]]
|
|
73
|
+
_["J"] << _["r"]; _["r"] << [_["R"], _["V"]]
|
|
74
|
+
_["K"] << _["s"]; _["s"] << [_["S"], _["W"]]
|
|
75
|
+
_["L"] << _["t"]; _["t"] << [_["T"], _["X"]]
|
|
76
|
+
|
|
77
|
+
graph.edge[:color]="#ff00ff:#ffffff:#00ffff:#000000"
|
|
78
|
+
_["M"] << _["u"]; _["u"] << [_["U"], _["Q"]]
|
|
79
|
+
_["N"] << _["v"]; _["v"] << [_["V"], _["R"]]
|
|
80
|
+
_["O"] << _["w"]; _["w"] << [_["W"], _["S"]]
|
|
81
|
+
_["P"] << _["x"]; _["x"] << [_["X"], _["T"]]
|
|
82
|
+
|
|
83
|
+
graph.edge[:color]="#ff00ff:#ffffff:#00ffff:#000000:#00ff00:#ffff00:#ff0000:#0000ff"
|
|
84
|
+
_["Q"] << _["10"]
|
|
85
|
+
_["R"] << _["20"]
|
|
86
|
+
_["S"] << _["30"]
|
|
87
|
+
_["T"] << _["40"]
|
|
88
|
+
_["U"] << _["50"]
|
|
89
|
+
_["V"] << _["60"]
|
|
90
|
+
_["W"] << _["70"]
|
|
91
|
+
_["X"] << _["80"]
|
|
92
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift( "../lib" );
|
|
4
|
+
require "graphviz"
|
|
5
|
+
|
|
6
|
+
GraphViz::new( "G", :output => "png", :rankdir => "LR", :size => "8,5" ) { |graph|
|
|
7
|
+
graph.node[:shape] = "doublecircle"
|
|
8
|
+
graph._LR_0; graph._LR_3; graph._LR_4; graph._LR_8
|
|
9
|
+
graph.node[:shape] = "circle"
|
|
10
|
+
(graph._LR_0 << graph._LR_2)[:label] = "SS(B)"
|
|
11
|
+
(graph._LR_0 << graph._LR_1)[:label] = "SS(S)"
|
|
12
|
+
(graph._LR_1 << graph._LR_3)[:label] = "S($end)"
|
|
13
|
+
(graph._LR_2 << graph._LR_6)[:label] = "SS(b)"
|
|
14
|
+
(graph._LR_2 << graph._LR_5)[:label] = "SS(a)"
|
|
15
|
+
(graph._LR_2 << graph._LR_4)[:label] = "S(A)"
|
|
16
|
+
(graph._LR_5 << graph._LR_7)[:label] = "S(b)"
|
|
17
|
+
(graph._LR_5 << graph._LR_5)[:label] = "S(a)"
|
|
18
|
+
(graph._LR_6 << graph._LR_6)[:label] = "S(b)"
|
|
19
|
+
(graph._LR_6 << graph._LR_5)[:label] = "S(a)"
|
|
20
|
+
(graph._LR_7 << graph._LR_8)[:label] = "S(b)"
|
|
21
|
+
(graph._LR_7 << graph._LR_5)[:label] = "S(a)"
|
|
22
|
+
(graph._LR_8 << graph._LR_6)[:label] = "S(b)"
|
|
23
|
+
(graph._LR_8 << graph._LR_5)[:label] = "S(a)"
|
|
24
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift( "../lib" );
|
|
4
|
+
require "graphviz"
|
|
5
|
+
|
|
6
|
+
GraphViz::new( "ER", :type => "graph", :output => "png", :use => "neato" ) { |graph|
|
|
7
|
+
graph.node[:shape] = "box"
|
|
8
|
+
graph.course; graph.institute; graph.student
|
|
9
|
+
|
|
10
|
+
graph.node[:shape] = "ellipse"
|
|
11
|
+
graph.name0(:label => "name")
|
|
12
|
+
graph.name1(:label => "name")
|
|
13
|
+
graph.name2(:label => "name")
|
|
14
|
+
graph.code; graph.grade; graph.number
|
|
15
|
+
|
|
16
|
+
graph.node[:shape] = "diamond"
|
|
17
|
+
graph.node[:style] = "filled"
|
|
18
|
+
graph.node[:color] = "lightgrey"
|
|
19
|
+
graph.ci( :label => "C-I" )
|
|
20
|
+
graph.sc( :label => "S-C" )
|
|
21
|
+
graph.si( :label => "S-I" )
|
|
22
|
+
|
|
23
|
+
graph.name0 << graph.course;
|
|
24
|
+
graph.code << graph.course;
|
|
25
|
+
|
|
26
|
+
(graph.course << graph.ci).set { |e|
|
|
27
|
+
e.label = "n"
|
|
28
|
+
e.len = "1.00"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
e = (graph.ci << graph.institute)
|
|
32
|
+
e.label = "1"
|
|
33
|
+
e[:len] = "1.00"
|
|
34
|
+
|
|
35
|
+
graph.institute << graph.name1;
|
|
36
|
+
|
|
37
|
+
e = (graph.institute << graph.si)
|
|
38
|
+
e[:label] = "1"
|
|
39
|
+
e[:len] = "1.00"
|
|
40
|
+
|
|
41
|
+
e = (graph.si << graph.student)
|
|
42
|
+
e[:label] = "n"
|
|
43
|
+
e[:len] = "1.00"
|
|
44
|
+
|
|
45
|
+
graph.student << graph.grade
|
|
46
|
+
graph.student << graph.name2
|
|
47
|
+
graph.student << graph.number
|
|
48
|
+
|
|
49
|
+
e = (graph.student << graph.sc)
|
|
50
|
+
e[:label] = "m"
|
|
51
|
+
e[:len] = "1.00"
|
|
52
|
+
|
|
53
|
+
e = (graph.sc << graph.course)
|
|
54
|
+
e[:label] = "n"
|
|
55
|
+
e[:len] = "1.00"
|
|
56
|
+
|
|
57
|
+
graph[:label] = "\\n\\nEntity Relation Diagram\\ndrawn by NEATO";
|
|
58
|
+
graph[:fontsize] = "20";
|
|
59
|
+
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift( "../lib" );
|
|
4
|
+
require "graphviz"
|
|
5
|
+
|
|
6
|
+
GraphViz::options( :output => "png", :use => "dot" )
|
|
7
|
+
|
|
8
|
+
if ARGV[0]
|
|
9
|
+
GraphViz::options( :path => ARGV[0] )
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
GraphViz::new( "g", :rankdir => "LR", :type => "digraph" ) { |g|
|
|
13
|
+
g.node[:fontsize] = "16"
|
|
14
|
+
g.node[:shape] = "record"
|
|
15
|
+
|
|
16
|
+
g.node0( :label => "<f0> 0x10ba8| <f1>" )
|
|
17
|
+
g.node1( :label => "<f0> 0xf7fc4380| <f1> | <f2> |-1" )
|
|
18
|
+
g.node2( :label => "<f0> 0xf7fc44b8| | |2" )
|
|
19
|
+
g.node3( :label => "<f0> 3.43322790286038071e-06|44.79998779296875|0" )
|
|
20
|
+
g.node4( :label => "<f0> 0xf7fc4380| <f1> | <f2> |2" )
|
|
21
|
+
g.node5( :label => "<f0> (nil)| | |-1" )
|
|
22
|
+
g.node6( :label => "<f0> 0xf7fc4380| <f1> | <f2> |1" )
|
|
23
|
+
g.node7( :label => "<f0> 0xf7fc4380| <f1> | <f2> |2" )
|
|
24
|
+
g.node8( :label => "<f0> (nil)| | |-1" )
|
|
25
|
+
g.node9( :label => "<f0> (nil)| | |-1" )
|
|
26
|
+
g.node10( :label => "<f0> (nil)| <f1> | <f2> |-1" )
|
|
27
|
+
g.node11( :label => "<f0> (nil)| <f1> | <f2> |-1" )
|
|
28
|
+
g.node12( :label => "<f0> 0xf7fc43e0| | |1" )
|
|
29
|
+
|
|
30
|
+
g.add_edge( g.node0(:f0), g.node1(:f0) )
|
|
31
|
+
g.add_edge( g.node0(:f1), g.node2(:f0) )
|
|
32
|
+
g.add_edge( g.node1(:f0), g.node3(:f0) )
|
|
33
|
+
g.add_edge( g.node1(:f1), g.node4(:f0) )
|
|
34
|
+
g.add_edge( g.node1(:f2), g.node5(:f0) )
|
|
35
|
+
g.add_edge( g.node4(:f0), g.node3(:f0) )
|
|
36
|
+
g.add_edge( g.node4(:f1), g.node6(:f0) )
|
|
37
|
+
g.add_edge( g.node4(:f2), g.node10(:f0) )
|
|
38
|
+
g.add_edge( g.node6(:f0), g.node3(:f0) )
|
|
39
|
+
g.add_edge( g.node6(:f1), g.node7(:f0) )
|
|
40
|
+
g.add_edge( g.node6(:f2), g.node9(:f0) )
|
|
41
|
+
g.add_edge( g.node7(:f0), g.node3(:f0) )
|
|
42
|
+
g.add_edge( g.node7(:f1), g.node1(:f0) )
|
|
43
|
+
g.add_edge( g.node7(:f2), g.node8(:f0) )
|
|
44
|
+
g.add_edge( g.node10(:f1), g.node11(:f0) )
|
|
45
|
+
g.add_edge( g.node10(:f2), g.node12(:f0) )
|
|
46
|
+
g.add_edge( g.node11(:f2), g.node1(:f0) )
|
|
47
|
+
}.output( :file => "#{$0}.png" )
|
data/examples/shapes.rb
CHANGED
|
@@ -14,10 +14,11 @@ g.node["shape"] = "ellipse"
|
|
|
14
14
|
|
|
15
15
|
[ "box", "polygon", "ellipse", "circle", "point",
|
|
16
16
|
"egg", "triangle", "plaintext", "diamond", "trapezium",
|
|
17
|
-
"parallelogram", "house", "hexagon", "octagon", "doublecircle",
|
|
17
|
+
"parallelogram", "house", "pentagon", "hexagon", "septagon", "octagon", "doublecircle",
|
|
18
18
|
"doubleoctagon", "tripleoctagon", "invtriangle", "invtrapezium", "invhouse",
|
|
19
|
-
"Mdiamond", "Msquare", "Mcircle"
|
|
19
|
+
"Mdiamond", "Msquare", "Mcircle", "rect", "rectangle", "none", "note", "tab", "folder",
|
|
20
|
+
"box3d", "component" ].each { |s|
|
|
20
21
|
g.add_node( s, "shape" => s )
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
g.output()
|
|
24
|
+
g.output( :file => "shapes.png")
|
data/examples/testorder.rb
CHANGED
data/examples/testxml.rb
CHANGED
|
@@ -4,4 +4,4 @@ $:.unshift( "../lib" )
|
|
|
4
4
|
require 'graphviz/xml'
|
|
5
5
|
|
|
6
6
|
gvxml = GraphViz::XML::new( "test.xml", :text => true, :attrs => true )
|
|
7
|
-
gvxml.output( :output => "png", :file => "
|
|
7
|
+
gvxml.output( :output => "png", :file => "#{$0}.png", :use => "dot", :path => ARGV[0] )
|
data/lib/graphviz.rb
CHANGED
|
@@ -28,14 +28,17 @@ class GraphViz
|
|
|
28
28
|
public
|
|
29
29
|
|
|
30
30
|
## Var: Output format (dot, png, jpeg, ...)
|
|
31
|
+
@@format = "canon"
|
|
31
32
|
@format
|
|
32
33
|
## Var: Output file name
|
|
33
34
|
@filename
|
|
34
35
|
## Var: program to use (dot|twopi)
|
|
36
|
+
@@prog = "dot"
|
|
35
37
|
@prog
|
|
36
38
|
## Var: program path
|
|
39
|
+
@@path = nil
|
|
37
40
|
@path
|
|
38
|
-
|
|
41
|
+
|
|
39
42
|
## Var: Graph name
|
|
40
43
|
@name
|
|
41
44
|
|
|
@@ -78,30 +81,44 @@ class GraphViz
|
|
|
78
81
|
# Create a new edge
|
|
79
82
|
#
|
|
80
83
|
# In:
|
|
81
|
-
# oNodeOne : First node
|
|
82
|
-
# oNodeTwo : Second Node
|
|
84
|
+
# oNodeOne : First node (or node list)
|
|
85
|
+
# oNodeTwo : Second Node (or node list)
|
|
83
86
|
# *hOpt : Edge attributs
|
|
84
87
|
#
|
|
85
88
|
def add_edge( oNodeOne, oNodeTwo, *hOpt )
|
|
86
|
-
oEdge = GraphViz::Edge::new( oNodeOne, oNodeTwo, self )
|
|
87
89
|
|
|
88
|
-
if
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
if( oNodeOne.class == Array )
|
|
91
|
+
oNodeOne.each do |no|
|
|
92
|
+
add_edge( no, oNodeTwo, *hOpt )
|
|
91
93
|
end
|
|
92
|
-
|
|
94
|
+
else
|
|
95
|
+
if( oNodeTwo.class == Array )
|
|
96
|
+
oNodeTwo.each do |nt|
|
|
97
|
+
add_edge( oNodeOne, nt, *hOpt )
|
|
98
|
+
end
|
|
99
|
+
else
|
|
93
100
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
oEdge = GraphViz::Edge::new( oNodeOne, oNodeTwo, self )
|
|
102
|
+
|
|
103
|
+
if hOpt.nil? == false and hOpt[0].nil? == false
|
|
104
|
+
hOpt[0].each do |xKey, xValue|
|
|
105
|
+
oEdge[xKey.to_s] = xValue
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
@elements_order.push( {
|
|
110
|
+
"type" => "edge",
|
|
111
|
+
"value" => oEdge
|
|
112
|
+
} )
|
|
113
|
+
@loEdges.push( oEdge )
|
|
114
|
+
|
|
115
|
+
return( oEdge )
|
|
116
|
+
end
|
|
117
|
+
end
|
|
101
118
|
end
|
|
102
119
|
|
|
103
120
|
#
|
|
104
|
-
# Create
|
|
121
|
+
# Create à new graph
|
|
105
122
|
#
|
|
106
123
|
# In:
|
|
107
124
|
# xGraphName : Graph name
|
|
@@ -124,7 +141,21 @@ class GraphViz
|
|
|
124
141
|
|
|
125
142
|
return( @hoGraphs[xGraphName] )
|
|
126
143
|
end
|
|
127
|
-
|
|
144
|
+
|
|
145
|
+
#
|
|
146
|
+
# Get the number of nodes
|
|
147
|
+
#
|
|
148
|
+
def node_count
|
|
149
|
+
@hoNodes.size
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
#
|
|
153
|
+
# Get the number of edges
|
|
154
|
+
#
|
|
155
|
+
def edge_count
|
|
156
|
+
@loEdges.size
|
|
157
|
+
end
|
|
158
|
+
|
|
128
159
|
def method_missing( idName, *args, &block ) #:nodoc:
|
|
129
160
|
xName = idName.id2name
|
|
130
161
|
|
|
@@ -136,7 +167,13 @@ class GraphViz
|
|
|
136
167
|
yield( rCod )
|
|
137
168
|
else
|
|
138
169
|
# Create a node named '#{xName}' or search for a node, edge or cluster
|
|
139
|
-
|
|
170
|
+
if @hoNodes.keys.include?( xName )
|
|
171
|
+
if( args[0] )
|
|
172
|
+
return "#{xName}:#{args[0].to_s}"
|
|
173
|
+
else
|
|
174
|
+
return( @hoNodes[xName] )
|
|
175
|
+
end
|
|
176
|
+
end
|
|
140
177
|
return( @hoGraphs[xName] ) if @hoGraphs.keys.include?( xName )
|
|
141
178
|
|
|
142
179
|
rCod = add_node( xName, args[0] )
|
|
@@ -202,7 +239,7 @@ class GraphViz
|
|
|
202
239
|
if kElement["value"] == nil then
|
|
203
240
|
raise ArgumentError, "#{kElement["name"]} has a nil value!"
|
|
204
241
|
end
|
|
205
|
-
|
|
242
|
+
|
|
206
243
|
case kElement["type"]
|
|
207
244
|
when "graph_attr"
|
|
208
245
|
xData << xSeparator + kElement["name"] + " = \"" + kElement["value"] + "\""
|
|
@@ -230,6 +267,18 @@ class GraphViz
|
|
|
230
267
|
end
|
|
231
268
|
}
|
|
232
269
|
|
|
270
|
+
if xData.length > 0
|
|
271
|
+
case xLastType
|
|
272
|
+
when "graph_attr"
|
|
273
|
+
xDOTScript << " " + xData + ";\n"
|
|
274
|
+
|
|
275
|
+
when "node_attr"
|
|
276
|
+
xDOTScript << " node [" + xData + "];\n"
|
|
277
|
+
|
|
278
|
+
when "edge_attr"
|
|
279
|
+
xDOTScript << " edge [" + xData + "];\n"
|
|
280
|
+
end
|
|
281
|
+
end
|
|
233
282
|
xDOTScript << "}"
|
|
234
283
|
|
|
235
284
|
if @oParentGraph.nil? == false
|
|
@@ -288,6 +337,30 @@ class GraphViz
|
|
|
288
337
|
end
|
|
289
338
|
end
|
|
290
339
|
|
|
340
|
+
alias :save :output
|
|
341
|
+
|
|
342
|
+
#
|
|
343
|
+
# Get the graph name
|
|
344
|
+
#
|
|
345
|
+
def name
|
|
346
|
+
@name.clone
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
#
|
|
350
|
+
# Create an edge between the current cluster and the node or cluster +oNode+
|
|
351
|
+
#
|
|
352
|
+
def <<( oNode )
|
|
353
|
+
raise( ArgumentError, "Edge between root graph and node or cluster not allowed!" ) if self.pg.nil?
|
|
354
|
+
|
|
355
|
+
if( oNode.class == Array )
|
|
356
|
+
oNode.each do |no|
|
|
357
|
+
self << no
|
|
358
|
+
end
|
|
359
|
+
else
|
|
360
|
+
return GraphViz::commonGraph( oNode, self ).add_edge( self, oNode )
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
291
364
|
def pg #:nodoc:
|
|
292
365
|
@oParentGraph
|
|
293
366
|
end
|
|
@@ -312,6 +385,30 @@ class GraphViz
|
|
|
312
385
|
} )
|
|
313
386
|
end
|
|
314
387
|
|
|
388
|
+
## ----------------------------------------------------------------------------
|
|
389
|
+
|
|
390
|
+
#
|
|
391
|
+
# Change default options (:use, :path and :output)
|
|
392
|
+
#
|
|
393
|
+
def self.default( hOpts )
|
|
394
|
+
hOpts.each do |k, v|
|
|
395
|
+
case k.to_s
|
|
396
|
+
when "use"
|
|
397
|
+
@@prog = v
|
|
398
|
+
when "path"
|
|
399
|
+
@@path = v
|
|
400
|
+
when "output"
|
|
401
|
+
@@format = v
|
|
402
|
+
else
|
|
403
|
+
warn "Invalide option #{k}!"
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def self.options( hOpts )
|
|
409
|
+
GraphViz::default( hOpts )
|
|
410
|
+
end
|
|
411
|
+
|
|
315
412
|
## ----------------------------------------------------------------------------
|
|
316
413
|
|
|
317
414
|
private
|
|
@@ -324,7 +421,7 @@ class GraphViz
|
|
|
324
421
|
## Var: Parent graph
|
|
325
422
|
@oParentGraph
|
|
326
423
|
|
|
327
|
-
## Var: Type de graphe (
|
|
424
|
+
## Var: Type de graphe (orienté ou non)
|
|
328
425
|
@oGraphType
|
|
329
426
|
|
|
330
427
|
#
|
|
@@ -339,11 +436,11 @@ class GraphViz
|
|
|
339
436
|
# :type : Graph type (Constants::GRAPHTYPE) (default : digraph)
|
|
340
437
|
#
|
|
341
438
|
def initialize( xGraphName, *hOpt, &block )
|
|
342
|
-
@format = "dot"
|
|
343
439
|
@filename = nil
|
|
344
|
-
@prog = "dot"
|
|
345
|
-
@path = nil
|
|
346
440
|
@name = xGraphName
|
|
441
|
+
@format = @@format
|
|
442
|
+
@prog = @@prog
|
|
443
|
+
@path = @@path
|
|
347
444
|
|
|
348
445
|
@elements_order = Array::new()
|
|
349
446
|
|
data/lib/graphviz/constants.rb
CHANGED
|
@@ -15,34 +15,53 @@
|
|
|
15
15
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16
16
|
|
|
17
17
|
module Constants
|
|
18
|
-
RGV_VERSION = "0.
|
|
18
|
+
RGV_VERSION = "0.9.0"
|
|
19
19
|
|
|
20
20
|
## Const: Output formats
|
|
21
21
|
FORMATS = [
|
|
22
|
+
"bmp",
|
|
23
|
+
"canon",
|
|
22
24
|
"dot",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
+
"xdot",
|
|
26
|
+
"cmap",
|
|
27
|
+
"dia",
|
|
28
|
+
"eps",
|
|
29
|
+
"fig",
|
|
30
|
+
"gd",
|
|
31
|
+
"gd2",
|
|
32
|
+
"gif",
|
|
33
|
+
"gtk",
|
|
25
34
|
"hpgl",
|
|
26
|
-
"
|
|
27
|
-
"gif",
|
|
35
|
+
"ico",
|
|
28
36
|
"imap",
|
|
37
|
+
"cmapx",
|
|
38
|
+
"imap_np",
|
|
39
|
+
"cmapx_np",
|
|
29
40
|
"ismap",
|
|
30
|
-
"cmap",
|
|
31
41
|
"jpeg",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
42
|
+
"jpg",
|
|
43
|
+
"jpe",
|
|
44
|
+
"mif",
|
|
45
|
+
"mp",
|
|
46
|
+
"pcl",
|
|
47
|
+
"pdf",
|
|
34
48
|
"pic",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
49
|
+
"plain",
|
|
50
|
+
"plain-ext",
|
|
51
|
+
"png",
|
|
52
|
+
"ps",
|
|
53
|
+
"ps2",
|
|
54
|
+
"svg",
|
|
55
|
+
"svgz",
|
|
56
|
+
"tga",
|
|
57
|
+
"tiff",
|
|
58
|
+
"tif",
|
|
59
|
+
"vml",
|
|
60
|
+
"vmlz",
|
|
38
61
|
"vrml",
|
|
39
62
|
"vtx",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"svg",
|
|
43
|
-
"plain",
|
|
44
|
-
"text",
|
|
45
|
-
"canon",
|
|
63
|
+
"wbmp",
|
|
64
|
+
"xlib",
|
|
46
65
|
"none"
|
|
47
66
|
]
|
|
48
67
|
|
data/lib/graphviz/edge.rb
CHANGED
|
@@ -64,7 +64,30 @@ class GraphViz
|
|
|
64
64
|
def []( xAttrName )
|
|
65
65
|
@oAttrEdge[xAttrName.to_s].clone
|
|
66
66
|
end
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
#
|
|
69
|
+
# Set edge attributs
|
|
70
|
+
#
|
|
71
|
+
# Example :
|
|
72
|
+
# e = graph.add_edge( ... )
|
|
73
|
+
# ...
|
|
74
|
+
# e.set { |_e|
|
|
75
|
+
# _e.color = "blue"
|
|
76
|
+
# _e.fontcolor = "red"
|
|
77
|
+
# }
|
|
78
|
+
#
|
|
79
|
+
def set( &b )
|
|
80
|
+
yield( self )
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Add edge options
|
|
84
|
+
# use edge.<option>=<value> or edge.<option>( <value> )
|
|
85
|
+
def method_missing( idName, *args, &block ) #:nodoc:
|
|
86
|
+
xName = idName.id2name
|
|
87
|
+
|
|
88
|
+
self[xName.gsub( /=$/, "" )]=args[0]
|
|
89
|
+
end
|
|
90
|
+
|
|
68
91
|
def output( oGraphType ) #:nodoc:
|
|
69
92
|
xLink = " -> "
|
|
70
93
|
if oGraphType == "graph"
|
data/lib/graphviz/node.rb
CHANGED
|
@@ -62,7 +62,36 @@ class GraphViz
|
|
|
62
62
|
# Create an edge between the current node and the node +oNode+
|
|
63
63
|
#
|
|
64
64
|
def <<( oNode )
|
|
65
|
-
|
|
65
|
+
if( oNode.class == Array )
|
|
66
|
+
oNode.each do |no|
|
|
67
|
+
self << no
|
|
68
|
+
end
|
|
69
|
+
else
|
|
70
|
+
return GraphViz::commonGraph( oNode, self ).add_edge( self, oNode )
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
#
|
|
75
|
+
# Set node attributs
|
|
76
|
+
#
|
|
77
|
+
# Example :
|
|
78
|
+
# n = graph.add_node( ... )
|
|
79
|
+
# ...
|
|
80
|
+
# n.set { |_n|
|
|
81
|
+
# _n.color = "blue"
|
|
82
|
+
# _n.fontcolor = "red"
|
|
83
|
+
# }
|
|
84
|
+
#
|
|
85
|
+
def set( &b )
|
|
86
|
+
yield( self )
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Add node options
|
|
90
|
+
# use node.<option>=<value> or node.<option>( <value> )
|
|
91
|
+
def method_missing( idName, *args, &block ) #:nodoc:
|
|
92
|
+
xName = idName.id2name
|
|
93
|
+
|
|
94
|
+
self[xName.gsub( /=$/, "" )]=args[0]
|
|
66
95
|
end
|
|
67
96
|
|
|
68
97
|
def pg #:nodoc:
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-graphviz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gregoire Lejeune
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-
|
|
12
|
+
date: 2008-06-12 00:00:00 +02:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -35,11 +35,6 @@ files:
|
|
|
35
35
|
- examples/HTML-Labels.rb
|
|
36
36
|
- examples/maketest.sh
|
|
37
37
|
- examples/p2p.rb
|
|
38
|
-
- examples/s10.png
|
|
39
|
-
- examples/s12.png
|
|
40
|
-
- examples/s13.png
|
|
41
|
-
- examples/s14.png
|
|
42
|
-
- examples/sample-dsl-10.rb
|
|
43
38
|
- examples/sample01.rb
|
|
44
39
|
- examples/sample02.rb
|
|
45
40
|
- examples/sample03.rb
|
|
@@ -53,6 +48,12 @@ files:
|
|
|
53
48
|
- examples/sample12.rb
|
|
54
49
|
- examples/sample13.rb
|
|
55
50
|
- examples/sample14.rb
|
|
51
|
+
- examples/sample15.rb
|
|
52
|
+
- examples/sample16.rb
|
|
53
|
+
- examples/sample17.rb
|
|
54
|
+
- examples/sample18.rb
|
|
55
|
+
- examples/sample19.rb
|
|
56
|
+
- examples/sample20.rb
|
|
56
57
|
- examples/shapes.rb
|
|
57
58
|
- examples/test.xml
|
|
58
59
|
- examples/testorder.rb
|
data/examples/s10.png
DELETED
|
Binary file
|
data/examples/s12.png
DELETED
|
Binary file
|
data/examples/s13.png
DELETED
|
Binary file
|
data/examples/s14.png
DELETED
|
Binary file
|
data/examples/sample-dsl-10.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
$:.unshift( "../lib" );
|
|
2
|
-
require "graphviz"
|
|
3
|
-
|
|
4
|
-
g = GraphViz::new( :path => ARGV[0] )
|
|
5
|
-
|
|
6
|
-
g.digraph :G {
|
|
7
|
-
|
|
8
|
-
subgraph :cluster_0 {
|
|
9
|
-
style :filled
|
|
10
|
-
color :lightgrey
|
|
11
|
-
node :style => :filled, :color => :white
|
|
12
|
-
a0 << a1 << a2 << a3
|
|
13
|
-
label "process #1"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
subgraph :cluster_1 {
|
|
17
|
-
node :style => :filled
|
|
18
|
-
b0 << b1 << b2 << b3
|
|
19
|
-
label "process #2"
|
|
20
|
-
color :blue
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
start << a0;
|
|
24
|
-
start << b0;
|
|
25
|
-
a1 << b3;
|
|
26
|
-
b2 << a3;
|
|
27
|
-
a3 << a0;
|
|
28
|
-
a3 << _end;
|
|
29
|
-
b3 << _end;
|
|
30
|
-
|
|
31
|
-
start :shape => :Mdiamond
|
|
32
|
-
_end :shape=> :Msquare
|
|
33
|
-
}
|