rgl 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +75 -1
- data/Rakefile +18 -3
- data/install.rb +0 -0
- data/lib/rgl/adjacency.rb +2 -1
- data/lib/rgl/base.rb +1 -1
- data/lib/rgl/condensation.rb +47 -0
- data/lib/rgl/dot.rb +13 -13
- data/lib/rgl/rdot.rb +28 -28
- data/lib/rgl/transitiv_closure.rb +2 -46
- data/lib/rgl/transitivity.rb +179 -0
- data/tests/TestGraph.rb +36 -20
- data/tests/TestRdot.rb +237 -189
- data/tests/TestTransitivity.rb +129 -0
- metadata +138 -127
- data/tests/TestTransitiveClosure.rb +0 -26
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rgl/transitivity'
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
include RGL
|
6
|
+
|
7
|
+
class TestTransitiveClosure < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@dg = DirectedAdjacencyGraph.new
|
11
|
+
@dg.add_edges([1,2],[2,3],[2,4],[4,5],[1,6],[6,4])
|
12
|
+
@dg_tc = DirectedAdjacencyGraph.new
|
13
|
+
@dg_tc.add_edges(
|
14
|
+
[1,2],[1,3],[1,4],[1,5],[1,6],
|
15
|
+
[2,3],[2,4],[2,5],
|
16
|
+
[4,5],
|
17
|
+
[6,4],[6,5]
|
18
|
+
)
|
19
|
+
@dg_tr = DirectedAdjacencyGraph.new
|
20
|
+
@dg_tr.add_edges(
|
21
|
+
[1,2],[1,6],
|
22
|
+
[2,3],[2,4],
|
23
|
+
[4,5],
|
24
|
+
[6,4]
|
25
|
+
)
|
26
|
+
|
27
|
+
@dg_loner = @dg.dup
|
28
|
+
@dg_loner.add_vertices(7, 8, 9)
|
29
|
+
@dg_loner_tc = @dg_tc.dup
|
30
|
+
@dg_loner_tc.add_vertices(7, 8, 9)
|
31
|
+
@dg_loner_tr = @dg_tr.dup
|
32
|
+
@dg_loner_tr.add_vertices(7, 8, 9)
|
33
|
+
|
34
|
+
@dg_cyclic = DirectedAdjacencyGraph.new
|
35
|
+
@dg_cyclic.add_edges(
|
36
|
+
[1,1],[1,2],
|
37
|
+
[2,3],
|
38
|
+
[3,4],
|
39
|
+
[4,5],
|
40
|
+
[5,6],
|
41
|
+
[6,3]
|
42
|
+
)
|
43
|
+
@dg_cyclic_tc = DirectedAdjacencyGraph.new
|
44
|
+
@dg_cyclic_tc.add_edges(
|
45
|
+
[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],
|
46
|
+
[2,3],[2,4],[2,5],[2,6],
|
47
|
+
[3,3],[3,4],[3,5],[3,6],
|
48
|
+
[4,3],[4,4],[4,5],[4,6],
|
49
|
+
[5,3],[5,4],[5,5],[5,6],
|
50
|
+
[6,3],[6,4],[6,5],[6,6]
|
51
|
+
)
|
52
|
+
@dg_cyclic_tr = DirectedAdjacencyGraph.new
|
53
|
+
@dg_cyclic_tr.add_edges(
|
54
|
+
[1,1],[1,2],
|
55
|
+
[2,3],
|
56
|
+
[3,4],
|
57
|
+
[4,5],
|
58
|
+
[5,6],
|
59
|
+
[6,3]
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_transitive_closure
|
64
|
+
# A simple graph without cycles.
|
65
|
+
assert_equal(@dg_tc, @dg.transitive_closure)
|
66
|
+
|
67
|
+
# Iterative applications of transitive closure should return the same result
|
68
|
+
# as a single application.
|
69
|
+
assert_equal(
|
70
|
+
@dg.transitive_closure,
|
71
|
+
@dg.transitive_closure.transitive_closure
|
72
|
+
)
|
73
|
+
|
74
|
+
# Compute for a graph containing vertices without edges.
|
75
|
+
assert_equal(@dg_loner_tc, @dg_loner.transitive_closure)
|
76
|
+
|
77
|
+
# Iterative applications of transitive closure should return the same result
|
78
|
+
# as a single application.
|
79
|
+
assert_equal(
|
80
|
+
@dg_loner.transitive_closure,
|
81
|
+
@dg_loner.transitive_closure.transitive_closure
|
82
|
+
)
|
83
|
+
|
84
|
+
# Compute for a graph with cycles.
|
85
|
+
assert_equal(@dg_cyclic_tc, @dg_cyclic.transitive_closure)
|
86
|
+
|
87
|
+
# Iterative applications of transitive closure should return the same result
|
88
|
+
# as a single application.
|
89
|
+
assert_equal(
|
90
|
+
@dg_cyclic.transitive_closure,
|
91
|
+
@dg_cyclic.transitive_closure.transitive_closure
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_transitive_closure_undirected
|
96
|
+
assert_raises(NotDirectedError) {AdjacencyGraph.new.transitive_closure}
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_transitive_reduction
|
100
|
+
# A simple graph without cycles.
|
101
|
+
assert_equal(@dg_tr, @dg.transitive_reduction)
|
102
|
+
|
103
|
+
# Compute for a graph containing vertices without edges.
|
104
|
+
assert_equal(@dg_loner_tr, @dg_loner.transitive_reduction)
|
105
|
+
|
106
|
+
# Compute for a graph with cycles.
|
107
|
+
assert_equal(@dg_cyclic_tr, @dg_cyclic.transitive_reduction)
|
108
|
+
|
109
|
+
# Test that the transitive closure of a transitive reduction is the same as
|
110
|
+
# the transitive closure of the original graph.
|
111
|
+
assert_equal(
|
112
|
+
@dg.transitive_closure,
|
113
|
+
@dg.transitive_reduction.transitive_closure
|
114
|
+
)
|
115
|
+
assert_equal(
|
116
|
+
@dg_loner.transitive_closure,
|
117
|
+
@dg_loner.transitive_reduction.transitive_closure
|
118
|
+
)
|
119
|
+
assert_equal(
|
120
|
+
@dg_cyclic.transitive_closure,
|
121
|
+
@dg_cyclic.transitive_reduction.transitive_closure
|
122
|
+
)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_transitive_reduction_undirected
|
126
|
+
assert_raises(NotDirectedError) {AdjacencyGraph.new.transitive_reduction}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
metadata
CHANGED
@@ -1,173 +1,184 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: rgl
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2008-03-08 00:00:00 +01:00
|
8
|
-
summary: Ruby Graph Library
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: monora@gmail.com
|
12
|
-
homepage: http://rgl.rubyforge.org
|
13
|
-
rubyforge_project: rgl
|
14
|
-
description: "RGL is a framework for graph data structures and algorithms. The design of the library is much influenced by the Boost Graph Library (BGL) which is written in C++ heavily using its template mechanism. RGL currently contains a core set of algorithm patterns: * Breadth First Search * Depth First Search The algorithm patterns by themselves do not compute any meaningful quantities over graphs, they are merely building blocks for constructing graph algorithms. The graph algorithms in RGL currently include: * Topological Sort * Connected Components * Strongly Connected Components * Transitive Closure * Search cycles (contributed by Shawn Garbett)"
|
15
|
-
autorequire: rgl/base
|
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.4.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Horst Duchene
|
8
|
+
autorequire: rgl/base
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-27 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: stream
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0.5"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: "RGL is a framework for graph data structures and algorithms. The design of the library is much influenced by the Boost Graph Library (BGL) which is written in C++ heavily using its template mechanism. RGL currently contains a core set of algorithm patterns: * Breadth First Search * Depth First Search The algorithm patterns by themselves do not compute any meaningful quantities over graphs, they are merely building blocks for constructing graph algorithms. The graph algorithms in RGL currently include: * Topological Sort * Connected Components * Strongly Connected Components * Transitive Closure * Transitive Reduction * Graph Condensation * Search cycles (contributed by Shawn Garbett)"
|
36
|
+
email: monora@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
31
43
|
files:
|
32
44
|
- install.rb
|
45
|
+
- Rakefile
|
33
46
|
- ChangeLog
|
34
47
|
- README
|
35
|
-
- Rakefile
|
36
|
-
- tests/TestTransitiveClosure.rb
|
37
|
-
- tests/TestComponents.rb
|
38
|
-
- tests/TestCycles.rb
|
39
|
-
- tests/TestDirectedGraph.rb
|
40
|
-
- tests/TestEdge.rb
|
41
48
|
- tests/TestGraph.rb
|
42
|
-
- tests/TestGraphXML.rb
|
43
|
-
- tests/TestImplicit.rb
|
44
49
|
- tests/TestUnDirectedGraph.rb
|
50
|
+
- tests/TestTransitivity.rb
|
45
51
|
- tests/TestTraversal.rb
|
46
|
-
- tests/test_helper.rb
|
47
52
|
- tests/TestDot.rb
|
53
|
+
- tests/TestEdge.rb
|
54
|
+
- tests/TestDirectedGraph.rb
|
48
55
|
- tests/TestRdot.rb
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
56
|
+
- tests/TestCycles.rb
|
57
|
+
- tests/TestImplicit.rb
|
58
|
+
- tests/test_helper.rb
|
59
|
+
- tests/TestGraphXML.rb
|
60
|
+
- tests/TestComponents.rb
|
52
61
|
- examples/insel-der-tausend-gefahren.rb
|
62
|
+
- examples/canvas.rb
|
63
|
+
- examples/north.rb
|
64
|
+
- examples/north2.rb
|
53
65
|
- examples/example.jpg
|
66
|
+
- examples/module_graph.jpg
|
54
67
|
- examples/examples.rb
|
55
|
-
- examples/north2.rb
|
56
|
-
- examples/north.rb
|
57
68
|
- examples/rdep-rgl.rb
|
69
|
+
- examples/north
|
70
|
+
- examples/north/g.10.75.graphml
|
58
71
|
- examples/north/g.10.0.graphml
|
59
|
-
- examples/north/
|
60
|
-
- examples/north/g.10.
|
61
|
-
- examples/north/g.10.
|
62
|
-
- examples/north/g.10.
|
63
|
-
- examples/north/g.10.
|
64
|
-
- examples/north/g.10.
|
65
|
-
- examples/north/g.10.
|
66
|
-
- examples/north/g.10.16.graphml
|
67
|
-
- examples/north/g.10.17.graphml
|
72
|
+
- examples/north/g.10.41.graphml
|
73
|
+
- examples/north/g.10.93.graphml
|
74
|
+
- examples/north/g.10.7.graphml
|
75
|
+
- examples/north/g.10.30.graphml
|
76
|
+
- examples/north/g.10.20.graphml
|
77
|
+
- examples/north/g.10.89.graphml
|
78
|
+
- examples/north/g.10.78.graphml
|
68
79
|
- examples/north/g.10.19.graphml
|
80
|
+
- examples/north/g.10.86.graphml
|
81
|
+
- examples/north/g.10.92.graphml
|
82
|
+
- examples/north/g.10.38.graphml
|
83
|
+
- examples/north/g.10.14.graphml
|
69
84
|
- examples/north/g.10.2.graphml
|
70
|
-
- examples/north/g.10.
|
71
|
-
- examples/north/g.10.
|
85
|
+
- examples/north/g.10.46.graphml
|
86
|
+
- examples/north/g.10.72.graphml
|
72
87
|
- examples/north/g.10.24.graphml
|
73
|
-
- examples/north/g.10.
|
88
|
+
- examples/north/g.10.45.graphml
|
89
|
+
- examples/north/g.10.88.graphml
|
90
|
+
- examples/north/g.10.82.graphml
|
74
91
|
- examples/north/g.10.27.graphml
|
75
|
-
- examples/north/g.10.28.graphml
|
76
|
-
- examples/north/g.10.29.graphml
|
77
|
-
- examples/north/g.10.3.graphml
|
78
|
-
- examples/north/g.10.30.graphml
|
79
92
|
- examples/north/g.10.31.graphml
|
80
|
-
- examples/north/g.10.
|
81
|
-
- examples/north/g.10.
|
82
|
-
- examples/north/g.10.
|
83
|
-
- examples/north/g.10.39.graphml
|
84
|
-
- examples/north/g.10.4.graphml
|
85
|
-
- examples/north/g.10.40.graphml
|
86
|
-
- examples/north/g.10.41.graphml
|
87
|
-
- examples/north/g.10.42.graphml
|
88
|
-
- examples/north/g.10.45.graphml
|
89
|
-
- examples/north/g.10.46.graphml
|
90
|
-
- examples/north/g.10.5.graphml
|
93
|
+
- examples/north/g.10.1.graphml
|
94
|
+
- examples/north/g.10.25.graphml
|
95
|
+
- examples/north/g.10.71.graphml
|
91
96
|
- examples/north/g.10.50.graphml
|
92
|
-
- examples/north/g.
|
93
|
-
- examples/north/g.10.
|
94
|
-
- examples/north/g.10.58.graphml
|
95
|
-
- examples/north/g.10.6.graphml
|
96
|
-
- examples/north/g.10.60.graphml
|
97
|
-
- examples/north/g.10.61.graphml
|
98
|
-
- examples/north/g.10.62.graphml
|
99
|
-
- examples/north/g.10.68.graphml
|
97
|
+
- examples/north/g.12.8.graphml
|
98
|
+
- examples/north/g.10.91.graphml
|
100
99
|
- examples/north/g.10.69.graphml
|
101
|
-
- examples/north/g.10.
|
102
|
-
- examples/north/g.
|
103
|
-
- examples/north/g.10.
|
104
|
-
- examples/north/g.10.72.graphml
|
105
|
-
- examples/north/g.10.74.graphml
|
106
|
-
- examples/north/g.10.75.graphml
|
107
|
-
- examples/north/g.10.78.graphml
|
100
|
+
- examples/north/g.10.13.graphml
|
101
|
+
- examples/north/g.14.9.graphml
|
102
|
+
- examples/north/g.10.42.graphml
|
108
103
|
- examples/north/g.10.79.graphml
|
109
|
-
- examples/north/g.10.
|
104
|
+
- examples/north/g.10.39.graphml
|
105
|
+
- examples/north/g.10.16.graphml
|
106
|
+
- examples/north/Graph.log
|
107
|
+
- examples/north/g.10.94.graphml
|
108
|
+
- examples/north/g.10.68.graphml
|
110
109
|
- examples/north/g.10.80.graphml
|
111
|
-
- examples/north/g.10.
|
110
|
+
- examples/north/g.10.37.graphml
|
111
|
+
- examples/north/g.10.61.graphml
|
112
112
|
- examples/north/g.10.83.graphml
|
113
|
-
- examples/north/g.10.
|
114
|
-
- examples/north/g.10.
|
115
|
-
- examples/north/g.10.
|
116
|
-
- examples/north/g.10.
|
117
|
-
- examples/north/g.10.9.graphml
|
113
|
+
- examples/north/g.10.5.graphml
|
114
|
+
- examples/north/g.10.11.graphml
|
115
|
+
- examples/north/g.10.40.graphml
|
116
|
+
- examples/north/g.10.4.graphml
|
118
117
|
- examples/north/g.10.90.graphml
|
119
|
-
- examples/north/g.10.
|
120
|
-
- examples/north/g.10.
|
121
|
-
- examples/north/g.10.
|
122
|
-
- examples/north/g.10.
|
123
|
-
- examples/north/g.
|
124
|
-
- examples/north/g.
|
118
|
+
- examples/north/g.10.58.graphml
|
119
|
+
- examples/north/g.10.15.graphml
|
120
|
+
- examples/north/g.10.8.graphml
|
121
|
+
- examples/north/g.10.6.graphml
|
122
|
+
- examples/north/g.10.22.graphml
|
123
|
+
- examples/north/g.10.9.graphml
|
124
|
+
- examples/north/g.10.57.graphml
|
125
|
+
- examples/north/g.10.29.graphml
|
126
|
+
- examples/north/g.10.85.graphml
|
127
|
+
- examples/north/g.10.70.graphml
|
128
|
+
- examples/north/g.10.62.graphml
|
129
|
+
- examples/north/g.10.17.graphml
|
130
|
+
- examples/north/g.10.34.graphml
|
131
|
+
- examples/north/g.10.56.graphml
|
132
|
+
- examples/north/g.10.12.graphml
|
133
|
+
- examples/north/g.10.74.graphml
|
134
|
+
- examples/north/g.10.28.graphml
|
135
|
+
- examples/north/g.10.60.graphml
|
136
|
+
- examples/north/g.10.3.graphml
|
125
137
|
- rakelib/dep_graph.rake
|
126
|
-
- lib/rgl/
|
127
|
-
- lib/rgl/
|
128
|
-
- lib/rgl/base.rb
|
138
|
+
- lib/rgl/enumerable_ext.rb
|
139
|
+
- lib/rgl/transitiv_closure.rb
|
129
140
|
- lib/rgl/graphxml.rb
|
130
|
-
- lib/rgl/
|
141
|
+
- lib/rgl/condensation.rb
|
131
142
|
- lib/rgl/connected_components.rb
|
143
|
+
- lib/rgl/adjacency.rb
|
144
|
+
- lib/rgl/dot.rb
|
145
|
+
- lib/rgl/base.rb
|
132
146
|
- lib/rgl/rdot.rb
|
133
|
-
- lib/rgl/enumerable_ext.rb
|
134
|
-
- lib/rgl/implicit.rb
|
135
147
|
- lib/rgl/mutable.rb
|
148
|
+
- lib/rgl/bidirectional.rb
|
149
|
+
- lib/rgl/transitivity.rb
|
136
150
|
- lib/rgl/topsort.rb
|
137
|
-
- lib/rgl/transitiv_closure.rb
|
138
151
|
- lib/rgl/traversal.rb
|
139
|
-
|
140
|
-
|
152
|
+
- lib/rgl/implicit.rb
|
153
|
+
has_rdoc: true
|
154
|
+
homepage: http://rgl.rubyforge.org
|
155
|
+
post_install_message:
|
141
156
|
rdoc_options:
|
142
157
|
- --title
|
143
158
|
- RGL - Ruby Graph Library
|
144
159
|
- --main
|
145
160
|
- README
|
146
161
|
- --line-numbers
|
147
|
-
|
148
|
-
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: "0"
|
169
|
+
version:
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: "0"
|
175
|
+
version:
|
153
176
|
requirements:
|
154
177
|
- Stream library, v0.5 or later
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
- !ruby/object:Gem::Version
|
163
|
-
version: "0.5"
|
164
|
-
version:
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: rake
|
167
|
-
version_requirement:
|
168
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
169
|
-
requirements:
|
170
|
-
- - ">"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: 0.0.0
|
173
|
-
version:
|
178
|
+
rubyforge_project: rgl
|
179
|
+
rubygems_version: 1.2.0
|
180
|
+
signing_key:
|
181
|
+
specification_version: 2
|
182
|
+
summary: Ruby Graph Library
|
183
|
+
test_files: []
|
184
|
+
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rgl/transitiv_closure'
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
include RGL
|
6
|
-
|
7
|
-
class TestTransitiveClosure < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@dg = DirectedAdjacencyGraph.new(Array)
|
11
|
-
edges = [[1,2],[2,3],[2,4],[4,5],[1,6],[6,4]]
|
12
|
-
edges.each do |(src,target)|
|
13
|
-
@dg.add_edge(src, target)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_transitive_closure
|
18
|
-
assert_equal("(1-2)(1-3)(1-4)(1-6)(2-3)(2-4)(2-5)(4-5)(6-4)(6-5)",
|
19
|
-
@dg.transitive_closure.to_s)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_transitive_closure_undirected
|
23
|
-
assert_raises(NotDirectedError) {AdjacencyGraph.new.transitive_closure}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|