luquet-ruby-graphviz 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +7 -0
- data/COPYING +340 -0
- data/ChangeLog +66 -0
- data/README.rdoc +69 -0
- data/bin/ruby2gv +194 -0
- data/examples/HTML-Labels.rb +20 -0
- data/examples/arrowhead.rb +97 -0
- data/examples/dot/cluster.dot +31 -0
- data/examples/dot/fsm.dot +20 -0
- data/examples/dot/genetic.dot +118 -0
- data/examples/dot/hello.dot +1 -0
- data/examples/dot/hello_test.rb +14 -0
- data/examples/dot/lion_share.dot +103 -0
- data/examples/dot/prof.dot +150 -0
- data/examples/dot/psg.dot +28 -0
- data/examples/dot/sdh.dot +284 -0
- data/examples/dot/siblings.dot +492 -0
- data/examples/dot/test.dot +17 -0
- data/examples/dot/unix.dot +104 -0
- data/examples/graphviz.org/TrafficLights.rb +62 -0
- data/examples/graphviz.org/cluster.rb +62 -0
- data/examples/graphviz.org/hello_world.rb +10 -0
- data/examples/graphviz.org/lion_share.rb +215 -0
- data/examples/graphviz.org/process.rb +37 -0
- data/examples/maketest.sh +85 -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/sample06.rb +46 -0
- data/examples/sample07.rb +23 -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 +55 -0
- data/examples/sample13.rb +48 -0
- data/examples/sample14.rb +44 -0
- 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/sample21.rb +12 -0
- data/examples/sample22.rb +10 -0
- data/examples/sample23.rb +11 -0
- data/examples/sample24.rb +11 -0
- data/examples/sample25.rb +11 -0
- data/examples/shapes.rb +24 -0
- data/examples/test.xml +26 -0
- data/examples/testorder.rb +43 -0
- data/examples/testxml.rb +7 -0
- data/lib/graphviz.rb +655 -0
- data/lib/graphviz/attrs.rb +51 -0
- data/lib/graphviz/constants.rb +246 -0
- data/lib/graphviz/dot.treetop +97 -0
- data/lib/graphviz/edge.rb +130 -0
- data/lib/graphviz/node.rb +129 -0
- data/lib/graphviz/parser.rb +249 -0
- data/lib/graphviz/xml.rb +131 -0
- data/setup.rb +1585 -0
- metadata +176 -0
@@ -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", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
g = GraphViz::new( "G" )
|
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( :png => "#{$0}.png" )
|
@@ -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", "path" => ARGV[0] )
|
9
|
+
else
|
10
|
+
graph = GraphViz::new( "G" )
|
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( :png => "#{$0}.png" )
|
@@ -0,0 +1,55 @@
|
|
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
|
+
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", :label => "end"
|
46
|
+
|
47
|
+
g.start << g.cluster0.a0
|
48
|
+
g.start << g.cluster1.b0
|
49
|
+
g.cluster0.a1 << g.cluster1.b3
|
50
|
+
g.cluster1.b2 << g.cluster0.a3
|
51
|
+
g.cluster0.a3 << g.cluster0.a0
|
52
|
+
g.cluster0.a3 << g.endn
|
53
|
+
g.cluster1.b3 << g.endn
|
54
|
+
|
55
|
+
g.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "G" ) { |graph|
|
7
|
+
graph.node[:shape] = "ellipse"
|
8
|
+
graph.node[:color] = "black"
|
9
|
+
|
10
|
+
graph[:color] = "black"
|
11
|
+
|
12
|
+
graph.cluster0( ) do |cluster|
|
13
|
+
cluster[:label] = "process #1"
|
14
|
+
cluster[:style] = "filled"
|
15
|
+
cluster[:color] = "lightgrey"
|
16
|
+
|
17
|
+
cluster.a0 :style => "filled", :color => "white"
|
18
|
+
cluster.a1 :style => "filled", :color => "white"
|
19
|
+
cluster.a2 :style => "filled", :color => "white"
|
20
|
+
cluster.a3 :style => "filled", :color => "white"
|
21
|
+
|
22
|
+
cluster.a0 << cluster.a1
|
23
|
+
cluster.a1 << cluster.a2
|
24
|
+
cluster.a2 << cluster.a3
|
25
|
+
end
|
26
|
+
|
27
|
+
graph.cluster1( :label => "process #2" ) do |cluster|
|
28
|
+
cluster.b0 :style => "filled", :color => "blue"
|
29
|
+
cluster.b1 :style => "filled", :color => "blue"
|
30
|
+
cluster.b2 :style => "filled", :color => "blue"
|
31
|
+
cluster.b3 :style => "filled", :color => "blue"
|
32
|
+
|
33
|
+
cluster.b0 << cluster.b1
|
34
|
+
cluster.b1 << cluster.b2
|
35
|
+
cluster.b2 << cluster.b3
|
36
|
+
end
|
37
|
+
|
38
|
+
graph.start :shape => "Mdiamond"
|
39
|
+
graph.endn :shape => "Msquare", :label => "end"
|
40
|
+
|
41
|
+
graph.start << graph.cluster0.a0
|
42
|
+
graph.start << graph.cluster1.b0
|
43
|
+
graph.cluster0.a1 << graph.cluster1.b3
|
44
|
+
graph.cluster1.b2 << graph.cluster0.a3
|
45
|
+
graph.cluster0.a3 << graph.cluster0.a0
|
46
|
+
graph.cluster0.a3 << graph.endn
|
47
|
+
graph.cluster1.b3 << graph.endn
|
48
|
+
}.output( :path => '/usr/local/bin/', :png => "#{$0}.png" )
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "G" ) { |graph|
|
7
|
+
graph.node[:shape] = "ellipse"
|
8
|
+
graph.node[:color] = "black"
|
9
|
+
|
10
|
+
graph[:color] = "black"
|
11
|
+
|
12
|
+
graph.cluster0( ) do |cluster|
|
13
|
+
cluster[:label] = "process #1"
|
14
|
+
cluster[:style] = "filled"
|
15
|
+
cluster[:color] = "lightgrey"
|
16
|
+
|
17
|
+
cluster.node[:style] = "filled"
|
18
|
+
cluster.node[:color] = "white"
|
19
|
+
|
20
|
+
cluster.a0 << cluster.a1
|
21
|
+
cluster.a1 << cluster.a2
|
22
|
+
cluster.a2 << cluster.a3
|
23
|
+
end
|
24
|
+
|
25
|
+
graph.cluster1( :label => "process #2", :color => "blue" ) do |cluster|
|
26
|
+
cluster.node[:style] = "filled"
|
27
|
+
cluster.node[:color] = "lightgrey"
|
28
|
+
|
29
|
+
cluster.b0 << cluster.b1
|
30
|
+
cluster.b1 << cluster.b2
|
31
|
+
cluster.b2 << cluster.b3
|
32
|
+
end
|
33
|
+
|
34
|
+
graph.start :shape => "Mdiamond"
|
35
|
+
graph.endn :shape => "Msquare", :label => "end"
|
36
|
+
|
37
|
+
graph.start << graph.cluster0.a0
|
38
|
+
graph.start << graph.cluster1.b0
|
39
|
+
graph.cluster0.a1 << graph.cluster1.b3
|
40
|
+
graph.cluster1.b2 << graph.cluster0.a3
|
41
|
+
graph.cluster0.a3 << graph.cluster0.a0
|
42
|
+
graph.cluster0.a3 << graph.endn
|
43
|
+
graph.cluster1.b3 << graph.endn
|
44
|
+
}.output( :path => '/usr/local/bin/', :png => "#{$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", :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/', :png => "#{$0}.png" )
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "G", :type => "graph", :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/', :png => "#{$0}.png" )
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "G", :type => "graph", :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/', :png => "#{$0}.png" )
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "G", :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/', :png => "#{$0}.png" )
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "ER", :type => "graph", :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/', :png => "#{$0}.png" )
|