rgl 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/ChangeLog +74 -0
  2. data/Makefile +72 -0
  3. data/README +240 -0
  4. data/Rakefile +210 -0
  5. data/TAGS +209 -0
  6. data/examples/canvas.rb +103 -0
  7. data/examples/codegraph +238 -0
  8. data/examples/example.jpg +0 -0
  9. data/examples/examples.rb +112 -0
  10. data/examples/graph.dot +54 -0
  11. data/examples/graph.png +0 -0
  12. data/examples/module_graph.jpg +0 -0
  13. data/examples/north.rb +12 -0
  14. data/examples/north/Graph.log +128 -0
  15. data/examples/north/g.10.0.graphml +28 -0
  16. data/examples/north/g.10.1.graphml +28 -0
  17. data/examples/north/g.10.11.graphml +31 -0
  18. data/examples/north/g.10.12.graphml +27 -0
  19. data/examples/north/g.10.13.graphml +27 -0
  20. data/examples/north/g.10.14.graphml +27 -0
  21. data/examples/north/g.10.15.graphml +26 -0
  22. data/examples/north/g.10.16.graphml +26 -0
  23. data/examples/north/g.10.17.graphml +26 -0
  24. data/examples/north/g.10.19.graphml +37 -0
  25. data/examples/north/g.10.2.graphml +28 -0
  26. data/examples/north/g.10.20.graphml +38 -0
  27. data/examples/north/g.10.22.graphml +43 -0
  28. data/examples/north/g.10.24.graphml +30 -0
  29. data/examples/north/g.10.25.graphml +45 -0
  30. data/examples/north/g.10.27.graphml +38 -0
  31. data/examples/north/g.10.28.graphml +30 -0
  32. data/examples/north/g.10.29.graphml +38 -0
  33. data/examples/north/g.10.3.graphml +26 -0
  34. data/examples/north/g.10.30.graphml +34 -0
  35. data/examples/north/g.10.31.graphml +42 -0
  36. data/examples/north/g.10.34.graphml +42 -0
  37. data/examples/north/g.10.37.graphml +28 -0
  38. data/examples/north/g.10.38.graphml +38 -0
  39. data/examples/north/g.10.39.graphml +36 -0
  40. data/examples/north/g.10.4.graphml +26 -0
  41. data/examples/north/g.10.40.graphml +37 -0
  42. data/examples/north/g.10.41.graphml +37 -0
  43. data/examples/north/g.10.42.graphml +26 -0
  44. data/examples/north/g.10.45.graphml +28 -0
  45. data/examples/north/g.10.46.graphml +32 -0
  46. data/examples/north/g.10.5.graphml +31 -0
  47. data/examples/north/g.10.50.graphml +30 -0
  48. data/examples/north/g.10.56.graphml +29 -0
  49. data/examples/north/g.10.57.graphml +32 -0
  50. data/examples/north/g.10.58.graphml +32 -0
  51. data/examples/north/g.10.6.graphml +26 -0
  52. data/examples/north/g.10.60.graphml +32 -0
  53. data/examples/north/g.10.61.graphml +34 -0
  54. data/examples/north/g.10.62.graphml +34 -0
  55. data/examples/north/g.10.68.graphml +30 -0
  56. data/examples/north/g.10.69.graphml +32 -0
  57. data/examples/north/g.10.7.graphml +29 -0
  58. data/examples/north/g.10.70.graphml +26 -0
  59. data/examples/north/g.10.71.graphml +27 -0
  60. data/examples/north/g.10.72.graphml +28 -0
  61. data/examples/north/g.10.74.graphml +29 -0
  62. data/examples/north/g.10.75.graphml +29 -0
  63. data/examples/north/g.10.78.graphml +27 -0
  64. data/examples/north/g.10.79.graphml +34 -0
  65. data/examples/north/g.10.8.graphml +29 -0
  66. data/examples/north/g.10.80.graphml +34 -0
  67. data/examples/north/g.10.82.graphml +35 -0
  68. data/examples/north/g.10.83.graphml +32 -0
  69. data/examples/north/g.10.85.graphml +34 -0
  70. data/examples/north/g.10.86.graphml +34 -0
  71. data/examples/north/g.10.88.graphml +37 -0
  72. data/examples/north/g.10.89.graphml +29 -0
  73. data/examples/north/g.10.9.graphml +26 -0
  74. data/examples/north/g.10.90.graphml +32 -0
  75. data/examples/north/g.10.91.graphml +31 -0
  76. data/examples/north/g.10.92.graphml +26 -0
  77. data/examples/north/g.10.93.graphml +32 -0
  78. data/examples/north/g.10.94.graphml +34 -0
  79. data/examples/north/g.12.8.graphml +40 -0
  80. data/examples/north/g.14.9.graphml +36 -0
  81. data/examples/north2.rb +21 -0
  82. data/examples/rdep-rgl.rb +395 -0
  83. data/install.rb +49 -0
  84. data/lib/rgl/adjacency.rb +151 -0
  85. data/lib/rgl/base.rb +299 -0
  86. data/lib/rgl/connected_components.rb +125 -0
  87. data/lib/rgl/dot.rb +63 -0
  88. data/lib/rgl/graphxml.rb +52 -0
  89. data/lib/rgl/implicit.rb +151 -0
  90. data/lib/rgl/mutable.rb +54 -0
  91. data/lib/rgl/rdot.rb +264 -0
  92. data/lib/rgl/topsort.rb +61 -0
  93. data/lib/rgl/transitiv_closure.rb +34 -0
  94. data/lib/rgl/traversal.rb +296 -0
  95. data/tests/TestComponents.rb +67 -0
  96. data/tests/TestDirectedGraph.rb +100 -0
  97. data/tests/TestEdge.rb +33 -0
  98. data/tests/TestGraphXML.rb +57 -0
  99. data/tests/TestImplicit.rb +52 -0
  100. data/tests/TestTransitiveClosure.rb +29 -0
  101. data/tests/TestTraversal.rb +222 -0
  102. data/tests/TestUnDirectedGraph.rb +98 -0
  103. metadata +163 -0
