当前位置: 首页>>代码示例>>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;未经允许,请勿转载。