louvian_ruby 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/louvian.rb +6 -3
- metadata +1 -1
data/lib/louvian.rb
CHANGED
@@ -2,6 +2,8 @@ require 'set'
|
|
2
2
|
module Louvian
|
3
3
|
require 'louvian/community'
|
4
4
|
|
5
|
+
MIN_INCREASE = 0.000001
|
6
|
+
|
5
7
|
# Node => community
|
6
8
|
@@n2c = {}
|
7
9
|
|
@@ -119,8 +121,9 @@ module Louvian
|
|
119
121
|
end
|
120
122
|
end
|
121
123
|
display_communities
|
124
|
+
new_mod = self.modularity
|
122
125
|
puts "modularity is #{self.modularity}"
|
123
|
-
end while nb_moves > 0
|
126
|
+
end while nb_moves > 0 and new_mod - cur_mod >= MIN_INCREASE
|
124
127
|
end
|
125
128
|
|
126
129
|
private
|
@@ -152,10 +155,10 @@ module Louvian
|
|
152
155
|
|
153
156
|
#puts "\t\t\tcomm #{community.id} #{[tot, deg, m2, nb_links_to_comm]}"
|
154
157
|
# what makes sense
|
155
|
-
return (nb_links_to_comm.to_f/m2) - (tot * deg.to_f/m2**2/2)
|
158
|
+
#return (nb_links_to_comm.to_f/m2) - (tot * deg.to_f/m2**2/2)
|
156
159
|
|
157
160
|
# copied from the cpp code
|
158
|
-
|
161
|
+
return nb_links_to_comm.to_f - tot*deg.to_f/m2
|
159
162
|
end
|
160
163
|
|
161
164
|
# This method gets all neighbour communities and the number of links from +node+
|