Skip to content

Instantly share code, notes, and snippets.

@jleeothon
Created March 31, 2015 19:28
Show Gist options
  • Save jleeothon/ede52624820936e21258 to your computer and use it in GitHub Desktop.
Save jleeothon/ede52624820936e21258 to your computer and use it in GitHub Desktop.
Minimum distance between clusters of nodes
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