Ejemplo n.º 1
0
	def test_within_community_degree(self):
		graph = nx.Graph([(0,1)])
		graph.add_node(2)
		louvain = wm.LouvainCommunityDetection(graph)
		weighted_partitions = louvain.run()
		weighted_partition = weighted_partitions[0]
		with self.assertRaises(ValueError):
			nr.within_community_degree(weighted_partition)
Ejemplo n.º 2
0
 def test_within_community_degree(self):
     graph = nx.Graph([(0, 1)])
     graph.add_node(2)
     louvain = wm.LouvainCommunityDetection(graph)
     weighted_partitions = louvain.run()
     weighted_partition = weighted_partitions[0]
     with self.assertRaises(ValueError):
         nr.within_community_degree(weighted_partition)
Ejemplo n.º 3
0
	def test_disconnected_communites(self):
		graph = nx.Graph([(0,1),(1,2),(2,0),(3,4),(3,5),(4,5)])
		louvain = wm.LouvainCommunityDetection(graph)
		partition = louvain.run()[0]
		wcd = nr.within_community_degree(partition)
		self.assertEqual(wcd, {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0})
		pc = nr.participation_coefficient(partition)
		self.assertEqual(pc, {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0})
Ejemplo n.º 4
0
 def test_disconnected_communites(self):
     graph = nx.Graph([(0, 1), (1, 2), (2, 0), (3, 4), (3, 5), (4, 5)])
     louvain = wm.LouvainCommunityDetection(graph)
     partition = louvain.run()[0]
     wcd = nr.within_community_degree(partition)
     self.assertEqual(wcd, {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0})
     pc = nr.participation_coefficient(partition)
     self.assertEqual(pc, {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0})