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

Python testing.assert_edges_equal函数代码示例

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

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



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

示例1: test_project_weighted_shared

    def test_project_weighted_shared(self):
        edges=[('A','B',2),
               ('A','C',1),
               ('B','C',1),
               ('B','D',1),
               ('B','E',2),
               ('E','F',1)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.weighted_projected_graph(self.G,'ABCDEF')
        assert_edges_equal(P.edges(),Panswer.edges())
        for u,v in P.edges():
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])

        edges=[('A','B',3),
               ('A','E',1),
               ('A','C',1),
               ('A','D',1),
               ('B','E',1),
               ('B','C',1),
               ('B','D',1),
               ('C','D',1)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.weighted_projected_graph(self.N,'ABCDE')
        assert_edges_equal(P.edges(),Panswer.edges())
        for u,v in P.edges():
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])
开发者ID:666888,项目名称:networkx,代码行数:28,代码来源:test_project.py


示例2: test_project_weighted_jaccard

    def test_project_weighted_jaccard(self):
        edges = [
            ("A", "B", 2 / 5.0),
            ("A", "C", 1 / 2.0),
            ("B", "C", 1 / 5.0),
            ("B", "D", 1 / 5.0),
            ("B", "E", 2 / 6.0),
            ("E", "F", 1 / 3.0),
        ]
        Panswer = nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P = bipartite.overlap_weighted_projected_graph(self.G, "ABCDEF")
        assert_edges_equal(P.edges(), Panswer.edges())
        for u, v in P.edges():
            assert_equal(P[u][v]["weight"], Panswer[u][v]["weight"])

        edges = [
            ("A", "B", 3 / 3.0),
            ("A", "E", 1 / 3.0),
            ("A", "C", 1 / 3.0),
            ("A", "D", 1 / 3.0),
            ("B", "E", 1 / 3.0),
            ("B", "C", 1 / 3.0),
            ("B", "D", 1 / 3.0),
            ("C", "D", 1 / 1.0),
        ]
        Panswer = nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P = bipartite.overlap_weighted_projected_graph(self.N, "ABCDE")
        assert_edges_equal(P.edges(), Panswer.edges())
        for u, v in P.edges():
            assert_equal(P[u][v]["weight"], Panswer[u][v]["weight"])
开发者ID:GccX11,项目名称:networkx,代码行数:32,代码来源:test_project.py


示例3: test_project_weighted_ratio

    def test_project_weighted_ratio(self):
        edges=[('A','B',2/6.0),
               ('A','C',1/6.0),
               ('B','C',1/6.0),
               ('B','D',1/6.0),
               ('B','E',2/6.0),
               ('E','F',1/6.0)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.weighted_projected_graph(self.G, 'ABCDEF', ratio=True)
        assert_edges_equal(list(P.edges()),Panswer.edges())
        for u,v in list(P.edges()):
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])

        edges=[('A','B',3/3.0),
               ('A','E',1/3.0),
               ('A','C',1/3.0),
               ('A','D',1/3.0),
               ('B','E',1/3.0),
               ('B','C',1/3.0),
               ('B','D',1/3.0),
               ('C','D',1/3.0)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.weighted_projected_graph(self.N, 'ABCDE', ratio=True)
        assert_edges_equal(list(P.edges()),Panswer.edges())
        for u,v in list(P.edges()):
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])
开发者ID:argriffing,项目名称:networkx,代码行数:28,代码来源:test_project.py


示例4: test_project_weighted_shared

    def test_project_weighted_shared(self):
        edges = [("A", "B", 2), ("A", "C", 1), ("B", "C", 1), ("B", "D", 1), ("B", "E", 2), ("E", "F", 1)]
        Panswer = nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P = bipartite.weighted_projected_graph(self.G, "ABCDEF")
        assert_edges_equal(P.edges(), Panswer.edges())
        for u, v in P.edges():
            assert_equal(P[u][v]["weight"], Panswer[u][v]["weight"])

        edges = [
            ("A", "B", 3),
            ("A", "E", 1),
            ("A", "C", 1),
            ("A", "D", 1),
            ("B", "E", 1),
            ("B", "C", 1),
            ("B", "D", 1),
            ("C", "D", 1),
        ]
        Panswer = nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P = bipartite.weighted_projected_graph(self.N, "ABCDE")
        assert_edges_equal(P.edges(), Panswer.edges())
        for u, v in P.edges():
            assert_equal(P[u][v]["weight"], Panswer[u][v]["weight"])
开发者ID:GccX11,项目名称:networkx,代码行数:25,代码来源:test_project.py


