ruby-graphviz 0.8.0 → 0.8.1
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 +3 -0
- data/examples/HTML-Labels.rb +20 -0
- data/examples/arrowhead.rb +97 -0
- data/examples/maketest.sh +15 -0
- data/examples/p2p.rb +35 -0
- data/examples/sample01.rb +32 -0
- data/examples/sample02.rb +42 -0
- data/examples/sample03.rb +31 -0
- data/examples/sample04.rb +22 -0
- data/examples/sample05.rb +32 -0
- data/examples/sample07.rb +22 -0
- data/examples/sample08.rb +34 -0
- data/examples/sample09.rb +50 -0
- data/examples/sample10.rb +50 -0
- data/examples/sample11.rb +42 -0
- data/examples/sample12.rb +64 -0
- data/examples/shapes.rb +23 -0
- data/examples/test.xml +26 -0
- data/examples/testorder.rb +43 -0
- data/examples/testxml.rb +7 -0
- data/lib/graphviz/attrs.rb +1 -1
- data/lib/graphviz/constants.rb +4 -4
- data/lib/graphviz/edge.rb +21 -4
- data/lib/graphviz/node.rb +29 -4
- data/lib/graphviz/xml.rb +18 -2
- data/lib/graphviz.rb +74 -11
- metadata +63 -37
data/ChangeLog
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.unshift( "../lib" );
|
2
|
+
require "graphviz"
|
3
|
+
|
4
|
+
g = GraphViz::new( "structs", "output" => "png", :path => ARGV[0] )
|
5
|
+
|
6
|
+
g.node["shape"] = "plaintext"
|
7
|
+
|
8
|
+
g.add_node( "HTML" )
|
9
|
+
|
10
|
+
g.add_node( "struct1", "html" => '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"> <TR><TD>left</TD><TD PORT="f1">mid dle</TD><TD PORT="f2">right</TD></TR> </TABLE>>]; struct2 [label=< <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"> <TR><TD PORT="f0">one</TD><TD>two</TD></TR> </TABLE>')
|
11
|
+
|
12
|
+
g.add_node( "struct2", "html" => '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"> <TR><TD PORT="f0">one</TD><TD>two</TD></TR> </TABLE>' )
|
13
|
+
g.add_node( "struct3", "html" => '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR> <TD ROWSPAN="3">hello<BR/>world</TD> <TD COLSPAN="3">b</TD> <TD ROWSPAN="3">g</TD> <TD ROWSPAN="3">h</TD> </TR> <TR> <TD>c</TD><TD PORT="here">d</TD><TD>e</TD> </TR> <TR> <TD COLSPAN="3">f</TD> </TR> </TABLE>' )
|
14
|
+
|
15
|
+
g.add_edge( "struct1:f1", "struct2:f0" )
|
16
|
+
g.add_edge( "struct1:f2", "struct3:here" )
|
17
|
+
|
18
|
+
g.add_edge( "HTML", "struct1" )
|
19
|
+
|
20
|
+
g.output( "file" => "HTML-Labels.png" )
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g["rankdir"] = "LR"
|
14
|
+
g.node["shape"] = "ellipse"
|
15
|
+
g.edge["arrowhead"] = "normal"
|
16
|
+
|
17
|
+
[
|
18
|
+
"box",
|
19
|
+
"boxbox",
|
20
|
+
"lbox",
|
21
|
+
"lboxlbox",
|
22
|
+
"rbox",
|
23
|
+
"rboxrbox",
|
24
|
+
"olbox",
|
25
|
+
"olboxolbox",
|
26
|
+
"orbox",
|
27
|
+
"orboxorbox",
|
28
|
+
"obox",
|
29
|
+
"oboxobox",
|
30
|
+
"crow",
|
31
|
+
"crowcrow",
|
32
|
+
"lcrow",
|
33
|
+
"lcrowlcrow",
|
34
|
+
"rcrow",
|
35
|
+
"rcrowrcrow",
|
36
|
+
"diamond",
|
37
|
+
"diamonddiamond",
|
38
|
+
"ldiamond",
|
39
|
+
"ldiamondldiamond",
|
40
|
+
"rdiamond",
|
41
|
+
"rdiamondrdiamond",
|
42
|
+
"oldiamond",
|
43
|
+
"oldiamondoldiamond",
|
44
|
+
"ordiamond",
|
45
|
+
"ordiamondordiamond",
|
46
|
+
"odiamond",
|
47
|
+
"odiamondodiamond",
|
48
|
+
"dot",
|
49
|
+
"dotdot",
|
50
|
+
"odot",
|
51
|
+
"odotodot",
|
52
|
+
"inv",
|
53
|
+
"invinv",
|
54
|
+
"linv",
|
55
|
+
"linvlinv",
|
56
|
+
"rinv",
|
57
|
+
"rinvrinv",
|
58
|
+
"olinv",
|
59
|
+
"olinvolinv",
|
60
|
+
"orinv",
|
61
|
+
"orinvorinv",
|
62
|
+
"oinv",
|
63
|
+
"oinvoinv",
|
64
|
+
"none",
|
65
|
+
"nonenone",
|
66
|
+
"normal",
|
67
|
+
"normalnormal",
|
68
|
+
"lnormal",
|
69
|
+
"lnormallnormal",
|
70
|
+
"rnormal",
|
71
|
+
"rnormalrnormal",
|
72
|
+
"olnormal",
|
73
|
+
"olnormalolnormal",
|
74
|
+
"ornormal",
|
75
|
+
"ornormalornormal",
|
76
|
+
"onormal",
|
77
|
+
"onormalonormal",
|
78
|
+
"tee",
|
79
|
+
"teetee",
|
80
|
+
"ltee",
|
81
|
+
"lteeltee",
|
82
|
+
"rtee",
|
83
|
+
"rteertee",
|
84
|
+
"vee",
|
85
|
+
"veevee",
|
86
|
+
"lvee",
|
87
|
+
"lveelvee",
|
88
|
+
"rvee",
|
89
|
+
"rveervee"
|
90
|
+
].each { |s|
|
91
|
+
p = "p_" << s
|
92
|
+
g.add_node( p, "shape" => "point" )
|
93
|
+
g.add_node( s )
|
94
|
+
g.add_edge( p, s, "arrowhead" => s )
|
95
|
+
}
|
96
|
+
|
97
|
+
g.output()
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
ruby sample01.rb $1 > sample01.png
|
4
|
+
ruby sample02.rb $1 > sample02.png
|
5
|
+
ruby sample03.rb $1 > sample03.png
|
6
|
+
ruby sample04.rb $1 > sample04.png
|
7
|
+
|
8
|
+
ruby sample07.rb $1 > sample07.png
|
9
|
+
ruby sample08.rb $1 > sample08.png
|
10
|
+
ruby sample09.rb $1 > sample09.png
|
11
|
+
|
12
|
+
ruby sample11.rb $1 > sample11.png
|
13
|
+
|
14
|
+
ruby shapes.rb $1 > shapes.png
|
15
|
+
ruby arrowhead.rb $1 > arrowhead.png
|
data/examples/p2p.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0], :use => "circo" )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
c0 = g.add_graph( "cluster0" )
|
14
|
+
c0["label"] = "Environnement de Brad !"
|
15
|
+
c0["style"] = "filled"
|
16
|
+
c0["color"] = "blue"
|
17
|
+
|
18
|
+
ja = c0.add_node( "Jennifer_Aniston", :style => "filled", :color => "red" )
|
19
|
+
bp = c0.add_node( "Brad_Pitt", :style => "filled", :color => "white" )
|
20
|
+
aj = c0.add_node( "Angelina_Jolie", :style => "filled", :color => "green" )
|
21
|
+
|
22
|
+
c0.add_edge( ja, bp ) # On ete mariés
|
23
|
+
c0.add_edge( bp, aj ) # Sont ensemble
|
24
|
+
|
25
|
+
jv = g.add_node( "John_Voight", :label => "John Voight", :shape => "rectangle" )
|
26
|
+
md = g.add_node( "Madonna" )
|
27
|
+
gr = g.add_node( "Guy_Ritchie" )
|
28
|
+
|
29
|
+
g.add_edge( aj, jv ) # est la fille de
|
30
|
+
g.add_edge( jv, aj ) # est le pere de
|
31
|
+
g.add_edge( bp, jv, :color => "red", :label => "Est le beau fils de" ) # Beau fils
|
32
|
+
g.add_edge( bp, gr )
|
33
|
+
g.add_edge( gr, md )
|
34
|
+
|
35
|
+
g.output
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", :path => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
11
|
+
end
|
12
|
+
|
13
|
+
main = g.add_node( "main" )
|
14
|
+
parse = g.add_node( "parse" )
|
15
|
+
execute = g.add_node( "execute" )
|
16
|
+
init = g.add_node( "init" )
|
17
|
+
cleanup = g.add_node( "cleanup" )
|
18
|
+
make_string = g.add_node( "make_string" )
|
19
|
+
printf = g.add_node( "printf" )
|
20
|
+
compare = g.add_node( "compare" )
|
21
|
+
|
22
|
+
g.add_edge( main, parse )
|
23
|
+
g.add_edge( parse, execute )
|
24
|
+
g.add_edge( main, init )
|
25
|
+
g.add_edge( main, cleanup )
|
26
|
+
g.add_edge( execute, make_string )
|
27
|
+
g.add_edge( execute, printf )
|
28
|
+
g.add_edge( init, make_string )
|
29
|
+
g.add_edge( main, printf )
|
30
|
+
g.add_edge( execute, compare )
|
31
|
+
|
32
|
+
g.output( :output => "png" )
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", :output => "png", :path => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", :output => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node[:shape] = "ellipse"
|
14
|
+
g.node[:color] = "black"
|
15
|
+
|
16
|
+
g.edge[:color] = "black"
|
17
|
+
g.edge[:weight] = "1"
|
18
|
+
g.edge[:style] = "filled"
|
19
|
+
g.edge[:label] = ""
|
20
|
+
|
21
|
+
g[:size] = "4,4"
|
22
|
+
|
23
|
+
main = g.add_node( "main", :shape => "box" )
|
24
|
+
parse = g.add_node( "parse" )
|
25
|
+
execute = g.add_node( "execute" )
|
26
|
+
init = g.add_node( "init" )
|
27
|
+
cleanup = g.add_node( "cleanup" )
|
28
|
+
make_string = g.add_node( "make_string", :label => 'make a\nstring' )
|
29
|
+
printf = g.add_node( "printf" )
|
30
|
+
compare = g.add_node( "compare", :shape => "box", :style => "filled", :color => ".7 .3 1.0" )
|
31
|
+
|
32
|
+
g.add_edge( main, parse, :weight => "8" )
|
33
|
+
g.add_edge( parse, execute )
|
34
|
+
g.add_edge( main, init, :style => "dotted" )
|
35
|
+
g.add_edge( main, cleanup )
|
36
|
+
g.add_edge( execute, make_string )
|
37
|
+
g.add_edge( execute, printf )
|
38
|
+
g.add_edge( init, make_string )
|
39
|
+
g.add_edge( main, printf, :color => "red", :style => "bold", :label => "100 times" )
|
40
|
+
g.add_edge( execute, compare, :color => "red" )
|
41
|
+
|
42
|
+
g.output( )
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "ellipse"
|
14
|
+
g.node["sides"] = "4"
|
15
|
+
g.node["peripheries"] = ""
|
16
|
+
g.node["color"] = "black"
|
17
|
+
g.node["style"] = ""
|
18
|
+
g.node["skew"] = "0.0"
|
19
|
+
g.node["distortion"] = "0.0"
|
20
|
+
|
21
|
+
a = g.add_node( "a", "shape" => "polygon", "sides" => "5", "peripheries" => "3", "color" => "lightblue", "style" => "filled" )
|
22
|
+
b = g.add_node( "b" )
|
23
|
+
c = g.add_node( "c", "shape" => "polygon", "sides" => "4", "skew" => ".4", "label" => "hello world" )
|
24
|
+
d = g.add_node( "d", "shape" => "invtriangle" )
|
25
|
+
e = g.add_node( "e", "shape" => "polygon", "sides" => "4", "distortion" => ".7" )
|
26
|
+
|
27
|
+
g.add_edge( a, b )
|
28
|
+
g.add_edge( b, c )
|
29
|
+
g.add_edge( b, d )
|
30
|
+
|
31
|
+
g.output()
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "structs", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "structs", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "record"
|
14
|
+
|
15
|
+
struct1 = g.add_node( "struct1", "shape" => "record", "label" => "<f0> left|<f1> mid\ dle|<f2> right" )
|
16
|
+
struct2 = g.add_node( "struct2", "shape" => "record", "label" => "<f0> one|<f1> two" )
|
17
|
+
struct3 = g.add_node( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<here> d|e}| f}| g | h' )
|
18
|
+
|
19
|
+
g.add_edge( struct1, struct2 )
|
20
|
+
g.add_edge( struct1, struct3 )
|
21
|
+
|
22
|
+
g.output()
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "structs", "type" => "graph", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "structs", "type" => "graph" )
|
11
|
+
end
|
12
|
+
|
13
|
+
main = g.add_node( "main" )
|
14
|
+
parse = g.add_node( "parse" )
|
15
|
+
execute = g.add_node( "execute" )
|
16
|
+
init = g.add_node( "init" )
|
17
|
+
cleanup = g.add_node( "cleanup" )
|
18
|
+
make_string = g.add_node( "make_string" )
|
19
|
+
printf = g.add_node( "printf" )
|
20
|
+
compare = g.add_node( "compare" )
|
21
|
+
|
22
|
+
g.add_edge( main, parse )
|
23
|
+
g.add_edge( parse, execute )
|
24
|
+
g.add_edge( main, init )
|
25
|
+
g.add_edge( main, cleanup )
|
26
|
+
g.add_edge( execute, make_string )
|
27
|
+
g.add_edge( execute, printf )
|
28
|
+
g.add_edge( init, make_string )
|
29
|
+
g.add_edge( main, printf )
|
30
|
+
g.add_edge( execute, compare )
|
31
|
+
|
32
|
+
g.output( "output" => "png" )
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "structs", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "structs", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "record"
|
14
|
+
|
15
|
+
g.add_node( "struct1", "shape" => "record", "label" => "<f0> left|<f1> middle|<f2> right" )
|
16
|
+
g.add_node( "struct2", "shape" => "record", "label" => "<f0> one|<f1> two" )
|
17
|
+
g.add_node( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<here> d|e}| f}| g | h' )
|
18
|
+
|
19
|
+
g.add_edge( "struct1:f1", "struct2:f0" )
|
20
|
+
g.add_edge( "struct1:f2", "struct3:here" )
|
21
|
+
|
22
|
+
g.output()
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "nodesep" => ".05", "rankdir" => "LR", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png", "nodesep" => ".05", "rankdir" => "LR" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "record"
|
14
|
+
g.node["width"] = ".1"
|
15
|
+
g.node["height"] = ".1"
|
16
|
+
|
17
|
+
g.add_node( "node0", "label" => "<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> |<f7> | ", "height" => "2.5" )
|
18
|
+
g.add_node( "node1", "label" => "{<n> n14 | 719 |<p> }", "width" => "1.5" )
|
19
|
+
g.add_node( "node2", "label" => "{<n> a1 | 805 |<p> }", "width" => "1.5" )
|
20
|
+
g.add_node( "node3", "label" => "{<n> i9 | 718 |<p> }", "width" => "1.5" )
|
21
|
+
g.add_node( "node4", "label" => "{<n> e5 | 989 |<p> }", "width" => "1.5" )
|
22
|
+
g.add_node( "node5", "label" => "{<n> t20 | 959 |<p> }", "width" => "1.5" )
|
23
|
+
g.add_node( "node6", "label" => "{<n> o15 | 794 |<p> }", "width" => "1.5" )
|
24
|
+
g.add_node( "node7", "label" => "{<n> s19 | 659 |<p> }", "width" => "1.5" )
|
25
|
+
|
26
|
+
g.add_edge( "node0:f0", "node1:n" )
|
27
|
+
g.add_edge( "node0:f1", "node2:n" )
|
28
|
+
g.add_edge( "node0:f2", "node3:n" )
|
29
|
+
g.add_edge( "node0:f5", "node4:n" )
|
30
|
+
g.add_edge( "node0:f6", "node5:n" )
|
31
|
+
g.add_edge( "node2:p", "node6:n" )
|
32
|
+
g.add_edge( "node4:p", "node7:n" )
|
33
|
+
|
34
|
+
g.output()
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "ellipse"
|
14
|
+
g.node["color"] = "black"
|
15
|
+
|
16
|
+
g["color"] = "black"
|
17
|
+
|
18
|
+
c0 = g.add_graph( "cluster0" )
|
19
|
+
c0["label"] = "process #1"
|
20
|
+
c0["style"] = "filled"
|
21
|
+
c0["color"] = "lightgrey"
|
22
|
+
a0 = c0.add_node( "a0", "style" => "filled", "color" => "white" )
|
23
|
+
a1 = c0.add_node( "a1", "style" => "filled", "color" => "white" )
|
24
|
+
a2 = c0.add_node( "a2", "style" => "filled", "color" => "white" )
|
25
|
+
a3 = c0.add_node( "a3", "style" => "filled", "color" => "white" )
|
26
|
+
c0.add_edge( a0, a1 )
|
27
|
+
c0.add_edge( a1, a2 )
|
28
|
+
c0.add_edge( a2, a3 )
|
29
|
+
|
30
|
+
c1 = g.add_graph( "cluster1", "label" => "process #2" )
|
31
|
+
b0 = c1.add_node( "b0", "style" => "filled", "color" => "blue" )
|
32
|
+
b1 = c1.add_node( "b1", "style" => "filled", "color" => "blue" )
|
33
|
+
b2 = c1.add_node( "b2", "style" => "filled", "color" => "blue" )
|
34
|
+
b3 = c1.add_node( "b3", "style" => "filled", "color" => "blue" )
|
35
|
+
c1.add_edge( b0, b1 )
|
36
|
+
c1.add_edge( b1, b2 )
|
37
|
+
c1.add_edge( b2, b3 )
|
38
|
+
|
39
|
+
start = g.add_node( "start", "shape" => "Mdiamond" )
|
40
|
+
endn = g.add_node( "end", "shape" => "Msquare" )
|
41
|
+
|
42
|
+
g.add_edge( start, a0 )
|
43
|
+
g.add_edge( start, b0 )
|
44
|
+
g.add_edge( a1, b3 )
|
45
|
+
g.add_edge( b2, a3 )
|
46
|
+
g.add_edge( a3, a0 )
|
47
|
+
g.add_edge( a3, endn )
|
48
|
+
g.add_edge( b3, endn )
|
49
|
+
|
50
|
+
g.output()
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "type" => "graph", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png", "type" => "graph" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "ellipse"
|
14
|
+
g.node["color"] = "black"
|
15
|
+
|
16
|
+
g["color"] = "black"
|
17
|
+
|
18
|
+
c0 = g.add_graph( "cluster0" )
|
19
|
+
c0["label"] = "process #1"
|
20
|
+
c0["style"] = "filled"
|
21
|
+
c0["color"] = "lightgrey"
|
22
|
+
a0 = c0.add_node( "a0", "style" => "filled", "color" => "white" )
|
23
|
+
a1 = c0.add_node( "a1", "style" => "filled", "color" => "white" )
|
24
|
+
a2 = c0.add_node( "a2", "style" => "filled", "color" => "white" )
|
25
|
+
a3 = c0.add_node( "a3", "style" => "filled", "color" => "white" )
|
26
|
+
c0.add_edge( a0, a1 )
|
27
|
+
c0.add_edge( a1, a2 )
|
28
|
+
c0.add_edge( a2, a3 )
|
29
|
+
|
30
|
+
c1 = g.add_graph( "cluster1", "label" => "process #2" )
|
31
|
+
b0 = c1.add_node( "b0", "style" => "filled", "color" => "blue" )
|
32
|
+
b1 = c1.add_node( "b1", "style" => "filled", "color" => "blue" )
|
33
|
+
b2 = c1.add_node( "b2", "style" => "filled", "color" => "blue" )
|
34
|
+
b3 = c1.add_node( "b3", "style" => "filled", "color" => "blue" )
|
35
|
+
c1.add_edge( b0, b1 )
|
36
|
+
c1.add_edge( b1, b2 )
|
37
|
+
c1.add_edge( b2, b3 )
|
38
|
+
|
39
|
+
start = g.add_node( "start", "shape" => "Mdiamond" )
|
40
|
+
endn = g.add_node( "end", "shape" => "Msquare" )
|
41
|
+
|
42
|
+
g.add_edge( start, a0 )
|
43
|
+
g.add_edge( start, b0 )
|
44
|
+
g.add_edge( a1, b3 )
|
45
|
+
g.add_edge( b2, a3 )
|
46
|
+
g.add_edge( a3, a0 )
|
47
|
+
g.add_edge( a3, endn )
|
48
|
+
g.add_edge( b3, endn )
|
49
|
+
|
50
|
+
g.output()
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
graph = nil
|
7
|
+
if ARGV[0]
|
8
|
+
graph = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
graph = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
graph["compound"] = "true"
|
14
|
+
graph.edge["lhead"] = ""
|
15
|
+
graph.edge["ltail"] = ""
|
16
|
+
|
17
|
+
c0 = graph.add_graph( "cluster0" )
|
18
|
+
a = c0.add_node( "a" )
|
19
|
+
b = c0.add_node( "b" )
|
20
|
+
c = c0.add_node( "c" )
|
21
|
+
d = c0.add_node( "d" )
|
22
|
+
c0.add_edge( a, b )
|
23
|
+
c0.add_edge( a, c )
|
24
|
+
c0.add_edge( b, d )
|
25
|
+
c0.add_edge( c, d )
|
26
|
+
|
27
|
+
c1 = graph.add_graph( "cluster1" )
|
28
|
+
e = c1.add_node( "e" )
|
29
|
+
f = c1.add_node( "f" )
|
30
|
+
g = c1.add_node( "g" )
|
31
|
+
c1.add_edge( e, g )
|
32
|
+
c1.add_edge( e, f )
|
33
|
+
|
34
|
+
h = graph.add_node( "h" )
|
35
|
+
|
36
|
+
graph.add_edge( b, f, "lhead" => "cluster1" )
|
37
|
+
graph.add_edge( d, e )
|
38
|
+
graph.add_edge( c, g, "ltail" => "cluster0", "lhead" => "cluster1" )
|
39
|
+
graph.add_edge( c, e, "ltail" => "cluster0" )
|
40
|
+
graph.add_edge( d, h )
|
41
|
+
|
42
|
+
graph.output()
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node[:shape] = "ellipse"
|
14
|
+
g.node[:color] = "black"
|
15
|
+
|
16
|
+
g[:color] = "black"
|
17
|
+
|
18
|
+
g.cluster0( ) do |cluster|
|
19
|
+
cluster[:label] = "process #1"
|
20
|
+
cluster[:style] = "filled"
|
21
|
+
cluster[:color] = "lightgrey"
|
22
|
+
|
23
|
+
cluster.a0 :style => "filled", :color => "white"
|
24
|
+
cluster.a1 :style => "filled", :color => "white"
|
25
|
+
cluster.a2 :style => "filled", :color => "white"
|
26
|
+
cluster.a3 :style => "filled", :color => "white"
|
27
|
+
|
28
|
+
cluster.a0 << cluster.a1
|
29
|
+
cluster.a1 << cluster.a2
|
30
|
+
cluster.a2 << cluster.a3
|
31
|
+
end
|
32
|
+
|
33
|
+
g.cluster1( :label => "process #2" ) do |cluster|
|
34
|
+
cluster.b0 :style => "filled", :color => "blue"
|
35
|
+
cluster.b1 :style => "filled", :color => "blue"
|
36
|
+
cluster.b2 :style => "filled", :color => "blue"
|
37
|
+
cluster.b3 :style => "filled", :color => "blue"
|
38
|
+
|
39
|
+
cluster.b0 << cluster.b1
|
40
|
+
cluster.b1 << cluster.b2
|
41
|
+
cluster.b2 << cluster.b3
|
42
|
+
end
|
43
|
+
|
44
|
+
g.start :shape => "Mdiamond"
|
45
|
+
g.endn :shape => "Msquare"
|
46
|
+
|
47
|
+
## THIS DON'T WORK !!!
|
48
|
+
#g.start << g.cluster0.a0
|
49
|
+
#g.start << g.cluster1.b0
|
50
|
+
#g.cluster0.a1 << g.cluster1.b3
|
51
|
+
#g.cluster1.b2 << g.cluster0.a3
|
52
|
+
#g.cluster0.a3 << g.cluster0.a0
|
53
|
+
#g.cluster0.a3 << g.endn
|
54
|
+
#g.cluster1.b3 << g.endn
|
55
|
+
|
56
|
+
g.add_edge( g.start, g.cluster0.a0 )
|
57
|
+
g.add_edge( g.start, g.cluster1.b0 )
|
58
|
+
g.add_edge( g.cluster0.a1, g.cluster1.b3 )
|
59
|
+
g.add_edge( g.cluster1.b2, g.cluster0.a3 )
|
60
|
+
g.add_edge( g.cluster0.a3, g.cluster0.a0 )
|
61
|
+
g.add_edge( g.cluster0.a3, g.endn )
|
62
|
+
g.add_edge( g.cluster1.b3, g.endn )
|
63
|
+
|
64
|
+
g.output
|
data/examples/shapes.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["shape"] = "ellipse"
|
14
|
+
|
15
|
+
[ "box", "polygon", "ellipse", "circle", "point",
|
16
|
+
"egg", "triangle", "plaintext", "diamond", "trapezium",
|
17
|
+
"parallelogram", "house", "hexagon", "octagon", "doublecircle",
|
18
|
+
"doubleoctagon", "tripleoctagon", "invtriangle", "invtrapezium", "invhouse",
|
19
|
+
"Mdiamond", "Msquare", "Mcircle" ].each { |s|
|
20
|
+
g.add_node( s, "shape" => s )
|
21
|
+
}
|
22
|
+
|
23
|
+
g.output()
|
data/examples/test.xml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<inventory title="OmniCorp Store #45x10^3">
|
2
|
+
<section name="health">
|
3
|
+
<item upc="123456789" stock="12">
|
4
|
+
<name>Invisibility Cream</name>
|
5
|
+
<price>14.50</price>
|
6
|
+
<description>Makes you invisible</description>
|
7
|
+
</item>
|
8
|
+
<item upc="445322344" stock="18">
|
9
|
+
<name>Levitation Salve</name>
|
10
|
+
<price>23.99</price>
|
11
|
+
<description>Levitate yourself for up to 3 hours per application</description>
|
12
|
+
</item>
|
13
|
+
</section>
|
14
|
+
<section name="food">
|
15
|
+
<item upc="485672034" stock="653">
|
16
|
+
<name>Blork and Freen Instameal</name>
|
17
|
+
<price>4.95</price>
|
18
|
+
<description>A tasty meal in a tablet; just add water</description>
|
19
|
+
</item>
|
20
|
+
<item upc="132957764" stock="44">
|
21
|
+
<name>Grob winglets</name>
|
22
|
+
<price>3.56</price>
|
23
|
+
<description>Tender winglets of Grob. Just add water</description>
|
24
|
+
</item>
|
25
|
+
</section>
|
26
|
+
</inventory>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
g = nil
|
7
|
+
if ARGV[0]
|
8
|
+
g = GraphViz::new( "G", "output" => "png", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G", "output" => "png" )
|
11
|
+
end
|
12
|
+
|
13
|
+
g.node["color"] = "black"
|
14
|
+
|
15
|
+
g.edge["color"] = "black"
|
16
|
+
g.edge["weight"] = "1"
|
17
|
+
g.edge["style"] = "filled"
|
18
|
+
g.edge["label"] = ""
|
19
|
+
|
20
|
+
g["size"] = "4,4"
|
21
|
+
|
22
|
+
g.node["shape"] = "box"
|
23
|
+
main = g.add_node( "main" )
|
24
|
+
g.node["shape"] = "ellipse"
|
25
|
+
parse = g.add_node( "parse" )
|
26
|
+
execute = g.add_node( "execute" )
|
27
|
+
init = g.add_node( "init" )
|
28
|
+
cleanup = g.add_node( "cleanup" )
|
29
|
+
make_string = g.add_node( "make_string", "label" => 'make a\nstring' )
|
30
|
+
printf = g.add_node( "printf" )
|
31
|
+
compare = g.add_node( "compare", "shape" => "box", "style" => "filled", "color" => ".7 .3 1.0" )
|
32
|
+
|
33
|
+
g.add_edge( main, parse, "weight" => "8" )
|
34
|
+
g.add_edge( parse, execute )
|
35
|
+
g.add_edge( main, init, "style" => "dotted" )
|
36
|
+
g.add_edge( main, cleanup )
|
37
|
+
g.add_edge( execute, make_string )
|
38
|
+
g.add_edge( execute, printf )
|
39
|
+
g.add_edge( init, make_string )
|
40
|
+
g.add_edge( main, printf, "color" => "red", "style" => "bold", "label" => "100 times" )
|
41
|
+
g.add_edge( execute, compare, "color" => "red" )
|
42
|
+
|
43
|
+
g.output( )
|
data/examples/testxml.rb
ADDED
data/lib/graphviz/attrs.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2004, 2005, 2006, 2007 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
1
|
+
# Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
data/lib/graphviz/constants.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2004 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
1
|
+
# Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -15,8 +15,7 @@
|
|
15
15
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
16
16
|
|
17
17
|
module Constants
|
18
|
-
RGV_VERSION = "0.8.
|
19
|
-
RGV_DATE = "2007-05-15"
|
18
|
+
RGV_VERSION = "0.8.1"
|
20
19
|
|
21
20
|
## Const: Output formats
|
22
21
|
FORMATS = [
|
@@ -52,7 +51,8 @@ module Constants
|
|
52
51
|
"dot",
|
53
52
|
"neato",
|
54
53
|
"twopi",
|
55
|
-
"fdp"
|
54
|
+
"fdp",
|
55
|
+
"circo"
|
56
56
|
]
|
57
57
|
|
58
58
|
## Const: type de graphs
|
data/lib/graphviz/edge.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2004, 2005, 2006, 2007 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
1
|
+
# Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -23,8 +23,17 @@ class GraphViz
|
|
23
23
|
@xNodeOne
|
24
24
|
@xNodeTwo
|
25
25
|
@oAttrEdge
|
26
|
+
@oGParrent
|
26
27
|
|
27
|
-
|
28
|
+
#
|
29
|
+
# Create a new edge
|
30
|
+
#
|
31
|
+
# In:
|
32
|
+
# vNodeOne : First node
|
33
|
+
# vNodeTwo : Second node
|
34
|
+
# oGParrent : Graph
|
35
|
+
#
|
36
|
+
def initialize( vNodeOne, vNodeTwo, oGParrent = nil )
|
28
37
|
if vNodeOne.class == String
|
29
38
|
@xNodeOne = vNodeOne
|
30
39
|
else
|
@@ -36,19 +45,27 @@ class GraphViz
|
|
36
45
|
else
|
37
46
|
@xNodeTwo = vNodeTwo.name
|
38
47
|
end
|
48
|
+
|
49
|
+
@oGParrent = oGParrent
|
39
50
|
|
40
51
|
@oAttrEdge = GraphViz::Attrs::new( nil, "edge", EDGESATTRS )
|
41
52
|
end
|
42
53
|
|
43
|
-
|
54
|
+
#
|
55
|
+
# Set value +xAttrValue+ to the edge attribut +xAttrName+
|
56
|
+
#
|
57
|
+
def []=( xAttrName, xAttrValue )
|
44
58
|
@oAttrEdge[xAttrName.to_s] = xAttrValue
|
45
59
|
end
|
46
60
|
|
61
|
+
#
|
62
|
+
# Get the value of the node attribut +xAttrName+
|
63
|
+
#
|
47
64
|
def []( xAttrName )
|
48
65
|
@oAttrEdge[xAttrName.to_s].clone
|
49
66
|
end
|
50
67
|
|
51
|
-
def output( oGraphType )
|
68
|
+
def output( oGraphType ) #:nodoc:
|
52
69
|
xLink = " -> "
|
53
70
|
if oGraphType == "graph"
|
54
71
|
xLink = " -- "
|
data/lib/graphviz/node.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2004, 2005, 2006, 2007 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
1
|
+
# Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -22,25 +22,50 @@ class GraphViz
|
|
22
22
|
include Constants
|
23
23
|
@xNodeName
|
24
24
|
@oAttrNode
|
25
|
-
|
26
|
-
|
25
|
+
@oGParrent
|
26
|
+
|
27
|
+
#
|
28
|
+
# Create a new node
|
29
|
+
#
|
30
|
+
# In:
|
31
|
+
# xNodeName : Name of the node
|
32
|
+
# oGParrent : Graph
|
33
|
+
#
|
34
|
+
def initialize( xNodeName, oGParrent = nil )
|
27
35
|
@xNodeName = xNodeName
|
36
|
+
@oGParrent = oGParrent
|
28
37
|
@oAttrNode = GraphViz::Attrs::new( nil, "node", NODESATTRS )
|
29
38
|
end
|
30
39
|
|
40
|
+
#
|
41
|
+
# Get the node name
|
42
|
+
#
|
31
43
|
def name
|
32
44
|
@xNodeName.clone
|
33
45
|
end
|
34
46
|
|
47
|
+
#
|
48
|
+
# Set value +xAttrValue+ to the node attribut +xAttrName+
|
49
|
+
#
|
35
50
|
def []=( xAttrName, xAttrValue )
|
36
51
|
@oAttrNode[xAttrName.to_s] = xAttrValue
|
37
52
|
end
|
38
53
|
|
54
|
+
#
|
55
|
+
# Get the value of the node attribut +xAttrName+
|
56
|
+
#
|
39
57
|
def []( xAttrName )
|
40
58
|
@oAttrNode[xAttrName.to_s].clone
|
41
59
|
end
|
42
60
|
|
43
|
-
|
61
|
+
#
|
62
|
+
# Create an edge between the current node and the node +oNode+
|
63
|
+
#
|
64
|
+
def <<( oNode )
|
65
|
+
return @oGParrent.add_edge( self, oNode )
|
66
|
+
end
|
67
|
+
|
68
|
+
def output #:nodoc:
|
44
69
|
xOut = "" << @xNodeName.clone
|
45
70
|
xAttr = ""
|
46
71
|
xSeparator = ""
|
data/lib/graphviz/xml.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2004, 2005, 2006, 2007 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
1
|
+
# Copyright (C) 2004, 2005, 2006, 2007, 2008 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -26,12 +26,28 @@ class GraphViz
|
|
26
26
|
@bShowText
|
27
27
|
@bShowAttrs
|
28
28
|
|
29
|
+
#
|
30
|
+
# Generate the graph
|
31
|
+
#
|
32
|
+
# Options :
|
33
|
+
# :output : Output format (Constants::FORMATS)
|
34
|
+
# :file : Output file name
|
35
|
+
# :use : Program to use (Constants::PROGRAMS)
|
36
|
+
# :path : Program PATH
|
37
|
+
#
|
29
38
|
def output( *hOpt )
|
30
39
|
@oGraph.output( *hOpt )
|
31
40
|
end
|
32
41
|
|
33
42
|
private
|
34
43
|
|
44
|
+
#
|
45
|
+
# Create a graph from a XML file
|
46
|
+
#
|
47
|
+
# In:
|
48
|
+
# xFile : XML File
|
49
|
+
# *hOpt : Graph options
|
50
|
+
#
|
35
51
|
def initialize( xFile, *hOpt )
|
36
52
|
@xNodeName = "00000"
|
37
53
|
@bShowText = true
|
@@ -55,7 +71,7 @@ class GraphViz
|
|
55
71
|
_init( @oReXML.root() )
|
56
72
|
end
|
57
73
|
|
58
|
-
def _init( oXMLNode )
|
74
|
+
def _init( oXMLNode ) #:nodoc:
|
59
75
|
xLocalNodeName = @xNodeName.clone
|
60
76
|
@xNodeName.succ!
|
61
77
|
|
data/lib/graphviz.rb
CHANGED
@@ -46,16 +46,18 @@ class GraphViz
|
|
46
46
|
attr_accessor :node, :edge
|
47
47
|
|
48
48
|
@elements_order
|
49
|
-
|
49
|
+
|
50
50
|
##
|
51
|
+
# Create a new node
|
52
|
+
#
|
51
53
|
# In:
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
54
|
+
# xNodeName : Name of the new node
|
55
|
+
# *hOpt : Node attributs
|
56
|
+
#
|
57
|
+
# Return the GraphViz::Node object created
|
56
58
|
#
|
57
59
|
def add_node( xNodeName, *hOpt )
|
58
|
-
@hoNodes[xNodeName] = GraphViz::Node::new( xNodeName )
|
60
|
+
@hoNodes[xNodeName] = GraphViz::Node::new( xNodeName, self )
|
59
61
|
|
60
62
|
if hOpt.nil? == false and hOpt[0].nil? == false
|
61
63
|
hOpt[0].each do |xKey, xValue|
|
@@ -72,8 +74,16 @@ class GraphViz
|
|
72
74
|
return( @hoNodes[xNodeName] )
|
73
75
|
end
|
74
76
|
|
77
|
+
##
|
78
|
+
# Create a new edge
|
79
|
+
#
|
80
|
+
# In:
|
81
|
+
# oNodeOne : First node
|
82
|
+
# oNodeTwo : Second Node
|
83
|
+
# *hOpt : Edge attributs
|
84
|
+
#
|
75
85
|
def add_edge( oNodeOne, oNodeTwo, *hOpt )
|
76
|
-
oEdge = GraphViz::Edge::new( oNodeOne, oNodeTwo )
|
86
|
+
oEdge = GraphViz::Edge::new( oNodeOne, oNodeTwo, self )
|
77
87
|
|
78
88
|
if hOpt.nil? == false and hOpt[0].nil? == false
|
79
89
|
hOpt[0].each do |xKey, xValue|
|
@@ -90,8 +100,15 @@ class GraphViz
|
|
90
100
|
return( oEdge )
|
91
101
|
end
|
92
102
|
|
103
|
+
#
|
104
|
+
# Create � new graph
|
105
|
+
#
|
106
|
+
# In:
|
107
|
+
# xGraphName : Graph name
|
108
|
+
# *hOpt : Graph attributs
|
109
|
+
#
|
93
110
|
def add_graph( xGraphName, *hOpt )
|
94
|
-
@hoGraphs[xGraphName] = GraphViz::new( xGraphName,
|
111
|
+
@hoGraphs[xGraphName] = GraphViz::new( xGraphName, :parent => self, :type => @oGraphType )
|
95
112
|
|
96
113
|
if hOpt.nil? == false and hOpt[0].nil? == false
|
97
114
|
hOpt[0].each do |xKey, xValue|
|
@@ -108,14 +125,49 @@ class GraphViz
|
|
108
125
|
return( @hoGraphs[xGraphName] )
|
109
126
|
end
|
110
127
|
|
128
|
+
def method_missing( idName, *args, &block )
|
129
|
+
xName = idName.id2name
|
130
|
+
|
131
|
+
rCod = nil
|
132
|
+
|
133
|
+
if block
|
134
|
+
# Creating a cluster named '#{xName}'
|
135
|
+
rCod = add_graph( xName, args[0] )
|
136
|
+
yield( rCod )
|
137
|
+
else
|
138
|
+
# Create a node named '#{xName}' or search for a node, edge or cluster
|
139
|
+
return( @hoNodes[xName] ) if @hoNodes.keys.include?( xName )
|
140
|
+
return( @hoGraphs[xName] ) if @hoGraphs.keys.include?( xName )
|
141
|
+
|
142
|
+
rCod = add_node( xName, args[0] )
|
143
|
+
end
|
144
|
+
|
145
|
+
return rCod
|
146
|
+
end
|
147
|
+
|
148
|
+
#
|
149
|
+
# Set value +xValue+ to the graph attribut +xAttrName+
|
150
|
+
#
|
111
151
|
def []=( xAttrName, xValue )
|
112
152
|
@graph[xAttrName] = xValue
|
113
153
|
end
|
114
154
|
|
155
|
+
#
|
156
|
+
# Get the value of the graph attribut +xAttrName+
|
157
|
+
#
|
115
158
|
def []( xAttrName )
|
116
159
|
return( @graph[xAttrName].clone )
|
117
160
|
end
|
118
161
|
|
162
|
+
#
|
163
|
+
# Generate the graph
|
164
|
+
#
|
165
|
+
# Options :
|
166
|
+
# :output : Output format (Constants::FORMATS)
|
167
|
+
# :file : Output file name
|
168
|
+
# :use : Program to use (Constants::PROGRAMS)
|
169
|
+
# :path : Program PATH
|
170
|
+
#
|
119
171
|
def output( *hOpt )
|
120
172
|
xDOTScript = ""
|
121
173
|
xLastType = nil
|
@@ -236,7 +288,7 @@ class GraphViz
|
|
236
288
|
end
|
237
289
|
end
|
238
290
|
|
239
|
-
def set_position( xType, xKey, xValue )
|
291
|
+
def set_position( xType, xKey, xValue ) #:nodoc:
|
240
292
|
@elements_order.push( {
|
241
293
|
"type" => "#{xType}_attr",
|
242
294
|
"name" => xKey,
|
@@ -259,13 +311,24 @@ class GraphViz
|
|
259
311
|
## Var: Type de graphe (orient� ou non)
|
260
312
|
@oGraphType
|
261
313
|
|
314
|
+
#
|
315
|
+
# Create a new Graphviz object
|
316
|
+
#
|
317
|
+
# Options :
|
318
|
+
# :output : Output format (Constants::FORMATS)
|
319
|
+
# :file : Output file name
|
320
|
+
# :use : Program to use (Constants::PROGRAMS)
|
321
|
+
# :path : Program PATH
|
322
|
+
# :parent : Parent graph
|
323
|
+
# :type : Graph type (Constants::GRAPHTYPE)
|
324
|
+
#
|
262
325
|
def initialize( xGraphName, *hOpt )
|
263
326
|
@format = "dot"
|
264
327
|
@filename = nil
|
265
328
|
@prog = "dot"
|
266
329
|
@path = nil
|
267
330
|
@name = xGraphName
|
268
|
-
|
331
|
+
|
269
332
|
@elements_order = Array::new()
|
270
333
|
|
271
334
|
@oParentGraph = nil
|
@@ -310,7 +373,7 @@ class GraphViz
|
|
310
373
|
end
|
311
374
|
end
|
312
375
|
|
313
|
-
def find_executable( )
|
376
|
+
def find_executable( ) #:nodoc:
|
314
377
|
cmd = find_executable0( @prog )
|
315
378
|
if cmd == nil and @path != nil
|
316
379
|
__cmd = File.join( @path, @prog )
|
metadata
CHANGED
@@ -1,33 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.3
|
3
|
-
specification_version: 1
|
4
2
|
name: ruby-graphviz
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2007-05-15 00:00:00 +02:00
|
8
|
-
summary: Interface to the GraphViz graphing tool
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: gregoire.lejeune@free.fr
|
12
|
-
homepage: http://raa.ruby-lang.org/project/ruby-graphviz/
|
13
|
-
rubyforge_project:
|
14
|
-
description: Ruby/Graphviz provides an interface to layout and generate images of directed graphs in a variety of formats (PostScript, PNG, etc.) using GraphViz.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.8.1
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Gregoire Lejeune
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-04-06 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ruby/Graphviz provides an interface to layout and generate images of directed graphs in a variety of formats (PostScript, PNG, etc.) using GraphViz.
|
17
|
+
email: gregoire.lejeune@free.fr
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- ChangeLog
|
25
|
+
- COPYING
|
26
|
+
- AUTHORS
|
31
27
|
files:
|
32
28
|
- ChangeLog
|
33
29
|
- COPYING
|
@@ -35,31 +31,61 @@ files:
|
|
35
31
|
- AUTHORS
|
36
32
|
- setup.rb
|
37
33
|
- bin/ruby2gv.rb
|
34
|
+
- examples/arrowhead.rb
|
35
|
+
- examples/HTML-Labels.rb
|
36
|
+
- examples/maketest.sh
|
37
|
+
- examples/p2p.rb
|
38
|
+
- examples/sample01.rb
|
39
|
+
- examples/sample02.rb
|
40
|
+
- examples/sample03.rb
|
41
|
+
- examples/sample04.rb
|
42
|
+
- examples/sample05.rb
|
43
|
+
- examples/sample07.rb
|
44
|
+
- examples/sample08.rb
|
45
|
+
- examples/sample09.rb
|
46
|
+
- examples/sample10.rb
|
47
|
+
- examples/sample11.rb
|
48
|
+
- examples/sample12.rb
|
49
|
+
- examples/shapes.rb
|
50
|
+
- examples/test.xml
|
51
|
+
- examples/testorder.rb
|
52
|
+
- examples/testxml.rb
|
38
53
|
- lib/graphviz
|
39
|
-
- lib/graphviz.rb
|
40
54
|
- lib/graphviz/attrs.rb
|
41
55
|
- lib/graphviz/constants.rb
|
42
56
|
- lib/graphviz/edge.rb
|
43
57
|
- lib/graphviz/node.rb
|
44
58
|
- lib/graphviz/xml.rb
|
45
|
-
|
46
|
-
|
59
|
+
- lib/graphviz.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://raa.ruby-lang.org/project/ruby-graphviz/
|
62
|
+
post_install_message:
|
47
63
|
rdoc_options:
|
48
64
|
- --title
|
49
65
|
- Ruby/GraphViz
|
50
66
|
- --main
|
51
67
|
- README
|
52
68
|
- --line-numbers
|
53
|
-
|
54
|
-
-
|
55
|
-
|
56
|
-
|
57
|
-
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
62
83
|
requirements: []
|
63
84
|
|
64
|
-
|
85
|
+
rubyforge_project: ruby-asp
|
86
|
+
rubygems_version: 1.1.0
|
87
|
+
signing_key:
|
88
|
+
specification_version: 2
|
89
|
+
summary: Interface to the GraphViz graphing tool
|
90
|
+
test_files: []
|
65
91
|
|