• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testing.assert_nodes_equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中networkx.testing.assert_nodes_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_nodes_equal函数的具体用法?Python assert_nodes_equal怎么用?Python assert_nodes_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_nodes_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_decoding2

 def test_decoding2(self):
     # Example from "An Optimal Algorithm for Prufer Codes".
     sequence = [2, 4, 0, 1, 3, 3]
     tree = nx.from_prufer_sequence(sequence)
     assert_nodes_equal(list(tree), list(range(8)))
     edges = [(0, 1), (0, 4), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)]
     assert_edges_equal(list(tree.edges()), edges)
开发者ID:aparamon,项目名称:networkx,代码行数:7,代码来源:test_coding.py


示例2: test_graph

    def test_graph(self):
        g = nx.cycle_graph(10)
        G = nx.Graph()
        G.add_nodes_from(g)
        G.add_weighted_edges_from((u, v, u) for u, v in g.edges())

        # Dict of dicts
        dod = to_dict_of_dicts(G)
        GG = from_dict_of_dicts(dod, create_using=nx.Graph())
        assert_nodes_equal(sorted(G.nodes()), sorted(GG.nodes()))
        assert_edges_equal(sorted(G.edges()), sorted(GG.edges()))
        GW = to_networkx_graph(dod, create_using=nx.Graph())
        assert_nodes_equal(sorted(G.nodes()), sorted(GW.nodes()))
        assert_edges_equal(sorted(G.edges()), sorted(GW.edges()))
        GI = nx.Graph(dod)
        assert_equal(sorted(G.nodes()), sorted(GI.nodes()))
        assert_equal(sorted(G.edges()), sorted(GI.edges()))

        # Dict of lists
        dol = to_dict_of_lists(G)
        GG = from_dict_of_lists(dol, create_using=nx.Graph())
        # dict of lists throws away edge data so set it to none
        enone = [(u, v, {}) for (u, v, d) in G.edges(data=True)]
        assert_nodes_equal(sorted(G.nodes()), sorted(GG.nodes()))
        assert_edges_equal(enone, sorted(GG.edges(data=True)))
        GW = to_networkx_graph(dol, create_using=nx.Graph())
        assert_nodes_equal(sorted(G.nodes()), sorted(GW.nodes()))
        assert_edges_equal(enone, sorted(GW.edges(data=True)))
        GI = nx.Graph(dol)
        assert_nodes_equal(sorted(G.nodes()), sorted(GI.nodes()))
        assert_edges_equal(enone, sorted(GI.edges(data=True)))
开发者ID:jklaise,项目名称:networkx,代码行数:31,代码来源:test_convert.py


示例3: test_path_projected_graph

 def test_path_projected_graph(self):
     G=nx.path_graph(4)
     P=bipartite.projected_graph(G, [1, 3])
     assert_nodes_equal(list(P), [1, 3])
     assert_edges_equal(list(P.edges()), [(1, 3)])
     P=bipartite.projected_graph(G, [0, 2])
     assert_nodes_equal(list(P), [0, 2])
     assert_edges_equal(list(P.edges()), [(0, 2)])
开发者ID:argriffing,项目名称:networkx,代码行数:8,代码来源:test_project.py


示例4: test_multiline_adjlist_delimiter

 def test_multiline_adjlist_delimiter(self):
     fh = io.BytesIO()
     G = nx.path_graph(3)
     nx.write_multiline_adjlist(G, fh, delimiter=':')
     fh.seek(0)
     H = nx.read_multiline_adjlist(fh, nodetype=int, delimiter=':')
     assert_nodes_equal(list(H), list(G))
     assert_edges_equal(list(H.edges()), list(G.edges()))
开发者ID:yamaguchiyuto,项目名称:networkx,代码行数:8,代码来源:test_adjlist.py


示例5: test_decoding

 def test_decoding(self):
     """Tests for decoding a tree from a Prüfer sequence."""
     # Example from Wikipedia.
     sequence = [3, 3, 3, 4]
     tree = nx.from_prufer_sequence(sequence)
     assert_nodes_equal(list(tree), list(range(6)))
     edges = [(0, 3), (1, 3), (2, 3), (3, 4), (4, 5)]
     assert_edges_equal(list(tree.edges()), edges)
开发者ID:aparamon,项目名称:networkx,代码行数:8,代码来源:test_coding.py


示例6: test_reverse_hashable

 def test_reverse_hashable(self):
     class Foo(object):
         pass
     x = Foo()
     y = Foo()
     G = nx.DiGraph()
     G.add_edge(x, y)
     assert_nodes_equal(G.nodes(), G.reverse().nodes())
     assert_equal([(y, x)], list(G.reverse().edges()))
