def test_nodelist(self): """Conversion from graph to matrix to graph with nodelist.""" P4 = path_graph(4) P3 = path_graph(3) nodelist = list(P3) A = nx.to_numpy_matrix(P4, nodelist=nodelist) GA = nx.Graph(A) self.assert_equal(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 matrix to weighted digraph.""" A = nx.to_numpy_matrix(self.G4) self.identity_conversion(self.G4, A, nx.DiGraph())
def test_identity_weighted_graph_array(self): """Conversion from weighted graph to array to weighted graph.""" A = nx.to_numpy_matrix(self.G3) A = np.asarray(A) self.identity_conversion(self.G3, A, nx.Graph())
def test_identity_weighted_graph_matrix(self): """Conversion from weighted graph to matrix to weighted graph.""" A = nx.to_numpy_matrix(self.G3) self.identity_conversion(self.G3, A, nx.Graph())
def test_identity_digraph_array(self): """Conversion from digraph to array to digraph.""" A = nx.to_numpy_matrix(self.G2) A = np.asarray(A) self.identity_conversion(self.G2, A, nx.DiGraph())
def test_identity_digraph_matrix(self): """Conversion from digraph to matrix to digraph.""" A = nx.to_numpy_matrix(self.G2) self.identity_conversion(self.G2, A, nx.DiGraph())
def test_identity_graph_array(self): "Conversion from graph to array to graph." A = nx.to_numpy_matrix(self.G1) A = np.asarray(A) self.identity_conversion(self.G1, A, nx.Graph())