當前位置: 首頁>>代碼示例>>Python>>正文


Python networkx.OrderedDiGraph方法代碼示例

本文整理匯總了Python中networkx.OrderedDiGraph方法的典型用法代碼示例。如果您正苦於以下問題:Python networkx.OrderedDiGraph方法的具體用法?Python networkx.OrderedDiGraph怎麽用?Python networkx.OrderedDiGraph使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在networkx的用法示例。


在下文中一共展示了networkx.OrderedDiGraph方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_write_p2g

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_write_p2g(self):
        s = b"""foo
3 2
1
1 
2
2 
3

"""
        fh = io.BytesIO()
        G = nx.OrderedDiGraph()
        G.name = 'foo'
        G.add_edges_from([(1, 2), (2, 3)])
        write_p2g(G, fh)
        fh.seek(0)
        r = fh.read()
        assert_equal(r, s) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:20,代碼來源:test_p2g.py

示例2: test_write_p2g

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_write_p2g(self):
        s=b"""foo
3 2
1
1 
2
2 
3

"""
        fh=io.BytesIO()
        G=nx.OrderedDiGraph()
        G.name='foo'
        G.add_edges_from([(1,2),(2,3)])
        write_p2g(G,fh)
        fh.seek(0)
        r=fh.read()
        assert_equal(r,s) 
開發者ID:aws-samples,項目名稱:aws-kube-codesuite,代碼行數:20,代碼來源:test_p2g.py

示例3: test_differential_operator

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_differential_operator(self, n_vertices=98):
        r"""The Laplacian must always be the divergence of the gradient,
        whether the Laplacian is combinatorial or normalized, and whether the
        graph is directed or weighted."""
        def test_incidence_nx(graph):
            r"""Test that the incidence matrix corresponds to NetworkX."""
            incidence_pg = np.sign(graph.D.toarray())
            G = nx.OrderedDiGraph if graph.is_directed() else nx.OrderedGraph
            graph_nx = nx.from_scipy_sparse_matrix(graph.W, create_using=G)
            incidence_nx = nx.incidence_matrix(graph_nx, oriented=True)
            np.testing.assert_equal(incidence_pg, incidence_nx.toarray())
        for graph in [graphs.Graph(np.zeros((n_vertices, n_vertices))),
                      graphs.Graph(np.identity(n_vertices)),
                      graphs.Graph([[0, 0.8], [0.8, 0]]),
                      graphs.Graph([[1.3, 0], [0.4, 0.5]]),
                      graphs.ErdosRenyi(n_vertices, directed=False, seed=42),
                      graphs.ErdosRenyi(n_vertices, directed=True, seed=42)]:
            for lap_type in ['combinatorial', 'normalized']:
                graph.compute_laplacian(lap_type)
                graph.compute_differential_operator()
                L = graph.D.dot(graph.D.T)
                np.testing.assert_allclose(L.toarray(), graph.L.toarray())
                test_incidence_nx(graph) 
開發者ID:epfl-lts2,項目名稱:pygsp,代碼行數:25,代碼來源:test_graphs.py

示例4: graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def graph(self):
        if self._graph:
            return self._graph

        g = networkx.OrderedDiGraph()

        for task in self.tasks.values():
            g.add_node(task)
            for dep in task.depends_on():
                g.add_edge(task, dep)

        self._graph = g
        return self.graph 
開發者ID:kennethreitz-archive,項目名稱:bake,代碼行數:15,代碼來源:bakefile.py

示例5: test_digraph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_digraph():
        G = nx.OrderedDiGraph() 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:4,代碼來源:test_ordered.py

示例6: test_attribute_dict_integrity

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_attribute_dict_integrity(self):
        # we must not replace dict-like graph data structures with dicts
        G = nx.OrderedGraph()
        G.add_nodes_from("abc")
        H = to_networkx_graph(G, create_using=nx.OrderedGraph)
        assert_equal(list(H.nodes), list(G.nodes))
        H = nx.OrderedDiGraph(G)
        assert_equal(list(H.nodes), list(G.nodes)) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:10,代碼來源:test_convert.py

示例7: test_digraph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_digraph(self):
        G = nx.OrderedDiGraph() 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:4,代碼來源:test_ordered.py

示例8: setUp

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def setUp(self):
        self.G = nx.OrderedDiGraph()
        self.G.add_nodes_from([1, 2, 3])
        self.G.add_edges_from([(2, 3), (1, 3)]) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:6,代碼來源:test_ordered.py

示例9: test_attribute_dict_integrity

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import OrderedDiGraph [as 別名]
def test_attribute_dict_integrity(self):
        # we must not replace dict-like graph data structures with dicts
        G = nx.OrderedGraph()
        G.add_nodes_from("abc")
        H = to_networkx_graph(G, create_using=nx.OrderedGraph())
        assert_equal(list(H.nodes), list(G.nodes))
        H = nx.OrderedDiGraph(G)
        assert_equal(list(H.nodes), list(G.nodes)) 
開發者ID:aws-samples,項目名稱:aws-kube-codesuite,代碼行數:10,代碼來源:test_convert.py


注:本文中的networkx.OrderedDiGraph方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。