lib/rumale/clustering/single_linkage.rb in rumale-clustering-0.26.0 vs lib/rumale/clustering/single_linkage.rb in rumale-clustering-0.27.0
- old
+ new
@@ -146,10 +146,10 @@
curr_weights = Numo::DFloat.minimum(curr_weights[target], complete_graph[curr_node, curr_labels])
next_node = curr_labels[curr_weights.min_index]
weight = curr_weights.min
Node.new(x: curr_node, y: next_node, weight: weight)
end
- mst.sort! { |a, b| a.weight <=> b.weight }
+ mst.sort_by!(&:weight)
end
def single_linkage_hierarchy(mst)
n_edges = mst.size
n_nodes = n_edges + 1