Class: ClusteringCoefficientMeasure
- Defined in:
- lib/gimuby/genetic/archipelago/measure/clustering_coefficient_measure.rb
Overview
Compute the network average clustering coefficient as defined on en.wikipedia.org/wiki/Clustering_coefficient#Network_average_clustering_coefficient revision 19:31, 6 July 2013
Beware if you update code, this class has a state don’t break the workflow around the @potential_clusters member
Instance Method Summary collapse
-
#compute(archipelago) ⇒ float
The clustering coefficient.
Instance Method Details
#compute(archipelago) ⇒ float
Returns the clustering coefficient.
13 14 15 16 17 18 19 20 |
# File 'lib/gimuby/genetic/archipelago/measure/clustering_coefficient_measure.rb', line 13 def compute(archipelago) local_clustering_coefficients = [] archipelago.get_nodes.each do |node| local_clustering_coefficient = get_local_clustering_coefficient(archipelago, node) local_clustering_coefficients.push(local_clustering_coefficient) end local_clustering_coefficients.inject(:+) / local_clustering_coefficients.length.to_f end |