开发者ID:aparamon,项目名称:networkx,代码行数:9,代码来源:test_digraph.py


示例7: test_complete_2_partite_graph

    def test_complete_2_partite_graph(self):
        """Tests that the complete 2-partite graph is the complete bipartite
        graph.

        """
        G = nx.complete_multipartite_graph(2, 3)
        H = nx.complete_bipartite_graph(2, 3)
        assert_nodes_equal(G, H)
        assert_edges_equal(G.edges(), H.edges())
开发者ID:nadesai,项目名称:networkx,代码行数:9,代码来源:test_classic.py


示例8: assert_equal

    def assert_equal(self, G, data=False):
        (fd, fname) = tempfile.mkstemp()
        nx.write_yaml(G, fname)
        Gin = nx.read_yaml(fname)

        assert_nodes_equal(list(G), list(Gin))
        assert_edges_equal(G.edges(data=data), Gin.edges(data=data))

        os.close(fd)
        os.unlink(fname)
开发者ID:ProgVal,项目名称:networkx,代码行数:10,代码来源:test_yaml.py


示例9: test_path_weighted_projected_graph

 def test_path_weighted_projected_graph(self):
     G=nx.path_graph(4)
     P=bipartite.weighted_projected_graph(G,[1,3])
     assert_nodes_equal(list(P),[1,3])
     assert_edges_equal(list(P.edges()),[(1,3)])
     P[1][3]['weight']=1
     P=bipartite.weighted_projected_graph(G,[0,2])
     assert_nodes_equal(list(P),[0,2])
     assert_edges_equal(list(P.edges()),[(0,2)])
     P[0][2]['weight']=1
开发者ID:argriffing,项目名称:networkx,代码行数:10,代码来源:test_project.py


示例10: test_single

    def test_single(self):
        """Tests that joining just one tree yields a tree with one more
        node.

        """
        T = nx.empty_graph(1)
        actual = nx.join([(T, 0)])
        expected = nx.path_graph(2)
        assert_nodes_equal(list(expected), list(actual))
        assert_edges_equal(list(expected.edges()), list(actual.edges()))
开发者ID:ProgVal,项目名称:networkx,代码行数:10,代码来源:test_operations.py


示例11: test_path_collaboration_projected_graph

 def test_path_collaboration_projected_graph(self):
     G=nx.path_graph(4)
     P=bipartite.collaboration_weighted_projected_graph(G,[1,3])
     assert_nodes_equal(P.nodes(),[1,3])
     assert_edges_equal(P.edges(),[(1,3)])
     P[1][3]['weight']=1
     P=bipartite.collaboration_weighted_projected_graph(G,[0,2])
     assert_nodes_equal(P.nodes(),[0,2])
     assert_edges_equal(P.edges(),[(0,2)])
     P[0][2]['weight']=1
开发者ID:666888,项目名称:networkx,代码行数:10,代码来源:test_project.py


示例12: test_multiline_adjlist_integers

 def test_multiline_adjlist_integers(self):
     (fd, fname) = tempfile.mkstemp()
     G = nx.convert_node_labels_to_integers(self.G)
     nx.write_multiline_adjlist(G, fname)
     H = nx.read_multiline_adjlist(fname, nodetype=int)
     H2 = nx.read_multiline_adjlist(fname, nodetype=int)
     assert_nodes_equal(list(H), list(G))
     assert_edges_equal(list(H.edges()), list(G.edges()))
     os.close(fd)
     os.unlink(fname)
开发者ID:yamaguchiyuto,项目名称:networkx,代码行数:10,代码来源:test_adjlist.py


示例13: test_attributes

 def test_attributes(self):
     G = nx.Graph()
     G.add_edge(1, 2, weight=1, color='red', distance=7)
     G.add_edge(2, 3, weight=1, color='green', distance=2)
     G.add_edge(1, 3, weight=10, color='blue', distance=1)
     G.graph['foo'] = 'bar'
     T = nx.minimum_spanning_tree(G, algorithm=self.algo)
     assert_equal(T.graph, G.graph)
     assert_nodes_equal(T, G)
     for u, v in T.edges():
         assert_equal(T.adj[u][v], G.adj[u][v])
开发者ID:networkx,项目名称:networkx,代码行数:11,代码来源:test_mst.py


示例14: test_edgelist_multigraph

 def test_edgelist_multigraph(self):
     G=self.MG
     (fd,fname)=tempfile.mkstemp()
     bipartite.write_edgelist(G,fname) 
     H=bipartite.read_edgelist(fname,nodetype=int,create_using=nx.MultiGraph())
     H2=bipartite.read_edgelist(fname,nodetype=int,create_using=nx.MultiGraph())
     assert_not_equal(H,H2) # they should be different graphs
     assert_nodes_equal(H.nodes(),G.nodes())
     assert_edges_equal(H.edges(),G.edges())
     os.close(fd)
     os.unlink(fname)
