@@ -154,42 +154,9 @@ def modularity_newman(self):
154
154
1 / 0
155
155
return (np .array (self .mod_e ) - (np .array (self .mod_a )** 2 )).sum ()
156
156
157
+ ##TODO can we remove this?? CM
157
158
modularity = modularity_newman
158
159
159
- #modularity = modularity_guimera
160
-
161
-
162
- ## def modularity_guimera(self, g, part):
163
- ## """This function takes in a graph and a partition and returns Newman's
164
- ## modularity for that graph"""
165
-
166
- ## """ Parameters
167
- ## # g = graph part = partition; a dictionary that contains a list of
168
- ## # nodes that make up that module"""
169
-
170
- ## #graph values
171
- ## num_mod = len(part)
172
- ## L = nx.number_of_edges(g)
173
- ## # construct an adjacency matrix from the input graph (g)
174
- ## mat = nx.adj_matrix(g)
175
-
176
- ## M = 0
177
- ## # loop over the modules in the graph, create an adjacency matrix
178
- ## for m, val in part.iteritems():
179
- ## #create a 'sub mat'
180
- ## submat = mat[val,:][:,val]
181
-
182
- ## #make a graph
183
- ## subg = nx.from_numpy_matrix(submat)
184
-
185
- ## #calculate module-specific metrics
186
- ## link_s = float(subg.number_of_edges())
187
- ## deg_s = np.sum(nx.degree(g,val), dtype=float)
188
-
189
- ## #compute modularity!
190
- ## M += ((link_s/L) - (deg_s/(2*L))**2)
191
-
192
- ## return M
193
160
194
161
def compute_module_merge (self , m1 , m2 ):
195
162
"""Merges two modules in a given partition.
0 commit comments