示例5: test_project_weighted_newman

    def test_project_weighted_newman(self):
        edges = [("A", "B", 1.5), ("A", "C", 0.5), ("B", "C", 0.5), ("B", "D", 1), ("B", "E", 2), ("E", "F", 1)]
        Panswer = nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P = bipartite.collaboration_weighted_projected_graph(self.G, "ABCDEF")
        assert_edges_equal(P.edges(), Panswer.edges())
        for u, v in P.edges():
            assert_equal(P[u][v]["weight"], Panswer[u][v]["weight"])

        edges = [
            ("A", "B", 11 / 6.0),
            ("A", "E", 1 / 2.0),
            ("A", "C", 1 / 3.0),
            ("A", "D", 1 / 3.0),
            ("B", "E", 1 / 2.0),
            ("B", "C", 1 / 3.0),
            ("B", "D", 1 / 3.0),
            ("C", "D", 1 / 3.0),
        ]
        Panswer = nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P = bipartite.collaboration_weighted_projected_graph(self.N, "ABCDE")
        assert_edges_equal(P.edges(), Panswer.edges())
        for u, v in P.edges():
            assert_equal(P[u][v]["weight"], Panswer[u][v]["weight"])
开发者ID:GccX11,项目名称:networkx,代码行数:25,代码来源:test_project.py


示例6: 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


示例7: test_project_weighted_jaccard

    def test_project_weighted_jaccard(self):
        edges=[('A','B',2/5.0),
               ('A','C',1/2.0),
               ('B','C',1/5.0),
               ('B','D',1/5.0),
               ('B','E',2/6.0),
               ('E','F',1/3.0)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.overlap_weighted_projected_graph(self.G,'ABCDEF')
        assert_edges_equal(list(P.edges()),Panswer.edges())
        for u,v in list(P.edges()):
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])

        edges=[('A','B',3/3.0),
               ('A','E',1/3.0),
               ('A','C',1/3.0),
               ('A','D',1/3.0),
               ('B','E',1/3.0),
               ('B','C',1/3.0),
               ('B','D',1/3.0),
               ('C','D',1/1.0)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.overlap_weighted_projected_graph(self.N,'ABCDE')
        assert_edges_equal(list(P.edges()),Panswer.edges())
        for u,v in P.edges():
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])
开发者ID:argriffing,项目名称:networkx,代码行数:28,代码来源:test_project.py


示例8: test_lollipop_graph

    def test_lollipop_graph(self):
        # number of nodes = m1 + m2
        # number of edges = number_of_edges(complete_graph(m1)) + m2
        for m1, m2 in [(3, 5), (4, 10), (3, 20)]:
            b=lollipop_graph(m1,m2)
            assert_equal(number_of_nodes(b), m1+m2)
            assert_equal(number_of_edges(b), m1*(m1-1)/2 + m2)

        # Raise NetworkXError if m<2
        assert_raises(networkx.exception.NetworkXError,
                      lollipop_graph, 1, 20)

        # Raise NetworkXError if n<0
        assert_raises(networkx.exception.NetworkXError,
                      lollipop_graph, 5, -2)

        # lollipop_graph(2,m) = path_graph(m+2)
        for m1, m2 in [(2, 5), (2, 10), (2, 20)]:
            b=lollipop_graph(m1,m2)
            assert_true(is_isomorphic(b, path_graph(m2+2)))

        assert_raises(networkx.exception.NetworkXError,
                      lollipop_graph, m1, m2, create_using=DiGraph())

        mb=lollipop_graph(m1, m2, create_using=MultiGraph())
        assert_edges_equal(mb.edges(), b.edges())

        g=lollipop_graph([1,2,3,4], "abc")
        assert_equal(len(g), 7)
        assert_equal(g.size(), 9)
开发者ID:nadesai,项目名称:networkx,代码行数:30,代码来源:test_classic.py


示例9: test_trivial6

 def test_trivial6(self):
     """Small graph with arbitrary weight attribute"""
     G = nx.Graph()
     G.add_edge('one', 'two', weight=10, abcd=11)
     G.add_edge('two', 'three', weight=11, abcd=10)
     assert_edges_equal(nx.max_weight_matching(G, weight='abcd'),
                        matching_dict_to_set({'one': 'two', 'two': 'one'}))
开发者ID:jianantian,项目名称:networkx,代码行数:7,代码来源:test_matching.py


示例10: test_project_weighted_newman

    def test_project_weighted_newman(self):
        edges=[('A','B',1.5),
               ('A','C',0.5),
               ('B','C',0.5),
               ('B','D',1),
               ('B','E',2),
               ('E','F',1)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.collaboration_weighted_projected_graph(self.G,'ABCDEF')
        assert_edges_equal(list(P.edges()),Panswer.edges())
        for u,v in list(P.edges()):
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])

        edges=[('A','B',11/6.0),
               ('A','E',1/2.0),
               ('A','C',1/3.0),
               ('A','D',1/3.0),
               ('B','E',1/2.0),
               ('B','C',1/3.0),
               ('B','D',1/3.0),
               ('C','D',1/3.0)]
        Panswer=nx.Graph()
        Panswer.add_weighted_edges_from(edges)
        P=bipartite.collaboration_weighted_projected_graph(self.N,'ABCDE')
        assert_edges_equal(list(P.edges()),Panswer.edges())
        for u,v in list(P.edges()):
            assert_equal(P[u][v]['weight'],Panswer[u][v]['weight'])
