lib/rgraph/graph.rb in rgraph-0.0.11 vs lib/rgraph/graph.rb in rgraph-0.0.12
- old
+ new
@@ -166,9 +166,19 @@
distances unless @distance
(distances.flatten - [@infinity]).max
end
+ def farness
+ distances unless @distance
+
+ @distance.map{ |line| line.select{|l| l != @infinity }.inject(:+) }
+ end
+
+ def closeness
+ farness.map{|f| 1.0 / f }
+ end
+
def single_clustering(node)
possible = possible_connections(node)
return 0 if possible == 0
existent = node.neighbours.combination(2).select{ |t| t[0].neighbours.include?(t[1]) }.count