Skip to content

Commit e662510

Browse files
author
CindeeM
committed
RF: changed dnodecom to node_degree_by_community for clarity
1 parent 5f100af commit e662510

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

brainx/tests/test_weighted_modularity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ def test_internal_links(self):
128128

129129

130130

131-
def test_dnodecom(self):
131+
def test_node_degree_by_community(self):
132132
part = wm.WeightedPartition(self.graph) # one comm per node
133133
node = 0
134-
node2comm_weights = part.dnodecom(node)
134+
node2comm_weights = part.node_degree_by_community(node)
135135
# self loops not added to weight
136136
# so communities made only of node should be zero
137137
npt.assert_equal(node2comm_weights[0],0)
@@ -140,7 +140,7 @@ def test_dnodecom(self):
140140
expected = self.graph[node][neighbor]['weight']
141141
npt.assert_equal(node2comm_weights[neighbor],expected)
142142
part = wm.WeightedPartition(self.graph, self.communities)
143-
node2comm_weights = part.dnodecom(node)
143+
node2comm_weights = part.node_degree_by_community(node)
144144
npt.assert_equal(len(node2comm_weights), 2)
145145

146146

brainx/weighted_modularity.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@ def node_degree(self, node):
100100
return self.graph.degree(weight='weight')[node]
101101

102102

103-
def dnodecom(self, node):
104-
""" Find the number of links from node to each community"""
103+
def node_degree_by_community(self, node):
104+
""" Find the number of links from a node to each community
105+
Returns
106+
-------
107+
comm_weights : list
108+
list holding the weighted degree of a node to each community
109+
"""
105110
comm_weights = [0] * len(self.communities)
106111
for neighbor, data in self.graph[node].items():
107112
if neighbor == node:
@@ -278,7 +283,7 @@ def _calc_delta_modularity(self, node, part):
278283
communities
279284
deltamod = inC - totc * ki / total_weight"""
280285
noded = part.node_degree(node)
281-
dnc = part.dnodecom(node)
286+
dnc = part.node_degree_by_community(node)
282287
totc = self._communities_nodes_alledgesw(part, node)
283288
total_weight = part.total_edge_weight
284289
# cast to arrays to improve calc

0 commit comments

Comments
 (0)