コード例 #1
0
    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)
コード例 #2
0
 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())
コード例 #3
0
 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())
コード例 #4
0
 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())
コード例 #5
0
 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())
コード例 #6
0
 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())
コード例 #7
0
 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())