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)
 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())
 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())
 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())