コード例 #1
0
 def test_remove_negative_weights(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[1, -1, 1, -1], [1, -1, 1, 0], [-1, 1, 0, 0],
                   [0, 0, 0, 0]])
     graph = GraphWU(A, measure_list[GraphWU], 'zero', 'max')
     for (i, j), value in np.ndenumerate(graph.A):
         self.assertTrue(value >= 0)
コード例 #2
0
 def test_remove_diagonal(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[1, 1, 1, 1], [1, 1, 1, 0], [1, 1, 0, 0], [0, 0, 0, 0]])
     graph = GraphBD(A, measure_list[GraphBD], 'zero')
     for (i, j), value in np.ndenumerate(graph.A):
         if(i == j):
             self.assertEqual(value, 0)
コード例 #3
0
 def test_symmetrize(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[1, 1, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 1]])
     graph = GraphWU(A, measure_list[GraphWU], 'zero', 'max')
     for (i, j), value in np.ndenumerate(graph.A):
         if (i != j):
             self.assertTrue(value > 0)
コード例 #4
0
 def test_bd(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 1, 1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]])
     graph = GraphBD(A, measure_list[GraphBD], 'zero')
     community = graph.community_structure
     self.assertCategorizationEqual(community, [0, 0, 0, 1])
     self.assertAlmostEqual(graph.get_measure(MeasureModularity, 'modularity'), 0.0)
コード例 #5
0
 def test_binarize(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 0, 0, 0], [4.3, 1.5, -2, 0], [-600, 0.00, 3.14, 0],
                   [1, 1.0, 0.5, 0.0006]])
     graph = GraphBU(A, measure_list[GraphBU], 'zero')
     for (i, j), value in np.ndenumerate(graph.A):
         self.assertTrue(value == 1 or value == 0)
コード例 #6
0
 def test_wu(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 0.1, 0.2, 0.1, 0, 0, 0, 0],
                   [0, 0, 0.5, 0, 0.1, 0, 0, 0],
                   [0, 0, 0, 0, 0.2, 0, 0, 0],
                   [0, 0, 0.5, 0, 0.1, 0, 0, 0],
                   [0, 0, 0, 0, 0, 0.1, 0.5, 0],
                   [0, 0, 0, 0, 0, 0, 0, 0.2],
                   [0, 0, 0, 0, 0, 0, 0, 0.8],
                   [0, 0, 0, 0, 0, 0, 0, 0]])
     graph = GraphWU(A, measure_list[GraphWU], 'zero')
     community = graph.community_structure
     self.assertCategorizationEqual(community, [0,0,0,0,1,1,1,1])
     self.assertAlmostEqual(graph.get_measure(MeasureModularity, 'modularity'), 0.3806, places = 4)
コード例 #7
0
 def test_binary(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 1, 1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]])
     graph = GraphBD(A, measure_list[GraphBD], 'zero')
     self.assertTrue(graph.is_binary())
コード例 #8
0
 def test_binarize(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, -6, 2, 0], [44, -15, 1, 0], [100, 0.6, 0, 0], [0, 0, 0, 0]])
     graph = GraphBD(A, measure_list[GraphBD], 'zero')
     for (i, j), value in np.ndenumerate(graph.A):
         self.assertTrue(value == 1 or value == 0)
コード例 #9
0
 def test_binary(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 1, 1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]])
     graph = GraphWU(A, measure_list[GraphWU], 'zero', 'max')
     self.assertFalse(graph.is_binary())
コード例 #10
0
 def test(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 1, 1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]])
     graph = GraphBD(A, measure_list[GraphBD], 'zero')
コード例 #11
0
 def test_directed(self):
     measure_list = MeasureParser.list_measures()
     A = np.array([[0, 1, 1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]])
     graph = GraphWD(A, measure_list[GraphWD], 'zero')
     self.assertTrue(graph.is_directed())