bribera-rubyvor 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/Manifest.txt +1 -0
- data/README.txt +32 -1
- data/ext/memory.c +5 -3
- data/ext/output.c +15 -19
- data/ext/rb_cComputation.c +145 -90
- data/ext/rb_cPoint.c +21 -0
- data/ext/rb_cPriorityQueue.c +3 -3
- data/ext/ruby_vor_c.c +20 -13
- data/ext/ruby_vor_c.h +10 -1
- data/ext/voronoi.c +24 -24
- data/lib/ruby_vor/computation.rb +35 -105
- data/lib/ruby_vor/point.rb +19 -4
- data/lib/ruby_vor/version.rb +1 -1
- data/lib/ruby_vor/visualizer.rb +217 -0
- data/lib/ruby_vor.rb +1 -0
- data/rubyvor.gemspec +4 -4
- data/test/test_computation.rb +42 -17
- metadata +4 -3
data/test/test_computation.rb
CHANGED
@@ -11,7 +11,7 @@ class TestComputation < MiniTest::Unit::TestCase
|
|
11
11
|
|
12
12
|
def test_nn_graph
|
13
13
|
comp = RubyVor::VDDT::Computation.from_points(sample_points)
|
14
|
-
|
14
|
+
|
15
15
|
# based on this expected delaunay trianglulation:
|
16
16
|
# 3 2 1
|
17
17
|
# 3 0 2
|
@@ -34,7 +34,8 @@ class TestComputation < MiniTest::Unit::TestCase
|
|
34
34
|
[4, 5, 6, 8], # 7
|
35
35
|
[0, 2, 3, 5, 6, 7], # 8
|
36
36
|
]
|
37
|
-
|
37
|
+
|
38
|
+
|
38
39
|
comp.nn_graph.each_with_index do |neighbors,i|
|
39
40
|
refute_empty neighbors, "@nn_graph returned empty neighbors for node #{i}"
|
40
41
|
end
|
@@ -56,7 +57,7 @@ class TestComputation < MiniTest::Unit::TestCase
|
|
56
57
|
[1,2]
|
57
58
|
]
|
58
59
|
computed_mst = comp.minimum_spanning_tree
|
59
|
-
|
60
|
+
|
60
61
|
# Assert nodes are correct
|
61
62
|
assert_equal expected_mst.sort, \
|
62
63
|
computed_mst.keys.sort
|
@@ -169,20 +170,43 @@ class TestComputation < MiniTest::Unit::TestCase
|
|
169
170
|
RubyVor::Point.new(4.0,10.0), # 12
|
170
171
|
])
|
171
172
|
comp.nn_graph.each_with_index do |neighbors,i|
|
172
|
-
refute_empty neighbors, "@nn_graph
|
173
|
+
refute_empty neighbors, "@nn_graph has empty neighbors for node #{i}"
|
173
174
|
end
|
174
|
-
|
175
|
+
|
176
|
+
=begin
|
175
177
|
assert_equal [[0], [1,2,3,4,5,6,7,8], [9,10,11,12]], \
|
176
|
-
comp.cluster_by_distance(1).map{|cl| cl.sort}.sort
|
178
|
+
comp.cluster_by_distance(1).map{|cl| cl.sort}.sort, \
|
179
|
+
"cluster by distance 1"
|
177
180
|
|
178
181
|
assert_equal [[0,1,2,3,4,5,6,7,8], [9,10,11,12]], \
|
179
|
-
comp.cluster_by_distance(5).map{|cl| cl.sort}.sort
|
182
|
+
comp.cluster_by_distance(5).map{|cl| cl.sort}.sort, \
|
183
|
+
"cluster by distance 5"
|
180
184
|
|
181
185
|
assert_equal [[0,1,2,3,4,5,6,7,8,9,10,11,12]], \
|
182
|
-
comp.cluster_by_distance(10).map{|cl| cl.sort}.sort
|
186
|
+
comp.cluster_by_distance(10).map{|cl| cl.sort}.sort, \
|
187
|
+
"cluster by distance 10"
|
183
188
|
|
184
189
|
assert_equal [[0,1,2,3,4,5,6,7,8], [9,10,11,12]], \
|
185
|
-
comp.cluster_by_size([2])[2].map{|cl| cl.sort}.sort
|
190
|
+
comp.cluster_by_size([2])[2].map{|cl| cl.sort}.sort, \
|
191
|
+
"cluster by size 2"
|
192
|
+
=end
|
193
|
+
|
194
|
+
assert_equal [[0], [1], [2]], \
|
195
|
+
comp.cluster_by_distance(1).map{|cl| cl.sort}.sort, \
|
196
|
+
"cluster by distance 1"
|
197
|
+
|
198
|
+
assert_equal [[0,1], [2]], \
|
199
|
+
comp.cluster_by_distance(5).map{|cl| cl.sort}.sort, \
|
200
|
+
"cluster by distance 5"
|
201
|
+
|
202
|
+
assert_equal [[0,1,2]], \
|
203
|
+
comp.cluster_by_distance(10).map{|cl| cl.sort}.sort, \
|
204
|
+
"cluster by distance 10"
|
205
|
+
|
206
|
+
assert_equal [[0,1], [2]], \
|
207
|
+
comp.cluster_by_size([2])[2].map{|cl| cl.sort}.sort, \
|
208
|
+
"cluster by size 2"
|
209
|
+
|
186
210
|
end
|
187
211
|
|
188
212
|
|
@@ -212,13 +236,13 @@ class TestComputation < MiniTest::Unit::TestCase
|
|
212
236
|
|
213
237
|
def test_cluster_by_size
|
214
238
|
comp = RubyVor::VDDT::Computation.from_points([
|
215
|
-
RubyVor::Point.new(0.25, 0.25),
|
216
|
-
RubyVor::Point.new(1, 0.25),
|
217
|
-
RubyVor::Point.new(0.5, 1),
|
218
|
-
RubyVor::Point.new(5, 5),
|
219
|
-
RubyVor::Point.new(10.25, 10.25),
|
220
|
-
RubyVor::Point.new(13, 9),
|
221
|
-
RubyVor::Point.new(9, 9)
|
239
|
+
RubyVor::Point.new(0.25, 0.25), # 0
|
240
|
+
RubyVor::Point.new(1, 0.25), # 1
|
241
|
+
RubyVor::Point.new(0.5, 1), # 2
|
242
|
+
RubyVor::Point.new(5, 5), # 3
|
243
|
+
RubyVor::Point.new(10.25, 10.25), # 4
|
244
|
+
RubyVor::Point.new(13, 9), # 5
|
245
|
+
RubyVor::Point.new(9, 9) # 6
|
222
246
|
])
|
223
247
|
|
224
248
|
sizes = [1, 3, 5, 7]
|
@@ -230,7 +254,8 @@ class TestComputation < MiniTest::Unit::TestCase
|
|
230
254
|
computed_sized_clusters.keys.sort
|
231
255
|
|
232
256
|
assert_equal [[0,1,2,3,4,5,6]], \
|
233
|
-
computed_sized_clusters[1].map{|cl| cl.sort}.sort
|
257
|
+
computed_sized_clusters[1].map{|cl| cl.sort}.sort, \
|
258
|
+
'Failed cluster of size 1'
|
234
259
|
|
235
260
|
assert_equal [[0,1,2], [3], [4,5,6]], \
|
236
261
|
computed_sized_clusters[3].map{|cl| cl.sort}.sort
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bribera-rubyvor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan Ribera
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-23 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/ruby_vor/point.rb
|
58
58
|
- lib/ruby_vor/priority_queue.rb
|
59
59
|
- lib/ruby_vor/version.rb
|
60
|
+
- lib/ruby_vor/visualizer.rb
|
60
61
|
- rubyvor.gemspec
|
61
62
|
- test/test_computation.rb
|
62
63
|
- test/test_priority_queue.rb
|
@@ -90,6 +91,6 @@ signing_key:
|
|
90
91
|
specification_version: 2
|
91
92
|
summary: RubyVor provides efficient computation of Voronoi diagrams and Delaunay triangulation for a set of Ruby points
|
92
93
|
test_files:
|
93
|
-
- test/test_voronoi_interface.rb
|
94
94
|
- test/test_computation.rb
|
95
95
|
- test/test_priority_queue.rb
|
96
|
+
- test/test_voronoi_interface.rb
|