louvian_ruby 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/louvian.rb +6 -3
  2. 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
- #return nb_links_to_comm.to_f - tot*deg.to_f/m2
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+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: louvian_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: