Exemplo n.º 1
0
    def test_nodelist(self):
        """Conversion from graph to sparse matrix to graph with nodelist."""
        P4 = path_graph(4)
        P3 = path_graph(3)
        nodelist = list(P3.nodes())
        A = nx.to_scipy_sparse_matrix(P4, nodelist=nodelist)
        GA = nx.Graph(A)
        self.assert_isomorphic(GA, P3)

        # Make nodelist ambiguous by containing duplicates.
        nodelist += [nodelist[0]]
        pytest.raises(nx.NetworkXError, nx.to_numpy_matrix, P3, nodelist=nodelist)
Exemplo n.º 2
0
 def test_identity_weighted_digraph_matrix(self):
     """Conversion from weighted digraph to sparse matrix to weighted digraph."""
     A = nx.to_scipy_sparse_matrix(self.G4)
     self.identity_conversion(self.G4, A, nx.DiGraph())
Exemplo n.º 3
0
 def test_identity_digraph_matrix(self):
     "Conversion from digraph to sparse matrix to digraph."
     A = nx.to_scipy_sparse_matrix(self.G2)
     self.identity_conversion(self.G2, A, nx.DiGraph())
Exemplo n.º 4
0
 def test_identity_graph_matrix(self):
     "Conversion from graph to sparse matrix to graph."
     A = nx.to_scipy_sparse_matrix(self.G1)
     self.identity_conversion(self.G1, A, nx.Graph())