ruby-graphviz_c 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemrc +0 -0
- data/.gitignore +9 -0
- data/.travis.yml +7 -0
- data/AUTHORS.rdoc +33 -0
- data/CHANGELOG.rdoc +287 -0
- data/COPYING.rdoc +133 -0
- data/Gemfile +4 -0
- data/README.rdoc +206 -0
- data/Rakefile +71 -0
- data/bin/dot2ruby +91 -0
- data/bin/gem2gv +165 -0
- data/bin/git2gv +167 -0
- data/bin/ruby2gv +234 -0
- data/bin/xml2gv +96 -0
- data/examples/dot/JSP.dot +52 -0
- data/examples/dot/balanced.dot +36 -0
- data/examples/dot/cluster.dot +30 -0
- data/examples/dot/dotgraph.dot +28 -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 +33 -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/rank.dot +6 -0
- data/examples/dot/sdh.dot +284 -0
- data/examples/dot/siblings.dot +492 -0
- data/examples/dot/so-sample001.gv +30 -0
- data/examples/dot/so-sample002.gv +33 -0
- data/examples/dot/so-sample003.gv +45 -0
- data/examples/dot/test.dot +17 -0
- data/examples/dot/test_parse.rb +13 -0
- data/examples/dot/this_crach_with_dot_2.20.dot +24 -0
- data/examples/dot/unix.dot +104 -0
- data/examples/graphml/attributes.ext.graphml +12 -0
- data/examples/graphml/attributes.graphml +40 -0
- data/examples/graphml/cluster.graphml +75 -0
- data/examples/graphml/failed_graph.graphml +461 -0
- data/examples/graphml/hyper.graphml +29 -0
- data/examples/graphml/nested.graphml +54 -0
- data/examples/graphml/port.graphml +32 -0
- data/examples/graphml/simple.graphml +30 -0
- data/examples/hello.png +0 -0
- data/examples/rgv/rgv.ps +125 -0
- data/examples/rgv/test_rgv.rb +12 -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 +25 -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/sample26.rb +8 -0
- data/examples/sample27.rb +8 -0
- data/examples/sample28.rb +12 -0
- data/examples/sample29.rb +8 -0
- data/examples/sample30.rb +12 -0
- data/examples/sample31.rb +10 -0
- data/examples/sample32.rb +14 -0
- data/examples/sample33.rb +43 -0
- data/examples/sample34.rb +29 -0
- data/examples/sample35.rb +43 -0
- data/examples/sample36.rb +35 -0
- data/examples/sample37.rb +87 -0
- data/examples/sample38.rb +12 -0
- data/examples/sample39.rb +11 -0
- data/examples/sample40.rb +17 -0
- data/examples/sample41.rb +8 -0
- data/examples/sample42.rb +35 -0
- data/examples/sample43.rb +26 -0
- data/examples/sample44.rb +97 -0
- data/examples/sample45.rb +24 -0
- data/examples/sample46.rb +43 -0
- data/examples/sample47.rb +7 -0
- data/examples/sample48.rb +62 -0
- data/examples/sample49.rb +10 -0
- data/examples/sample50.rb +215 -0
- data/examples/sample51.rb +37 -0
- data/examples/sample52.rb +62 -0
- data/examples/sample53.rb +26 -0
- data/examples/sample54.rb +26 -0
- data/examples/sample55.rb +9 -0
- data/examples/sample56.rb +10 -0
- data/examples/sample57.rb +8 -0
- data/examples/sample58.rb +33 -0
- data/examples/sample59.rb +14 -0
- data/examples/sample60.rb +12 -0
- data/examples/sample61.rb +12 -0
- data/examples/sample62.rb +24 -0
- data/examples/sample63.rb +32 -0
- data/examples/sample64.rb +31 -0
- data/examples/sample65.rb +9 -0
- data/examples/sample66.rb +4 -0
- data/examples/sample67.rb +10 -0
- data/examples/sample68.rb +27 -0
- data/examples/sample69.rb +23 -0
- data/examples/sample70.rb +9 -0
- data/examples/sample99.rb +70 -0
- data/examples/sdlshapes/README +2 -0
- data/examples/sdlshapes/sdl.ps +655 -0
- data/examples/sdlshapes/sdlshapes.dot +78 -0
- data/examples/test.xml +26 -0
- data/examples/theory/pert.rb +47 -0
- data/examples/theory/tests.rb +87 -0
- data/lib/ext/gvpr/dot2ruby.g +185 -0
- data/lib/graphviz/attrs.rb +73 -0
- data/lib/graphviz/constants.rb +294 -0
- data/lib/graphviz/core_ext.rb +64 -0
- data/lib/graphviz/dot2ruby.rb +59 -0
- data/lib/graphviz/dot_script.rb +109 -0
- data/lib/graphviz/dsl.rb +67 -0
- data/lib/graphviz/edge.rb +197 -0
- data/lib/graphviz/elements.rb +39 -0
- data/lib/graphviz/ext.rb +17 -0
- data/lib/graphviz/family_tree/couple.rb +63 -0
- data/lib/graphviz/family_tree/generation.rb +39 -0
- data/lib/graphviz/family_tree/person.rb +120 -0
- data/lib/graphviz/family_tree/sibling.rb +13 -0
- data/lib/graphviz/family_tree.rb +118 -0
- data/lib/graphviz/graphml.rb +268 -0
- data/lib/graphviz/math/matrix.rb +221 -0
- data/lib/graphviz/node.rb +160 -0
- data/lib/graphviz/nothugly/nothugly.xsl +321 -0
- data/lib/graphviz/nothugly.rb +63 -0
- data/lib/graphviz/theory.rb +321 -0
- data/lib/graphviz/types/arrow_type.rb +32 -0
- data/lib/graphviz/types/color.rb +58 -0
- data/lib/graphviz/types/color_list.rb +24 -0
- data/lib/graphviz/types/esc_string.rb +20 -0
- data/lib/graphviz/types/gv_bool.rb +49 -0
- data/lib/graphviz/types/gv_double.rb +32 -0
- data/lib/graphviz/types/html_string.rb +18 -0
- data/lib/graphviz/types/lbl_string.rb +22 -0
- data/lib/graphviz/types/rect.rb +35 -0
- data/lib/graphviz/types/spline_type.rb +77 -0
- data/lib/graphviz/types.rb +22 -0
- data/lib/graphviz/utils/colors.rb +1018 -0
- data/lib/graphviz/utils.rb +70 -0
- data/lib/graphviz/xml.rb +119 -0
- data/lib/graphviz.rb +967 -0
- data/lib/ruby-graphviz.rb +1 -0
- data/man/dot2ruby.1 +66 -0
- data/man/dot2ruby.1.ronn +55 -0
- data/man/gem2gv.1 +60 -0
- data/man/gem2gv.1.ronn +47 -0
- data/man/git2gv.1 +48 -0
- data/man/git2gv.1.ronn +40 -0
- data/man/ruby2gv.1 +60 -0
- data/man/ruby2gv.1.ronn +47 -0
- data/man/xml2gv.1 +48 -0
- data/man/xml2gv.1.ronn +39 -0
- data/ruby-graphviz.gemspec +47 -0
- data/setup.rb +1585 -0
- data/test/helper.rb +13 -0
- data/test/support.rb +95 -0
- data/test/test_dot_script.rb +47 -0
- data/test/test_examples.rb +151 -0
- data/test/test_graph.rb +115 -0
- data/test/test_search.rb +29 -0
- data/test/test_subgraph.rb +27 -0
- data/test/test_theory.rb +98 -0
- data/test/test_types.rb +65 -0
- data/test/test_utils_colors.rb +52 -0
- metadata +301 -0
@@ -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" )
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::options( :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_edges( g.node0(:f0), g.node1(:f0) )
|
31
|
+
g.add_edges( g.node0(:f1), g.node2(:f0) )
|
32
|
+
g.add_edges( g.node1(:f0), g.node3(:f0) )
|
33
|
+
g.add_edges( g.node1(:f1), g.node4(:f0) )
|
34
|
+
g.add_edges( g.node1(:f2), g.node5(:f0) )
|
35
|
+
g.add_edges( g.node4(:f0), g.node3(:f0) )
|
36
|
+
g.add_edges( g.node4(:f1), g.node6(:f0) )
|
37
|
+
g.add_edges( g.node4(:f2), g.node10(:f0) )
|
38
|
+
g.add_edges( g.node6(:f0), g.node3(:f0) )
|
39
|
+
g.add_edges( g.node6(:f1), g.node7(:f0) )
|
40
|
+
g.add_edges( g.node6(:f2), g.node9(:f0) )
|
41
|
+
g.add_edges( g.node7(:f0), g.node3(:f0) )
|
42
|
+
g.add_edges( g.node7(:f1), g.node1(:f0) )
|
43
|
+
g.add_edges( g.node7(:f2), g.node8(:f0) )
|
44
|
+
g.add_edges( g.node10(:f1), g.node11(:f0) )
|
45
|
+
g.add_edges( g.node10(:f2), g.node12(:f0) )
|
46
|
+
g.add_edges( g.node11(:f2), g.node1(:f0) )
|
47
|
+
}.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
{"png" => "#{$0}.png", "imap" => "#{$0}.html"}.each do |format, file|
|
7
|
+
GraphViz::new( "G" ) { |g|
|
8
|
+
g.command(:URL => "http://www.research.att.com/base.html")
|
9
|
+
g._output(:label => "output", :URL => "colors.html")
|
10
|
+
g.command << g._output
|
11
|
+
}.output( format => file )
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "mainmap" ) { |graph|
|
7
|
+
graph[:URL] = "http://www.research.att.com/base.html"
|
8
|
+
graph.command( :URL => "http://www.research.att.com/command.html" )
|
9
|
+
(graph.command << graph._output( :label => "output" ))[:URL] = "colors.html"
|
10
|
+
}.output( :canon => nil, :cmapx => "#{$0}.html", :png => "#{$0}.png" )
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
r = GraphViz::new( "mainmap" ) { |graph|
|
7
|
+
graph[:URL] = "http://www.research.att.com/base.html"
|
8
|
+
graph.command( :URL => "http://www.research.att.com/command.html" )
|
9
|
+
(graph.command << graph._output( :label => "output" ))[:URL] = "colors.html"
|
10
|
+
}
|
11
|
+
puts r.output( :cmapx => String, :png => "#{$0}.png" )
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz::new( "G" ) { |g|
|
7
|
+
g.hello << g.world
|
8
|
+
g.bonjour( :label => '"Bonjour"' ) - g.monde( :label => "Le\nmonde")
|
9
|
+
g.hola > g.mundo
|
10
|
+
g.holla >> g.welt
|
11
|
+
}.output( :path => "/usr/local/bin", :png => "#{$0}.png" )
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:G){ |g|
|
7
|
+
g[:ratio => "auto", :label => "I love the world!"]
|
8
|
+
|
9
|
+
g.hello( :label => "Hello", :color => "blue" ) # You can do this
|
10
|
+
g.none[ :label => "World", :color => "green" ] # or that
|
11
|
+
(g.hello - g.none)[:style => :bold, :label => " I say"]
|
12
|
+
}.save( :png => "#{$0}.png" )
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:G){ |g|
|
7
|
+
g.add_nodes("\"Hello.\"\nHow are you ?", :href => "http://www.website.com", :tooltip => "\"Hello.\"\nHow are you ?", :shape => "ellipse", :color => "#FF0000")
|
8
|
+
}.save( :svg => "#{$0}.svg" )
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:g){ |g|
|
7
|
+
g[:center] = true
|
8
|
+
a = g.add_nodes("A", :shape => "sdl_procedure_start", :peripheries => 0 )
|
9
|
+
b = g.add_nodes("B", :shape => "sdl_save", :peripheries => 0)
|
10
|
+
c = g.add_nodes("n", :shape => "box", :label => "\\G::\\N\\r")
|
11
|
+
a << b << c
|
12
|
+
}.save( :ps => "#{$0}.ps", :extlib => File.join( File.dirname(__FILE__), "sdlshapes", "sdl.ps" ) )
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" );
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:G){ |g|
|
7
|
+
g.edge[:arrowsize => 0.5]
|
8
|
+
g.graph[:bb => "0,0,638,256"]
|
9
|
+
g.person[:shape => :record];
|
10
|
+
g.driver[:shape => :ellipse];
|
11
|
+
g.owner[:shape => :ellipse];
|
12
|
+
g.passenger[:shape => :ellipse];
|
13
|
+
g.vehicle[:shape => :record];
|
14
|
+
}.save( :png => "#{$0}.png" )
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$:.unshift( "../lib" );
|
2
|
+
require 'graphviz/family_tree'
|
3
|
+
|
4
|
+
tree = GraphViz::FamilyTree.new do
|
5
|
+
generation do
|
6
|
+
abraham.is_a_man( "Abraham" )
|
7
|
+
mona.is_a_woman( "Mona" )
|
8
|
+
|
9
|
+
abraham.is_maried_with mona
|
10
|
+
|
11
|
+
clancy.is_a_man( "Clancy" )
|
12
|
+
jackeline.is_a_woman( "Jackeline" )
|
13
|
+
|
14
|
+
clancy.is_maried_with jackeline
|
15
|
+
end
|
16
|
+
|
17
|
+
generation do
|
18
|
+
herb.is_a_man( "Herb" )
|
19
|
+
homer.is_a_man( "Homer" )
|
20
|
+
|
21
|
+
marge.is_a_woman( "Marge" )
|
22
|
+
patty.is_a_woman( "Patty" )
|
23
|
+
selma.is_a_woman( "Selma" )
|
24
|
+
|
25
|
+
homer.is_maried_with marge
|
26
|
+
end
|
27
|
+
|
28
|
+
couple( abraham, mona ).kids( herb, homer )
|
29
|
+
couple( clancy, jackeline ).kids( marge, patty, selma )
|
30
|
+
|
31
|
+
generation do
|
32
|
+
bart.is_a_boy( "Bart" )
|
33
|
+
lisa.is_a_girl( "Lisa" )
|
34
|
+
maggie.is_a_girl( "Maggie" )
|
35
|
+
ling.is_a_boy( "Ling" )
|
36
|
+
end
|
37
|
+
|
38
|
+
couple( homer, marge ).kids( bart, lisa, maggie )
|
39
|
+
|
40
|
+
ling.kids( selma )
|
41
|
+
end
|
42
|
+
|
43
|
+
puts tree.graph.save( :none => String )
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" )
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.new(:G) { |g|
|
7
|
+
g[:color] = "black"
|
8
|
+
|
9
|
+
g.one :label => "1"
|
10
|
+
|
11
|
+
# This is an anonymous graph
|
12
|
+
c = g.add_graph( :rank => "same" ) { |c|
|
13
|
+
c.two :label => "2"
|
14
|
+
c.three :label => "3"
|
15
|
+
c.two << c.three
|
16
|
+
}
|
17
|
+
|
18
|
+
# And this is not!
|
19
|
+
k = g.add_graph( "Hello" ) { |k|
|
20
|
+
k.four :label => "4"
|
21
|
+
k.five :label => "5"
|
22
|
+
k.four << k.five
|
23
|
+
}
|
24
|
+
|
25
|
+
g.one << c.two
|
26
|
+
g.one << c.three
|
27
|
+
c.two << k.four
|
28
|
+
c.three << k.five
|
29
|
+
}.output( :canon => String )
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" )
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.digraph( :G ) { |g|
|
7
|
+
g[:truecolor => true, :bgcolor => "transparent", :rankdir => "LR"]
|
8
|
+
g.node[:label => "\N"]
|
9
|
+
|
10
|
+
c1 = g.subgraph { |c|
|
11
|
+
c[:rank => "same"]
|
12
|
+
c.mygraph[
|
13
|
+
:label => '# mygraph.dot\ldigraph G {\l Hello -> World\l}\l',
|
14
|
+
:shape => "note",
|
15
|
+
:fontname => "Courier",
|
16
|
+
:fontsize => 10
|
17
|
+
]
|
18
|
+
c.image[ :label => "", :shape => "note", :image => "./hello.png"]
|
19
|
+
}
|
20
|
+
|
21
|
+
c2 = g.subgraph { |c|
|
22
|
+
c[:rank => "same"]
|
23
|
+
c.mysite[:label => "\nexample.com\n ", :shape => "component", :fontname => "Arial"]
|
24
|
+
c.dotgraph[:label => "\ndotgraph.net\n ", :shape => "component", :fontname => "Arial"]
|
25
|
+
}
|
26
|
+
|
27
|
+
g.cluster_0 { |c|
|
28
|
+
c[
|
29
|
+
:label => "my_page.html",
|
30
|
+
:fontname => "Courier",
|
31
|
+
:fontsize => 10,
|
32
|
+
:color => "black"
|
33
|
+
]
|
34
|
+
c.zeimage[:label => "", :shape => "note", :image => "./hello.png"]
|
35
|
+
}
|
36
|
+
|
37
|
+
(c1.mygraph << c2.mysite)[:color => "blue"]
|
38
|
+
(c2.dotgraph << c1.image)[:color => "red"]
|
39
|
+
(c2.dotgraph << c2.mysite)[:color => "red"]
|
40
|
+
(c2.mysite << c2.dotgraph)[:color => "blue"]
|
41
|
+
(c1.image << c2.dotgraph)[:color => "red"]
|
42
|
+
(c2.mysite << g.cluster_0.zeimage)[:color => "red"]
|
43
|
+
}.output( :png => "#{$0}.png", :none => "#{$0}.gv" )
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift( "../lib" )
|
4
|
+
require "graphviz"
|
5
|
+
|
6
|
+
GraphViz.graph( :G ) { |g|
|
7
|
+
last_line = []
|
8
|
+
node_number = 0
|
9
|
+
|
10
|
+
100.times do |j|
|
11
|
+
# New_Line
|
12
|
+
new_line = []
|
13
|
+
c = g.subgraph( :rank => "same" )
|
14
|
+
|
15
|
+
100.times do |i|
|
16
|
+
current_node = c.add_nodes( "N#{node_number}", :shape => "point", :label => "" )
|
17
|
+
last_node = new_line[-1]
|
18
|
+
unless last_node.nil?
|
19
|
+
c.add_edges( last_node, current_node )
|
20
|
+
end
|
21
|
+
new_line << current_node
|
22
|
+
top_first_node = last_line.shift
|
23
|
+
unless top_first_node.nil?
|
24
|
+
g.add_edges( top_first_node, current_node )
|
25
|
+
top_second_node = last_line.shift
|
26
|
+
unless top_second_node.nil?
|
27
|
+
g.add_edges( top_second_node, current_node )
|
28
|
+
last_line.unshift( top_second_node )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
node_number = node_number + 1
|
32
|
+
end
|
33
|
+
last_line = new_line
|
34
|
+
end
|
35
|
+
}.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,87 @@
|
|
1
|
+
$:.unshift( "../lib" )
|
2
|
+
require "graphviz"
|
3
|
+
|
4
|
+
# The goal is to set each planet to its own orbit + set some (earth+moon) to the same orbit
|
5
|
+
|
6
|
+
g = GraphViz::new( "Solarsys",
|
7
|
+
:type => "digraph",
|
8
|
+
:use => "twopi"
|
9
|
+
)
|
10
|
+
|
11
|
+
# the star
|
12
|
+
sun = g.add_nodes(
|
13
|
+
'Sun',
|
14
|
+
:shape => "circle",
|
15
|
+
:penwidth => 2,
|
16
|
+
:fontsize => 12,
|
17
|
+
:style => :filled,
|
18
|
+
:fillcolor => "orange",
|
19
|
+
:label => "Sun\n"
|
20
|
+
)
|
21
|
+
|
22
|
+
planets = Hash.new
|
23
|
+
|
24
|
+
# The Earth and the Moon - in the same subgraph\rank
|
25
|
+
g.subgraph { |c|
|
26
|
+
c[:rank => 'same']
|
27
|
+
planets['Moon'] = c.add_nodes(
|
28
|
+
'Moon',
|
29
|
+
:shape => "circle",
|
30
|
+
:penwidth => 2,
|
31
|
+
:fontsize => 12,
|
32
|
+
:style => :filled,
|
33
|
+
:fillcolor => "red",
|
34
|
+
:label => "Moon\n"
|
35
|
+
)
|
36
|
+
planets['Earth'] = c.add_nodes(
|
37
|
+
'Earth',
|
38
|
+
:shape => "circle",
|
39
|
+
:penwidth => 2,
|
40
|
+
:fontsize => 12,
|
41
|
+
:style => :filled,
|
42
|
+
:fillcolor => "blue",
|
43
|
+
:label => "Earth\n"
|
44
|
+
)
|
45
|
+
c.add_edges( planets['Moon'], planets['Earth'],
|
46
|
+
:penwidth => 2,
|
47
|
+
:labeltooltip => "distance",
|
48
|
+
:color => "black"
|
49
|
+
)
|
50
|
+
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
g.add_edges( sun, planets['Earth'],
|
55
|
+
:penwidth => 2,
|
56
|
+
:labeltooltip => "distance",
|
57
|
+
:color => "black"
|
58
|
+
)
|
59
|
+
|
60
|
+
i = 0
|
61
|
+
# some more planets - each supposed having its own orbit - im trying to do it with rank
|
62
|
+
['Mercury','Venus','Mars','Jupiter','Saturn','Uranus','Neptune','Pluto'].each { |p|
|
63
|
+
i = i + 1
|
64
|
+
# set each to its own orbit
|
65
|
+
# that doesnt seem to work ...
|
66
|
+
g.subgraph { |c|
|
67
|
+
c[:rank => "same"]
|
68
|
+
planets[p] = c.add_nodes(
|
69
|
+
p,
|
70
|
+
:shape => "circle",
|
71
|
+
:penwidth => 2,
|
72
|
+
:fontsize => 12,
|
73
|
+
:fillcolor => "green",
|
74
|
+
:style => :filled,
|
75
|
+
:label => "#{p}\n"
|
76
|
+
)
|
77
|
+
c.add_edges( sun, planets[p],
|
78
|
+
:penwidth => 2,
|
79
|
+
:label => "distance",
|
80
|
+
:color => "black"
|
81
|
+
)
|
82
|
+
}
|
83
|
+
|
84
|
+
}
|
85
|
+
|
86
|
+
g.output( :png => "#{$0}.png" )
|
87
|
+
g.output( :none => "#{$0}.dot" )
|