开发者ID:argriffing,项目名称:networkx,代码行数:28,代码来源:test_project.py


示例11: test_trivial4

 def test_trivial4(self):
     """Small graph"""
     G = nx.Graph()
     G.add_edge('one', 'two', weight=10)
     G.add_edge('two', 'three', weight=11)
     assert_edges_equal(nx.max_weight_matching(G),
                        matching_dict_to_set({'three': 'two', 'two': 'three'}))
开发者ID:jianantian,项目名称:networkx,代码行数:7,代码来源:test_matching.py


示例12: test_path_graph

    def test_path_graph(self):
        p=path_graph(0)
        assert_true(is_isomorphic(p, null_graph()))

        p=path_graph(1)
        assert_true(is_isomorphic( p, empty_graph(1)))

        p=path_graph(10)
        assert_true(is_connected(p))
        assert_equal(sorted(d for n, d in p.degree()),
                     [1, 1, 2, 2, 2, 2, 2, 2, 2, 2])
        assert_equal(p.order()-1, p.size())

        dp=path_graph(3, create_using=DiGraph())
        assert_true(dp.has_edge(0,1))
        assert_false(dp.has_edge(1,0))

        mp=path_graph(10, create_using=MultiGraph())
        assert_edges_equal(mp.edges(), p.edges())

        G=path_graph("abc")
        assert_equal(len(G), 3)
        assert_equal(G.size(), 2)
        g=path_graph("abc", nx.DiGraph())
        assert_equal(len(g), 3)
        assert_equal(g.size(), 2)
        assert_true(g.is_directed())
开发者ID:nadesai,项目名称:networkx,代码行数:27,代码来源:test_classic.py


示例13: 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


示例14: test_s_blossom_relabel_expand

 def test_s_blossom_relabel_expand(self):
     """Create S-blossom, relabel as T, expand:"""
     G = nx.Graph()
     G.add_weighted_edges_from([(1, 2, 23), (1, 5, 22), (1, 6, 15),
                                (2, 3, 25), (3, 4, 22), (4, 5, 25),
                                (4, 8, 14), (5, 7, 13)])
     assert_edges_equal(nx.max_weight_matching(G),
                        matching_dict_to_set({1: 6, 2: 3, 3: 2, 4: 8, 5: 7, 6: 1, 7: 5, 8: 4}))
开发者ID:jianantian,项目名称:networkx,代码行数:8,代码来源:test_matching.py


示例15: test_nested_s_blossom_relabel_expand

 def test_nested_s_blossom_relabel_expand(self):
     """Create nested S-blossom, relabel as T, expand:"""
     G = nx.Graph()
     G.add_weighted_edges_from([(1, 2, 19), (1, 3, 20), (1, 8, 8),
                                (2, 3, 25), (2, 4, 18), (3, 5, 18),
                                (4, 5, 13), (4, 7, 7), (5, 6, 7)])
     assert_edges_equal(nx.max_weight_matching(G),
                        matching_dict_to_set({1: 8, 2: 3, 3: 2, 4: 7, 5: 6, 6: 5, 7: 4, 8: 1}))
开发者ID:jianantian,项目名称:networkx,代码行数:8,代码来源:test_matching.py


示例16: test_nested_s_blossom_relabel

 def test_nested_s_blossom_relabel(self):
     """Create S-blossom, relabel as S, include in nested S-blossom:"""
     G = nx.Graph()
     G.add_weighted_edges_from([(1, 2, 10), (1, 7, 10), (2, 3, 12),
                                (3, 4, 20), (3, 5, 20), (4, 5, 25),
                                (5, 6, 10), (6, 7, 10), (7, 8, 8)])
     assert_edges_equal(nx.max_weight_matching(G),
                        matching_dict_to_set({1: 2, 2: 1, 3: 4, 4: 3, 5: 6, 6: 5, 7: 8, 8: 7}))
开发者ID:jianantian,项目名称:networkx,代码行数:8,代码来源:test_matching.py


示例17: 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


示例18: test_without_data

 def test_without_data(self):
     edges = nx.minimum_spanning_edges(self.G, algorithm=self.algo,
                                       data=False)
     # Edges from the spanning edges functions don't come in sorted
     # orientation, so we need to sort each edge individually.
     actual = sorted((min(u, v), max(u, v)) for u, v in edges)
     expected = [(u, v) for u, v, d in self.minimum_spanning_edgelist]
     assert_edges_equal(actual, expected)
开发者ID:networkx,项目名称:networkx,代码行数:8,代码来源:test_mst.py


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python testing.assert_graphs_equal函数代码示例发布时间:2022-05-27
下一篇:
Python json_graph.node_link_graph函数代码示例发布时间: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