@@ -224,7 +224,7 @@ def __init__(self, graph, communities=None, minthr=0.0000001):
224
224
self .minthr = minthr
225
225
226
226
def run (self ):
227
- """ run the algorithm
227
+ """ run the algorithm to find partitions in graph
228
228
229
229
Returns
230
230
-------
@@ -248,7 +248,7 @@ def _gen_dendogram(self):
248
248
#special case, when there is no link
249
249
#the best partition is everyone in its communities
250
250
if self .graph .number_of_edges () == 0 :
251
- raise IOError ('graph has no edges why do you want a partition?' )
251
+ raise IOError ('graph has no edges why do you want to partition?' )
252
252
253
253
current_graph = self .graph .copy ()
254
254
part = WeightedPartition (self .graph , self .initial_communities )
@@ -399,10 +399,21 @@ def _combine(prev, next):
399
399
400
400
401
401
def meta_graph (partition ):
402
- """ takes weighted partition communities and creates a new meta graph where
403
- communities are now the nodes, the new edges are created based on the
404
- node to node connections from original graph, and weighted accordingly,
405
- this includes self-loops"""
402
+ """creates a new graph object based on input graph and partition
403
+
404
+ Takes WeightedPartition object with specified communities and
405
+ creates a new graph object where
406
+ 1. communities are now the nodes in the new graph
407
+ 2. the new edges are created based on the node to node connections (weights)
408
+ from communities in the original graph, and weighted accordingly,
409
+ (this includes self-loops)
410
+
411
+ Returns
412
+ -------
413
+ metagraph : networkX graph
414
+ mapping : dict
415
+ dict showing the mapping from newnode -> original community nodes
416
+ """
406
417
metagraph = nx .Graph ()
407
418
# new nodes are communities
408
419
newnodes = [val for val ,_ in enumerate (partition .communities )]
0 commit comments