コード例 #1
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_similar_output_to_naive_big(self):
     G = nx.erdos_renyi_graph(1001, 0.02)
     G2 = graphpca.reduce_graph_efficiently(G, 2)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(
         np.allclose(G2, G2n, rtol=1e-03, atol=1e-05),
         'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #2
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_add_supernode_similar_output_to_naive_small(self):
     G = nx.erdos_renyi_graph(10, 0.5)
     G2 = graphpca.reduce_graph_efficiently(G, 2, add_supernode=True)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(
         np.allclose(G2, G2n, rtol=1e-02, atol=1e-06),
         'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #3
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_similar_output_to_naive_peterson(self):
     G = nx.petersen_graph()
     G2 = graphpca.reduce_graph_efficiently(G, 2)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(
         np.allclose(G2, G2n, rtol=1e-04, atol=1e-06),
         'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #4
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_add_supernode_similar_output_to_naive_big(self):
     G = nx.watts_strogatz_graph(1001, 10, 0.05)
     G2 = graphpca.reduce_graph_efficiently(G, 2, add_supernode=True)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(
         np.allclose(G2, G2n, rtol=1e-01, atol=1e-02),
         'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #5
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_returns_plausible_results(self):
     g = nx.erdos_renyi_graph(100, 0.3)
     g_5 = graphpca.reduce_graph_efficiently(g, 5)
     self.assertEqual(len(g_5), 5)
     self.assertEqual(len(g_5[0]), 100)
     for i in range(5):
         max_val = max(abs(g_5[i]))
         self.assertGreater(max_val, 0.01)
コード例 #6
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_add_supernode_similar_output_to_naive_mat_3(self):
     mat = scipy.io.loadmat('bcspwr01.mat')
     A = mat['Problem'][0][0][1].todense()
     G = nx.from_numpy_matrix(A)
     G3 = graphpca.reduce_graph_efficiently(G, 3, add_supernode=True)
     G3n = graphpca.reduce_graph_naively(G, 3)
     self.assertTrue(np.allclose(G3, G3n, rtol=1e-02, atol=1e-06),
                     'Regular result:\n{}\nNaive result:\n{}\n'.format(G3, G3n))
コード例 #7
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_returns_plausible_results(self):
     g = nx.erdos_renyi_graph(100, 0.3)
     g_5 = graphpca.reduce_graph_efficiently(g, 5)
     self.assertEqual(len(g_5), 5)
     self.assertEqual(len(g_5[0]), 100)
     for i in range(5):
         max_val = max(abs(g_5[i]))
         self.assertGreater(max_val, 0.01)
コード例 #8
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_add_supernode_similar_output_to_naive_mat_3(self):
     mat = scipy.io.loadmat('bcspwr01.mat')
     A = mat['Problem'][0][0][1].todense()
     G = nx.from_numpy_matrix(A)
     G3 = graphpca.reduce_graph_efficiently(G, 3, add_supernode=True)
     G3n = graphpca.reduce_graph_naively(G, 3)
     self.assertTrue(
         np.allclose(G3, G3n, rtol=1e-02, atol=1e-06),
         'Regular result:\n{}\nNaive result:\n{}\n'.format(G3, G3n))
コード例 #9
0
 def test_add_supernode_similar_output_to_naive_mat_3(self):
     mat = get_fixture_mat("bcspwr01.mat")
     A = mat["Problem"][0][0][1].todense()
     G = nx.from_numpy_matrix(A)
     G3 = graphpca.reduce_graph_efficiently(G, 3, add_supernode=True)
     G3n = graphpca.reduce_graph_naively(G, 3)
     self.assertTrue(
         np.allclose(G3, G3n, rtol=1e-02, atol=1e-06),
         "Regular result:\n{}\nNaive result:\n{}\n".format(G3, G3n),
     )
コード例 #10
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_similar_output_to_naive_mat_3(self):
     mat = scipy.io.loadmat('bcspwr01.mat')
     # I love the UFSMC (https://www.cise.ufl.edu/research/sparse/matrices/)
     # but wow they really buried the matrix in this .mat
     A = mat['Problem'][0][0][1].todense()
     G = nx.from_numpy_matrix(A)
     G3 = graphpca.reduce_graph_efficiently(G, 3)
     G3n = graphpca.reduce_graph_naively(G, 3)
     self.assertTrue(np.allclose(G3, G3n, rtol=1e-04, atol=1e-06),
                     'Regular result:\n{}\nNaive result:\n{}\n'.format(G3, G3n))
コード例 #11
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_ok_if_multiple_zero_eigens(self):
     g = nx.erdos_renyi_graph(100, 0.3)
     node = next(g.nodes_iter())
     for neighbor in g.neighbors(node):
         g.remove_edge(node, neighbor)
     g_5 = graphpca.reduce_graph_efficiently(g, 5)
     self.assertEqual(len(g_5), 5)
     self.assertEqual(len(g_5[0]), 100)
     for i in range(5):
         max_val = max(abs(g_5[i]))
         self.assertGreater(max_val, 0.01)
コード例 #12
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_ok_if_multiple_zero_eigens(self):
     g = nx.erdos_renyi_graph(100, 0.3)
     node = next(g.nodes_iter())
     for neighbor in g.neighbors(node):
         g.remove_edge(node, neighbor)
     g_5 = graphpca.reduce_graph_efficiently(g, 5)
     self.assertEqual(len(g_5), 5)
     self.assertEqual(len(g_5[0]), 100)
     for i in range(5):
         max_val = max(abs(g_5[i]))
         self.assertGreater(max_val, 0.01)
コード例 #13
0
ファイル: test_graphpca.py プロジェクト: nickchak21/graphpca
 def test_similar_output_to_naive_mat_3(self):
     mat = scipy.io.loadmat('bcspwr01.mat')
     # I love the UFSMC (https://www.cise.ufl.edu/research/sparse/matrices/)
     # but wow they really buried the matrix in this .mat
     A = mat['Problem'][0][0][1].todense()
     G = nx.from_numpy_matrix(A)
     G3 = graphpca.reduce_graph_efficiently(G, 3)
     G3n = graphpca.reduce_graph_naively(G, 3)
     self.assertTrue(
         np.allclose(G3, G3n, rtol=1e-04, atol=1e-06),
         'Regular result:\n{}\nNaive result:\n{}\n'.format(G3, G3n))
コード例 #14
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_add_supernode_similar_output_to_naive_big(self):
     G = nx.watts_strogatz_graph(1001, 10, 0.05)
     G2 = graphpca.reduce_graph_efficiently(G, 2, add_supernode=True)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(np.allclose(G2, G2n, rtol=1e-01, atol=1e-02),
                     'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #15
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_add_supernode_similar_output_to_naive_small(self):
     G = nx.erdos_renyi_graph(10, 0.5)
     G2 = graphpca.reduce_graph_efficiently(G, 2, add_supernode=True)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(np.allclose(G2, G2n, rtol=1e-02, atol=1e-06),
                     'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #16
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_similar_output_to_naive_big(self):
     G = nx.erdos_renyi_graph(1001, 0.02)
     G2 = graphpca.reduce_graph_efficiently(G, 2)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(np.allclose(G2, G2n, rtol=1e-03, atol=1e-05),
                     'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))
コード例 #17
0
ファイル: test_graphpca.py プロジェクト: brandones/graphpca
 def test_similar_output_to_naive_peterson(self):
     G = nx.petersen_graph()
     G2 = graphpca.reduce_graph_efficiently(G, 2)
     G2n = graphpca.reduce_graph_naively(G, 2)
     self.assertTrue(np.allclose(G2, G2n, rtol=1e-04, atol=1e-06),
                     'Regular result:\n{}\nNaive result:\n{}\n'.format(G2, G2n))