jumoku 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +12 -12
- data/lib/jumoku.rb +2 -2
- data/lib/jumoku/builders/raw_tree.rb +4 -4
- data/lib/jumoku/builders/tree.rb +5 -5
- data/lib/jumoku/support/branch.rb +1 -1
- data/lib/jumoku/tree_api.rb +1 -1
- data/lib/jumoku/version.rb +1 -1
- data/spec/raw_tree_spec.rb +1 -1
- data/vendor/git/{graphy → plexus}/CREDITS.md +0 -0
- data/vendor/git/plexus/Gemfile +3 -0
- data/vendor/git/plexus/Gemfile.lock +28 -0
- data/vendor/git/{graphy → plexus}/LICENSE +3 -1
- data/vendor/git/plexus/README.md +208 -0
- data/vendor/git/plexus/Rakefile +25 -0
- data/vendor/git/{graphy → plexus}/TODO.md +1 -1
- data/vendor/git/{graphy → plexus}/VERSION +0 -0
- data/vendor/git/{graphy → plexus}/examples/graph_self.rb +0 -0
- data/vendor/git/{graphy → plexus}/examples/module_graph.jpg +0 -0
- data/vendor/git/{graphy → plexus}/examples/module_graph.rb +0 -0
- data/vendor/git/{graphy → plexus}/examples/self_graph.jpg +0 -0
- data/vendor/git/{graphy → plexus}/examples/visualize.jpg +0 -0
- data/vendor/git/{graphy → plexus}/examples/visualize.rb +0 -0
- data/vendor/git/plexus/lib/plexus.rb +90 -0
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/adjacency_graph.rb +9 -9
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/arc.rb +16 -22
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/arc_number.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/biconnected.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/chinese_postman.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/classes/graph_classes.rb +10 -10
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/common.rb +6 -6
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/comparability.rb +10 -10
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/directed_graph.rb +15 -13
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/directed_graph/algorithms.rb +21 -18
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/directed_graph/distance.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/dot.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/edge.rb +8 -9
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/ext.rb +3 -3
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/graph.rb +51 -56
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/graph_api.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/labels.rb +8 -8
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/maximum_flow.rb +2 -2
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/ruby_compatibility.rb +0 -0
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/search.rb +43 -44
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/strong_components.rb +4 -4
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/support/support.rb +3 -3
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/undirected_graph.rb +13 -14
- data/vendor/git/{graphy/lib/graphy → plexus/lib/plexus}/undirected_graph/algorithms.rb +4 -4
- data/vendor/git/plexus/lib/plexus/version.rb +6 -0
- data/vendor/git/plexus/plexus.gemspec +24 -0
- data/vendor/git/{graphy → plexus}/spec/biconnected_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/chinese_postman_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/community_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/complement_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/digraph_distance_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/digraph_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/dot_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/edge_spec.rb +17 -18
- data/vendor/git/{graphy → plexus}/spec/inspection_spec.rb +13 -15
- data/vendor/git/{graphy → plexus}/spec/multi_edge_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/neighborhood_spec.rb +3 -5
- data/vendor/git/{graphy → plexus}/spec/properties_spec.rb +1 -1
- data/vendor/git/{graphy → plexus}/spec/search_spec.rb +45 -45
- data/vendor/git/{graphy → plexus}/spec/spec.opts +0 -0
- data/vendor/git/{graphy → plexus}/spec/spec_helper.rb +13 -10
- data/vendor/git/{graphy → plexus}/spec/strong_components_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/spec/triangulated_spec.rb +1 -1
- data/vendor/git/{graphy → plexus}/spec/undirected_graph_spec.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/CHANGELOG +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/Makefile +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/README +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/benchmark/dijkstra.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/compare_comments.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/doc/c-vs-rb.png +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/doc/compare_big.gp +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/doc/compare_big.png +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/doc/compare_small.gp +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/doc/compare_small.png +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/doc/results.csv +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/ext/priority_queue/CPriorityQueue/extconf.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/ext/priority_queue/CPriorityQueue/priority_queue.c +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/lib/priority_queue.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/lib/priority_queue/c_priority_queue.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/lib/priority_queue/poor_priority_queue.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/lib/priority_queue/ruby_priority_queue.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/priority_queue.so +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/setup.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/priority-queue/test/priority_queue_test.rb +0 -0
- data/vendor/git/{graphy → plexus}/vendor/rdot.rb +0 -0
- metadata +81 -78
- data/vendor/git/graphy/README.md +0 -186
- data/vendor/git/graphy/Rakefile +0 -61
- data/vendor/git/graphy/graphy.gemspec +0 -149
- data/vendor/git/graphy/lib/graphy.rb +0 -90
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require './lib/plexus/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = %q{plexus}
|
6
|
+
s.version = Plexus::VERSION
|
7
|
+
s.authors = ["Bruce Williams", "Jean-Denis Vauguet <jd@vauguet.fr>"]
|
8
|
+
s.summary = "A framework for graph data structures and algorithms."
|
9
|
+
s.description = %q{This library is based on GRATR and RGL.
|
10
|
+
|
11
|
+
Graph algorithms currently provided are:
|
12
|
+
|
13
|
+
* Topological Sort
|
14
|
+
* Strongly Connected Components
|
15
|
+
* Transitive Closure
|
16
|
+
* Rural Chinese Postman
|
17
|
+
* Biconnected
|
18
|
+
}
|
19
|
+
s.email = %q{bruce@codefluency.com}
|
20
|
+
s.add_dependency "facets"
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
s.add_development_dependency "yard"
|
23
|
+
end
|
24
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,13 +1,12 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe "Arc" do # :nodoc:
|
1
|
+
require 'spec_helper'
|
4
2
|
|
3
|
+
describe Arc do
|
5
4
|
before do
|
6
5
|
@e = Arc.new(1,2,'boo')
|
7
6
|
@u = Edge.new(1,2,'hoo')
|
8
7
|
end
|
9
8
|
|
10
|
-
describe "edge_new" do
|
9
|
+
describe "#edge_new" do
|
11
10
|
it do
|
12
11
|
proc { Arc.new }.should raise_error(ArgumentError)
|
13
12
|
proc { Arc.new(1) }.should raise_error(ArgumentError)
|
@@ -16,7 +15,7 @@ describe "Arc" do # :nodoc:
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
describe "edge_getters" do
|
18
|
+
describe "#edge_getters" do
|
20
19
|
it do
|
21
20
|
@e.source.should == 1
|
22
21
|
@e.target.should == 2
|
@@ -25,14 +24,14 @@ describe "Arc" do # :nodoc:
|
|
25
24
|
@e[0].should == 1
|
26
25
|
@e[1].should == 2
|
27
26
|
@e[2].should == 'boo'
|
28
|
-
|
27
|
+
|
29
28
|
@e[-3].should == 1
|
30
29
|
@e[-2].should == 2
|
31
30
|
@e[-1].should == 'boo'
|
32
31
|
|
33
|
-
proc { @e[-4] }.should raise_error(IndexError)
|
34
|
-
proc { @e[3] }.should raise_error(IndexError)
|
35
|
-
|
32
|
+
proc { @e[-4] }.should raise_error(IndexError)
|
33
|
+
proc { @e[3] }.should raise_error(IndexError)
|
34
|
+
|
36
35
|
@e['source'].should == 1
|
37
36
|
@e['target'].should == 2
|
38
37
|
@e['label'].should == 'boo'
|
@@ -43,7 +42,7 @@ describe "Arc" do # :nodoc:
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
describe "edge_setters" do
|
45
|
+
describe "#edge_setters" do
|
47
46
|
it do
|
48
47
|
@e.source = 23
|
49
48
|
@e.target = 42
|
@@ -82,7 +81,7 @@ describe "Arc" do # :nodoc:
|
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
85
|
-
describe "edge_simple_methods" do
|
84
|
+
describe "#edge_simple_methods" do
|
86
85
|
it do
|
87
86
|
@e.to_a.should == [1,2,'boo']
|
88
87
|
@e.to_s.should == "(1-2 'boo')"
|
@@ -99,14 +98,14 @@ describe "Arc" do # :nodoc:
|
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
102
|
-
describe "edge_sort" do
|
101
|
+
describe "#edge_sort" do
|
103
102
|
it do
|
104
103
|
x = [ Arc.new(2,3), Arc.new(1,3), Arc.new(1,2), Arc.new(2,1) ].sort
|
105
104
|
x.should == [Arc.new(1,2), Arc.new(1,3), Arc.new(2,1), Arc.new(2,3)]
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
109
|
-
describe "undirected_edge_new" do
|
108
|
+
describe "#undirected_edge_new" do
|
110
109
|
it do
|
111
110
|
proc { Edge.new }.should raise_error(ArgumentError)
|
112
111
|
proc { Edge.new(1) }.should raise_error(ArgumentError)
|
@@ -115,7 +114,7 @@ describe "Arc" do # :nodoc:
|
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
118
|
-
describe "undirected_edge_getters" do
|
117
|
+
describe "#undirected_edge_getters" do
|
119
118
|
it do
|
120
119
|
@u.source.should == 1
|
121
120
|
@u.target.should == 2
|
@@ -124,7 +123,7 @@ describe "Arc" do # :nodoc:
|
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
|
-
describe "undirected_edge_methods" do
|
126
|
+
describe "#undirected_edge_methods" do
|
128
127
|
it do
|
129
128
|
@u.label = nil
|
130
129
|
@u.to_s.should == "(1=2)"
|
@@ -138,14 +137,14 @@ describe "Arc" do # :nodoc:
|
|
138
137
|
end
|
139
138
|
end
|
140
139
|
|
141
|
-
describe "undirected_edge_sort" do
|
140
|
+
describe "#undirected_edge_sort" do
|
142
141
|
it do
|
143
142
|
x = [Edge.new(12, 1), Edge.new(2,11)].sort
|
144
143
|
x.should == [Edge.new(2,11), Edge.new(1,12)]
|
145
144
|
end
|
146
145
|
end
|
147
|
-
|
148
|
-
describe "hash" do
|
146
|
+
|
147
|
+
describe "#hash" do
|
149
148
|
it do
|
150
149
|
Arc[1,2,:c].should == Arc[1,2,:b]
|
151
150
|
Arc[1,2,:c].hash.should == Arc[1,2,:b].hash
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Inspection" do # :nodoc:
|
4
|
-
|
5
4
|
before do
|
6
|
-
@dg = DirectedMultiGraph[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
@dg = DirectedMultiGraph[
|
6
|
+
[0,0,1] => 1,
|
7
|
+
[1,2,2] => 2,
|
8
|
+
[1,3,3] => 4,
|
9
|
+
[1,4,4] => nil,
|
10
|
+
[4,1,5] => 8,
|
11
|
+
[1,2,6] => 16,
|
12
|
+
[3,3,7] => 32,
|
13
|
+
[3,3,8] => 64
|
14
|
+
]
|
15
15
|
@dg[3] = 128
|
16
16
|
@dg[0] = 256
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
describe "inspection_without_labels" do
|
20
20
|
it do
|
21
21
|
@dg = Digraph[1,2,3,4,5,6]
|
@@ -23,7 +23,7 @@ describe "Inspection" do # :nodoc:
|
|
23
23
|
reflect.should == @dg
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
describe "inspection_with_labels" do
|
28
28
|
it do
|
29
29
|
inspect = @dg.inspect
|
@@ -34,7 +34,5 @@ describe "Inspection" do # :nodoc:
|
|
34
34
|
reflect.edges.inject(0) { |a,e| a += (reflect[e] || 0)}.should == 127
|
35
35
|
reflect.vertices.inject(0) {|a,v| a += (reflect[v] || 0)}.should == 384
|
36
36
|
end
|
37
|
-
|
38
37
|
end
|
39
|
-
|
40
38
|
end
|
File without changes
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
2
|
|
3
|
-
describe "Neighborhood" do
|
4
|
-
|
3
|
+
describe "Neighborhood" do
|
5
4
|
before do
|
6
5
|
@d = Digraph[:a,:b, :a,:f,
|
7
6
|
:b,:g,
|
@@ -12,7 +11,7 @@ describe "Neighborhood" do # :nodoc:
|
|
12
11
|
:g,:a, :g,:e]
|
13
12
|
@w = [:a,:b]
|
14
13
|
end
|
15
|
-
|
14
|
+
|
16
15
|
describe "open_out_neighborhood" do
|
17
16
|
it do
|
18
17
|
@d.set_neighborhood([:a], :in).should == [:g]
|
@@ -24,7 +23,7 @@ describe "Neighborhood" do # :nodoc:
|
|
24
23
|
([:c] - @d.open_pth_neighborhood(@w, 4, :out)).should == []
|
25
24
|
end
|
26
25
|
end
|
27
|
-
|
26
|
+
|
28
27
|
describe "closed_out_neighborhood" do
|
29
28
|
it do
|
30
29
|
(@w - @d.closed_pth_neighborhood(@w, 0, :out)).should == []
|
@@ -34,5 +33,4 @@ describe "Neighborhood" do # :nodoc:
|
|
34
33
|
([:a,:b,:c,:d,:e,:f,:g] - @d.closed_pth_neighborhood(@w, 4, :out)).should == []
|
35
34
|
end
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
@@ -9,14 +9,14 @@ describe "Search" do # :nodoc:
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# "Algorithmic Graph Theory and Perfect Graphs", Martin Charles
|
12
|
-
# Golumbic, 1980, Academic Press, page 39, Propery (D1) and (D2) of
|
12
|
+
# Golumbic, 1980, Academic Press, page 39, Propery (D1) and (D2) of
|
13
13
|
# depth first search
|
14
14
|
describe "dfs_properties" do
|
15
15
|
it do
|
16
16
|
dfs = {}
|
17
17
|
father = {}
|
18
18
|
@directed.each do |vertex|
|
19
|
-
assign_dfsnumber_ancestry(@directed, dfs, father, vertex)
|
19
|
+
assign_dfsnumber_ancestry(@directed, dfs, father, vertex)
|
20
20
|
# Property (D1)
|
21
21
|
father.keys.each {|v| dfs[father[v]].should be < dfs[v] }
|
22
22
|
# Property (D2)
|
@@ -30,15 +30,15 @@ describe "Search" do # :nodoc:
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# "Algorithmic Graph Theory and Perfect Graphs", Martin Charles
|
33
|
-
# Golumbic, 1980, Academic Press, page 40, Propery (B1), (B2) and (B3) of
|
33
|
+
# Golumbic, 1980, Academic Press, page 40, Propery (B1), (B2) and (B3) of
|
34
34
|
# breadth first search
|
35
35
|
describe "bfs_properties" do
|
36
36
|
it do
|
37
|
-
level = {}
|
37
|
+
level = {}
|
38
38
|
father = {}
|
39
39
|
bfs = {}
|
40
40
|
@directed.each do |vertex|
|
41
|
-
assign_bfsnumber_ancestry(@directed, bfs, level, father, vertex)
|
41
|
+
assign_bfsnumber_ancestry(@directed, bfs, level, father, vertex)
|
42
42
|
# Property (B1)
|
43
43
|
father.keys.each do |v|
|
44
44
|
bfs[father[v]].should be < bfs[v]
|
@@ -107,7 +107,7 @@ describe "Search" do # :nodoc:
|
|
107
107
|
|
108
108
|
# Heuristic from "Artificial Intelligence: A Modern Approach" by Stuart
|
109
109
|
# Russell ande Peter Norvig, Prentice-Hall 2nd Edition, pg 95
|
110
|
-
straight_line_to_Bucharest =
|
110
|
+
straight_line_to_Bucharest =
|
111
111
|
{
|
112
112
|
'Arad' => 366,
|
113
113
|
'Bucharest' => 0,
|
@@ -142,57 +142,57 @@ describe "Search" do # :nodoc:
|
|
142
142
|
fv = Proc.new {|v| list << "fv #{v}" }
|
143
143
|
er = Proc.new {|e| list << "er #{e}" }
|
144
144
|
enr = Proc.new {|e| list << "enr #{e}" }
|
145
|
-
|
145
|
+
|
146
146
|
options = { :discover_vertex => dv,
|
147
147
|
:examine_vertex => ev,
|
148
148
|
:black_target => bt,
|
149
149
|
:finish_vertex => fv,
|
150
150
|
:edge_relaxed => er,
|
151
151
|
:edge_not_relaxed => enr }
|
152
|
-
|
152
|
+
|
153
153
|
result = romania.astar('Arad', 'Bucharest', h, options)
|
154
154
|
|
155
155
|
result.should == ["Arad", "Sibiu", "Rimnicu Vilcea", "Pitesti", "Bucharest"]
|
156
156
|
# This isn't the greatest test since the exact ordering is not
|
157
157
|
# not specified by the algorithm. If someone has a better idea, please fix
|
158
158
|
list.should == ["ev Arad",
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
159
|
+
"er (Arad=Sibiu '99')",
|
160
|
+
"dv Sibiu",
|
161
|
+
"er (Arad=Timisoara '138')",
|
162
|
+
"dv Timisoara",
|
163
|
+
"er (Arad=Zerind '75')",
|
164
|
+
"dv Zerind",
|
165
|
+
"fv Arad",
|
166
|
+
"ev Sibiu",
|
167
|
+
"er (Rimnicu Vilcea=Sibiu '80')",
|
168
|
+
"dv Rimnicu Vilcea",
|
169
|
+
"er (Fagaras=Sibiu '99')",
|
170
|
+
"dv Fagaras",
|
171
|
+
"er (Oradea=Sibiu '151')",
|
172
|
+
"dv Oradea",
|
173
|
+
"enr (Arad=Sibiu '99')",
|
174
|
+
"fv Sibiu",
|
175
|
+
"ev Rimnicu Vilcea",
|
176
|
+
"enr (Rimnicu Vilcea=Sibiu '80')",
|
177
|
+
"er (Craiova=Rimnicu Vilcea '146')",
|
178
|
+
"dv Craiova",
|
179
|
+
"er (Pitesti=Rimnicu Vilcea '97')",
|
180
|
+
"dv Pitesti",
|
181
|
+
"fv Rimnicu Vilcea",
|
182
|
+
"ev Fagaras",
|
183
|
+
"enr (Fagaras=Sibiu '99')",
|
184
|
+
"er (Bucharest=Fagaras '211')",
|
185
|
+
"dv Bucharest",
|
186
|
+
"fv Fagaras",
|
187
|
+
"ev Pitesti",
|
188
|
+
"enr (Pitesti=Rimnicu Vilcea '97')",
|
189
|
+
"er (Bucharest=Pitesti '101')",
|
190
|
+
"enr (Craiova=Pitesti '138')",
|
191
|
+
"fv Pitesti",
|
192
|
+
"ev Bucharest"]
|
193
193
|
end
|
194
194
|
end
|
195
|
-
|
195
|
+
|
196
196
|
describe "bfs_spanning_forest" do
|
197
197
|
it do
|
198
198
|
predecessor, roots = @tree.bfs_spanning_forest(1)
|
@@ -203,7 +203,7 @@ describe "Search" do # :nodoc:
|
|
203
203
|
roots.sort.should == [1,3,5,6,23]
|
204
204
|
end
|
205
205
|
end
|
206
|
-
|
206
|
+
|
207
207
|
describe "dfs_spanning_forest" do
|
208
208
|
it do
|
209
209
|
predecessor, roots = @tree.dfs_spanning_forest(1)
|
@@ -214,7 +214,7 @@ describe "Search" do # :nodoc:
|
|
214
214
|
roots.sort.should == [1,3,5,6,23]
|
215
215
|
end
|
216
216
|
end
|
217
|
-
|
217
|
+
|
218
218
|
describe "tree_from_vertex" do
|
219
219
|
it do
|
220
220
|
@tree.bfs_tree_from_vertex(1).should == {5=>2, 6=>2, 7=>6, 2=>1, 3=>1, 4=>1}
|
File without changes
|
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'graphy'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
1
|
+
require File.expand_path("../../lib/plexus.rb", __FILE__)
|
6
2
|
|
7
|
-
|
3
|
+
require 'plexus'
|
4
|
+
include Plexus
|
8
5
|
|
9
6
|
module AncestryHelper
|
10
|
-
|
11
7
|
# "Algorithmic Graph Theory and Perfect Graphs", Martin Charles
|
12
8
|
# Golumbic, 1980, Academic Press, page 38, Figure 2.6
|
13
9
|
def assign_dfsnumber_ancestry(graph, dfsnumber, father, start)
|
@@ -20,7 +16,7 @@ module AncestryHelper
|
|
20
16
|
end
|
21
17
|
|
22
18
|
# "Algorithmic Graph Theory and Perfect Graphs", Martin Charles
|
23
|
-
# Golumbic, 1980, Academic Press, page 40, Figure 2.7
|
19
|
+
# Golumbic, 1980, Academic Press, page 40, Figure 2.7
|
24
20
|
def assign_bfsnumber_ancestry(graph, bfsnum, level, father, start)
|
25
21
|
i = 0
|
26
22
|
bfsnum.clear
|
@@ -29,7 +25,7 @@ module AncestryHelper
|
|
29
25
|
rt = Proc.new {|v| level[v] = 0 }
|
30
26
|
ev = Proc.new {|v| bfsnum[v]=(i+=1);level[v]=(level[father[v]]+1) if father[v]}
|
31
27
|
te = Proc.new {|e| father[e.target] = e.source }
|
32
|
-
graph.dfs({:enter_vertex => ev, :tree_edge => te,
|
28
|
+
graph.dfs({:enter_vertex => ev, :tree_edge => te,
|
33
29
|
:root_vertex => rt, :start => start})
|
34
30
|
end
|
35
31
|
|
@@ -51,6 +47,13 @@ module AncestryHelper
|
|
51
47
|
|
52
48
|
end
|
53
49
|
|
54
|
-
|
50
|
+
RSpec.configure do |config|
|
51
|
+
# Remove this line if you don't want RSpec's should and should_not
|
52
|
+
# methods or matchers
|
53
|
+
require 'rspec/expectations'
|
54
|
+
config.include RSpec::Matchers
|
55
55
|
config.include AncestryHelper
|
56
|
+
|
57
|
+
# == Mock Framework
|
58
|
+
config.mock_with :rspec
|
56
59
|
end
|