开发者ID:666888,项目名称:networkx,代码行数:11,代码来源:test_edgelist.py


示例15: test_path_weighted_projected_directed_graph

 def test_path_weighted_projected_directed_graph(self):
     G = nx.DiGraph()
     G.add_path(list(range(4)))
     P = bipartite.weighted_projected_graph(G, [1, 3])
     assert_nodes_equal(P.nodes(), [1, 3])
     assert_edges_equal(P.edges(), [(1, 3)])
     P[1][3]["weight"] = 1
     P = bipartite.weighted_projected_graph(G, [0, 2])
     assert_nodes_equal(P.nodes(), [0, 2])
     assert_edges_equal(P.edges(), [(0, 2)])
     P[0][2]["weight"] = 1
开发者ID:GccX11,项目名称:networkx,代码行数:11,代码来源:test_project.py


示例16: test_directed_path_collaboration_projected_graph

 def test_directed_path_collaboration_projected_graph(self):
     G=nx.DiGraph()
     G.add_path(list(range(4)))
     P=bipartite.collaboration_weighted_projected_graph(G,[1,3])
     assert_nodes_equal(list(P),[1,3])
     assert_edges_equal(list(P.edges()),[(1,3)])
     P[1][3]['weight']=1
     P=bipartite.collaboration_weighted_projected_graph(G,[0,2])
     assert_nodes_equal(list(P),[0,2])
     assert_edges_equal(list(P.edges()),[(0,2)])
     P[0][2]['weight']=1
开发者ID:argriffing,项目名称:networkx,代码行数:11,代码来源:test_project.py


示例17: test_edgelist_integers

 def test_edgelist_integers(self):
     G = nx.convert_node_labels_to_integers(self.G)
     (fd, fname) = tempfile.mkstemp()
     nx.write_edgelist(G, fname)
     H = nx.read_edgelist(fname, nodetype=int)
     # isolated nodes are not written in edgelist
     G.remove_nodes_from(list(nx.isolates(G)))
     assert_nodes_equal(list(H), list(G))
     assert_edges_equal(list(H.edges()), list(G.edges()))
     os.close(fd)
     os.unlink(fname)
开发者ID:yamaguchiyuto,项目名称:networkx,代码行数:11,代码来源:test_edgelist.py


示例18: test_adjlist_digraph

 def test_adjlist_digraph(self):
     G = self.DG
     (fd, fname) = tempfile.mkstemp()
     nx.write_adjlist(G, fname)
     H = nx.read_adjlist(fname, create_using=nx.DiGraph())
     H2 = nx.read_adjlist(fname, create_using=nx.DiGraph())
     assert_not_equal(H, H2)  # they should be different graphs
     assert_nodes_equal(list(H), list(G))
     assert_edges_equal(list(H.edges()), list(G.edges()))
     os.close(fd)
     os.unlink(fname)
开发者ID:yamaguchiyuto,项目名称:networkx,代码行数:11,代码来源:test_adjlist.py


示例19: test_multiline_adjlist_graph

 def test_multiline_adjlist_graph(self):
     G = self.G
     (fd, fname) = tempfile.mkstemp()
     nx.write_multiline_adjlist(G, fname)
     H = nx.read_multiline_adjlist(fname)
     H2 = nx.read_multiline_adjlist(fname)
     assert_not_equal(H, H2)  # they should be different graphs
     assert_nodes_equal(list(H), list(G))
     assert_edges_equal(list(H.edges()), list(G.edges()))
     os.close(fd)
     os.unlink(fname)
开发者ID:yamaguchiyuto,项目名称:networkx,代码行数:11,代码来源:test_adjlist.py


示例20: test_path_projected_properties_graph

 def test_path_projected_properties_graph(self):
     G=nx.path_graph(4)
     G.add_node(1,name='one')
     G.add_node(2,name='two')
     P=bipartite.projected_graph(G,[1,3])
     assert_nodes_equal(list(P),[1,3])
     assert_edges_equal(list(P.edges()),[(1,3)])
     assert_equal(P.node[1]['name'],G.node[1]['name'])
     P=bipartite.projected_graph(G,[0,2])
     assert_nodes_equal(list(P),[0,2])
     assert_edges_equal(list(P.edges()),[(0,2)])
     assert_equal(P.node[2]['name'],G.node[2]['name'])
开发者ID:argriffing,项目名称:networkx,代码行数:12,代码来源:test_project.py



注:本文中的networkx.testing.assert_nodes_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils._get_fh函数代码示例发布时间:2022-05-27
下一篇:
Python testing.assert_graphs_equal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap