db_clustering 0.1.10 → 0.1.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9174e0f67fcea91843ba237b2cbb1e214558c8f
4
- data.tar.gz: 01b85e27ed68fc16581c23324a155064d3b6139f
3
+ metadata.gz: f960d170fbc8d820ad18016a4ce03943fd02de54
4
+ data.tar.gz: c257769487f5a8efaa1d2a2606aa1aee51083453
5
5
  SHA512:
6
- metadata.gz: 5fec9b5ba8dcbb1f4f0ad6668ffcb752bbdd5b691b4263608d0854a7b4036f5a223396539d4fbb7a36c4c085067a47fb860c9701ff580e5d2e81b7f964bf276d
7
- data.tar.gz: 0fae1b29b2f0feece92f5cc9286eb3376d89cbb9bec71ef94e66a897dce7c554449c2dde60152a6d2334e34d0708559eb0777c8b4d85930c68c7330dc421886d
6
+ metadata.gz: 6a02139c030777fdcd4ce942fad981682e50f641d5e99e76fd40859a77caa73199869f301b3bb272eae647f72b5a1c0cc967f4a9a535b5e9b229b8d1e25a246a
7
+ data.tar.gz: 972a4d5b380333a128901d62dc7b28bf8d4f5240f3517e55eb0404e99ccb7e5164299edfb5a55a87e917d58608c45d15896c236caf56c993bbc161a94db65ab0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
@@ -21,29 +21,28 @@ module DbClustering
21
21
 
22
22
  if neighbors.count < min_neighbors
23
23
  point.is_noise = true
24
- elsif point.cluster.nil?
25
- cluster = DbClustering::Models::Cluster.new
26
- @clusters << cluster
27
- cluster.add(point)
28
-
29
- expand_cluster(point, neighbors, max_distance)
24
+ else
25
+ if point.cluster.nil?
26
+ cluster = DbClustering::Models::Cluster.new
27
+ @clusters << cluster
28
+ else
29
+ cluster = point.cluster
30
+ end
31
+
32
+ neighbors.each do |neighbor|
33
+ if neighbor.cluster.nil?
34
+ cluster.add(neighbor)
35
+
36
+ # add the neighbors of the neighbor to the neighbors to fully expand the cluster
37
+ neighbors |= @datasource.neighbors(point: neighbor, distance_metric: @distance_metric, max_distance: max_distance)
38
+ end
39
+ end
30
40
  end
31
41
 
32
42
  yield(point, current_index, points_count) if block_given?
33
43
  end
34
44
  end
35
45
 
36
- def expand_cluster(point, neighbors, max_distance)
37
- neighbors.each do |neighbor|
38
- if neighbor.cluster.nil?
39
- point.cluster.add(neighbor)
40
-
41
- neighbors = @datasource.neighbors(point: point, distance_metric: @distance_metric, max_distance: max_distance)
42
- expand_cluster(neighbor, neighbors, max_distance)
43
- end
44
- end
45
- end
46
-
47
46
  end
48
47
  end
49
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_clustering
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cihat Gündüz