@@ -0,0 +1,98 @@
1
+ require 'test/unit'
2
+ require 'rgl/adjacency'
3
+
4
+ include RGL
5
+ include RGL::Edge
6
+
7
+ class TestUnDirectedGraph < Test::Unit::TestCase
8
+
9
+ def setup
10
+ @dg = AdjacencyGraph.new
11
+ [[1,2],[2,3],[3,2],[2,4]].each do |(src,target)|
12
+ @dg.add_edge(src, target)
13
+ end
14
+ end
15
+
16
+ def test_empty_graph
17
+ dg = AdjacencyGraph.new
18
+ assert(dg.empty?)
19
+ assert(!dg.directed?)
20
+ assert(!dg.has_edge?(2,1))
21
+ assert(!dg.has_vertex?(3))
22
+ # Non existend vertex result in a Name Error because each_key is
23
+ # called for nil
24
+ assert_raises(NoVertexError) {dg.out_degree(3)}
25
+ assert_equal([],dg.vertices)
26
+ assert_equal(0,dg.size)
27
+ assert_equal(0,dg.num_vertices)
28
+ assert_equal(0,dg.num_edges)
29
+ assert_equal(UnDirectedEdge,dg.edge_class)
30
+ assert([].eql?(dg.edges))
31
+ assert([].eql?(dg.to_a))
32
+ end
33
+
34
+ def test_add
35
+ dg = AdjacencyGraph.new
36
+ dg.add_edge(1,2)
37
+ assert(!dg.empty?)
38
+ assert(dg.has_edge?(1,2))
39
+ assert(dg.has_edge?(2,1), "Backwards edge not included!")
40
+ assert(dg.has_vertex?(1) && dg.has_vertex?(2))
41
+ assert(!dg.has_vertex?(3))
42
+
43
+ assert_equal([1,2],dg.vertices.sort)
44
+ assert([DirectedEdge.new(1,2)].eql?(dg.edges))
45
+ assert_equal("(1=2)",dg.edges.to_s)
46
+
47
+ assert_equal([2],dg.adjacent_vertices(1))
48
+ assert_equal([1],dg.adjacent_vertices(2))
49
+
50
+ assert_equal(1,dg.out_degree(1))
51
+ assert_equal(1,dg.out_degree(2))
52
+ end
53
+
54
+ def test_edges
55
+ assert_equal(3, @dg.edges.length)
56
+ edges = [[1,2],[2,3],[2,4]].map {|x| UnDirectedEdge.new(*x)}
57
+ assert_equal(edges, @dg.edges.sort)
58
+ # assert_equal([0,1,2,3], @dg.edges.map {|l| l.info}.sort)
59
+ end
60
+
61
+ def test_vertices
62
+ assert_equal([1,2,3,4], @dg.vertices.sort)
63
+ end
64
+
65
+ def test_edges_from_to?
66
+ assert @dg.has_edge?(1,2)
67
+ assert @dg.has_edge?(2,3)
68
+ assert @dg.has_edge?(3,2)
69
+ assert @dg.has_edge?(2,4)
70
+ assert @dg.has_edge?(2,1)
71
+ assert !@dg.has_edge?(3,1)
72
+ assert !@dg.has_edge?(4,1)
73
+ assert @dg.has_edge?(4,2)
74
+ end
75
+
76
+ def test_remove_edges
77
+ @dg.remove_edge 1,2
78
+ assert !@dg.has_edge?(1,2), "(1,2) should not be an edge any more."
79
+ @dg.remove_edge 1,2
80
+ assert !@dg.has_edge?(2,1)
81
+ @dg.remove_vertex 3
82
+ assert !@dg.has_vertex?(3), "3 should not be a vertex any more."
83
+ assert !@dg.has_edge?(2,3)
84
+ assert_equal([UnDirectedEdge.new(2,4)],@dg.edges)
85
+ end
86
+
87
+ def test_add_vertices
88
+ dg = AdjacencyGraph.new
89
+ dg.add_vertices 1,3,2,4
90
+ assert_equal dg.vertices.sort, [1,2,3,4]
91
+
92
+ dg.remove_vertices 1,3
93
+ assert_equal dg.vertices.sort, [2,4]
94
+
95
+ dg.remove_vertices 1,3,Object # ones again
96
+ assert_equal dg.vertices.sort, [2,4]
97
+ end
98
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.3
3
+ specification_version: 1
4
+ name: rgl
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.2.2
7
+ date: 2004-12-12
8
+ summary: Ruby Graph Library
9
+ require_paths:
10
+ - lib
11
+ email: hd.at.clr@hduchene.de
12
+ homepage: rgl.rubyforge.org
13
+ rubyforge_project: rgl
14
+ description: "RGL is a framework for graph data structures and algorithms. The design of the
15
+ library is much influenced by the Boost Graph Library (BGL) which is written in
16
+ C++ heavily using its template mechanism. RGL currently contains a core set of
17
+ algorithm patterns: * Breadth First Search * Depth First Search The
18
+ algorithm patterns by themselves do not compute any meaningful quantities over
19
+ graphs, they are merely building blocks for constructing graph algorithms. The
20
+ graph algorithms in RGL currently include: * Topological Sort * Connected
21
+ Components * Strongly Connected Components * Transitive Closure"
22
+ autorequire: rgl
23
+ default_executable:
24
+ bindir: bin
25
+ has_rdoc: true
26
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
27
+ requirements:
28
+ -
29
+ - ">"
30
+ - !ruby/object:Gem::Version
31
+ version: 0.0.0
32
+ version:
33
+ platform: ruby
34
+ authors:
35
+ - Horst Duchene
36
+ files:
37
+ - install.rb
38
+ - ChangeLog
39
+ - Makefile
40
+ - README
41
+ - Rakefile
42
+ - TAGS
43
+ - tests/TestGraphXML.rb
44
+ - tests/TestComponents.rb
45
+ - tests/TestDirectedGraph.rb
46
+ - tests/TestEdge.rb
47
+ - tests/TestImplicit.rb
48
+ - tests/TestTransitiveClosure.rb
49
+ - tests/TestTraversal.rb
50
+ - tests/TestUnDirectedGraph.rb
51
+ - examples/north
52
+ - examples/canvas.rb
53
+ - examples/example.jpg
54
+ - examples/examples.rb
55
+ - examples/module_graph.jpg
56
+ - examples/north.rb
57
+ - examples/north2.rb
58
+ - examples/rdep-rgl.rb
59
+ - examples/codegraph
60
+ - examples/graph.dot
61
+ - examples/graph.png
62
+ - examples/north/Graph.log
63
+ - examples/north/g.10.0.graphml
64
+ - examples/north/g.10.1.graphml
65
+ - examples/north/g.10.11.graphml
66
+ - examples/north/g.10.12.graphml
67
+ - examples/north/g.10.13.graphml
68
+ - examples/north/g.10.14.graphml
69
+ - examples/north/g.10.15.graphml
70
+ - examples/north/g.10.16.graphml
71
+ - examples/north/g.10.17.graphml
72
+ - examples/north/g.10.19.graphml
73
+ - examples/north/g.10.2.graphml
74
+ - examples/north/g.10.20.graphml
75
+ - examples/north/g.10.22.graphml
76
+ - examples/north/g.10.24.graphml
77
+ - examples/north/g.10.25.graphml
78
+ - examples/north/g.10.27.graphml
79
+ - examples/north/g.10.28.graphml
80
+ - examples/north/g.10.29.graphml
81
+ - examples/north/g.10.3.graphml
82
+ - examples/north/g.10.30.graphml
83
+ - examples/north/g.10.31.graphml
84
+ - examples/north/g.10.34.graphml
85
+ - examples/north/g.10.37.graphml
86
+ - examples/north/g.10.38.graphml
87
+ - examples/north/g.10.39.graphml
88
+ - examples/north/g.10.4.graphml
89
+ - examples/north/g.10.40.graphml
90
+ - examples/north/g.10.41.graphml
91
+ - examples/north/g.10.42.graphml
92
+ - examples/north/g.10.45.graphml
93
+ - examples/north/g.10.46.graphml
94
+ - examples/north/g.10.5.graphml
95
+ - examples/north/g.10.50.graphml
96
+ - examples/north/g.10.56.graphml
97
+ - examples/north/g.10.57.graphml
98
+ - examples/north/g.10.58.graphml
99
+ - examples/north/g.10.6.graphml
100
+ - examples/north/g.10.60.graphml
101
+ - examples/north/g.10.61.graphml
102
+ - examples/north/g.10.62.graphml
103
+ - examples/north/g.10.68.graphml
104
+ - examples/north/g.10.69.graphml
105
+ - examples/north/g.10.7.graphml
106
+ - examples/north/g.10.70.graphml
107
+ - examples/north/g.10.71.graphml
108
+ - examples/north/g.10.72.graphml
109
+ - examples/north/g.10.74.graphml
110
+ - examples/north/g.10.75.graphml
111
+ - examples/north/g.10.78.graphml
112
+ - examples/north/g.10.79.graphml
113
+ - examples/north/g.10.8.graphml
114
+ - examples/north/g.10.80.graphml
115
+ - examples/north/g.10.82.graphml
116
+ - examples/north/g.10.83.graphml
117
+ - examples/north/g.10.85.graphml
118
+ - examples/north/g.10.86.graphml
119
+ - examples/north/g.10.88.graphml
120
+ - examples/north/g.10.89.graphml
121
+ - examples/north/g.10.9.graphml
122
+ - examples/north/g.10.90.graphml
123
+ - examples/north/g.10.91.graphml
124
+ - examples/north/g.10.92.graphml
125
+ - examples/north/g.10.93.graphml
126
+ - examples/north/g.10.94.graphml
127
+ - examples/north/g.12.8.graphml
128
+ - examples/north/g.14.9.graphml
129
+ - lib/rgl/adjacency.rb
130
+ - lib/rgl/base.rb
131
+ - lib/rgl/connected_components.rb
132
+ - lib/rgl/dot.rb
133
+ - lib/rgl/graphxml.rb
134
+ - lib/rgl/implicit.rb
135
+ - lib/rgl/mutable.rb
136
+ - lib/rgl/rdot.rb
137
+ - lib/rgl/topsort.rb
138
+ - lib/rgl/transitiv_closure.rb
139
+ - lib/rgl/traversal.rb
140
+ test_files: []
141
+ rdoc_options:
142
+ - "--title"
143
+ - "RGL - Ruby Graph Library"
144
+ - "--main"
145
+ - README
146
+ - "--line-numbers"
147
+ extra_rdoc_files:
148
+ - README
149
+ executables: []
150
+ extensions: []
151
+ requirements:
152
+ - "Stream library, v0.5 or later"
153
+ dependencies:
154
+ - !ruby/object:Gem::Dependency
155
+ name: stream
156
+ version_requirement:
157
+ version_requirements: !ruby/object:Gem::Version::Requirement
158
+ requirements:
159
+ -
160
+ - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: "0.5"
163
+ version: