@@ -89,6 +89,11 @@ def test_get_node_community(self):
89
89
part = wm .WeightedPartition (self .graph )
90
90
self .assertEqual (part .get_node_community (0 ), 0 )
91
91
92
+ def test_node_degree (self ):
93
+ part = wm .WeightedPartition (self .graph ) # one comm per node
94
+ node = 0
95
+ res = part .node_degree (node )
96
+ npt .assert_almost_equal (res , 37.94151675 )
92
97
93
98
def test_modularity (self ):
94
99
part = wm .WeightedPartition (self .graph , self .communities )
@@ -114,21 +119,20 @@ def test_internal_links(self):
114
119
115
120
116
121
117
- def test_dnodecom ():
118
- graph , communities = get_test_data ()
119
- part = wm .WeightedPartition (graph ) # one comm per node
120
- node = 0
121
- node2comm_weights = wm .dnodecom (node , part )
122
- # self loops not added to weight
123
- # so communities made only of node should be zero
124
- npt .assert_equal (node2comm_weights [0 ],0 )
125
- # this should be equal to weight between two nodes
126
- neighbor = 1
127
- expected = graph [node ][neighbor ]['weight' ]
128
- npt .assert_equal (node2comm_weights [neighbor ],expected )
129
- part = wm .WeightedPartition (graph , communities )
130
- node2comm_weights = wm .dnodecom (node , part )
131
- npt .assert_equal (len (node2comm_weights ), 2 )
122
+ def test_dnodecom (self ):
123
+ part = wm .WeightedPartition (self .graph ) # one comm per node
124
+ node = 0
125
+ node2comm_weights = part .dnodecom (node )
126
+ # self loops not added to weight
127
+ # so communities made only of node should be zero
128
+ npt .assert_equal (node2comm_weights [0 ],0 )
129
+ # this should be equal to weight between two nodes
130
+ neighbor = 1
131
+ expected = self .graph [node ][neighbor ]['weight' ]
132
+ npt .assert_equal (node2comm_weights [neighbor ],expected )
133
+ part = wm .WeightedPartition (self .graph , self .communities )
134
+ node2comm_weights = part .dnodecom (node )
135
+ npt .assert_equal (len (node2comm_weights ), 2 )
132
136
133
137
def test_meta_graph ():
134
138
graph , communities = get_test_data ()
@@ -176,12 +180,6 @@ def test_communities_nodes_alledgesw():
176
180
177
181
178
182
179
- def test_node_degree ():
180
- graph , communities = get_test_data ()
181
- part = wm .WeightedPartition (graph ) # one comm per node
182
- node = 0
183
- res = wm .node_degree (graph , node )
184
- npt .assert_almost_equal (res , 37.94151675 )
185
183
186
184
def test_combine ():
187
185
first = [set ([0 ,1 ,2 ]), set ([3 ,4 ,5 ]), set ([6 ,7 ])]
0 commit comments