Skip to content

Commit b441c86

Browse files
author
CindeeM
committed
DOC: improve metagraph docs and misc cleanup
1 parent 436ce6d commit b441c86

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

brainx/weighted_modularity.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def __init__(self, graph, communities=None, minthr=0.0000001):
224224
self.minthr = minthr
225225

226226
def run(self):
227-
""" run the algorithm
227+
""" run the algorithm to find partitions in graph
228228
229229
Returns
230230
-------
@@ -248,7 +248,7 @@ def _gen_dendogram(self):
248248
#special case, when there is no link
249249
#the best partition is everyone in its communities
250250
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?')
252252

253253
current_graph = self.graph.copy()
254254
part = WeightedPartition(self.graph, self.initial_communities)
@@ -399,10 +399,21 @@ def _combine(prev, next):
399399

400400

401401
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+
"""
406417
metagraph = nx.Graph()
407418
# new nodes are communities
408419
newnodes = [val for val,_ in enumerate(partition.communities)]

0 commit comments

Comments
 (0)