Created
March 31, 2015 19:28
-
-
Save jleeothon/ede52624820936e21258 to your computer and use it in GitHub Desktop.
Minimum distance between clusters of nodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node | |
def distance_to cluster | |
self.reduce(nil) do |min, i| | |
cluster.reduce(min) do |min, j| | |
d = i.distance_to j | |
min = if min.nil? or min > d then d else min end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment