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

Python networkx.null_graph函数代码示例

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

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



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

示例1: test_null

 def test_null(self):
     dimacs = """\
     p cnf 0 0
     """
     graph=nx.null_graph()
     F = TseitinFormula(graph)
     self.assertCnfEqualsDimacs(F,dimacs)
开发者ID:chansonyhu,项目名称:cnfgen,代码行数:7,代码来源:test_tseitin.py


示例2: test_cartesian_product_null

def test_cartesian_product_null():
    null=nx.null_graph()
    empty10=nx.empty_graph(10)
    K3=nx.complete_graph(3)
    K10=nx.complete_graph(10)
    P3=nx.path_graph(3)
    P10=nx.path_graph(10)
    # null graph
    G=cartesian_product(null,null)
    assert_true(nx.is_isomorphic(G,null))
    # null_graph X anything = null_graph and v.v.
    G=cartesian_product(null,empty10)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,K3)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,K10)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,P3)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,P10)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(empty10,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(K3,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(K10,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(P3,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(P10,null)
    assert_true(nx.is_isomorphic(G,null))
开发者ID:Bludge0n,项目名称:AREsoft,代码行数:31,代码来源:test_product.py


示例3: test_null_graph

 def test_null_graph(self):
     null = nx.null_graph()
     assert_equal(list(nx.edge_boundary(null, [])), [])
     assert_equal(list(nx.edge_boundary(null, [], [])), [])
     assert_equal(list(nx.edge_boundary(null, [1, 2, 3])), [])
     assert_equal(list(nx.edge_boundary(null, [1, 2, 3], [4, 5, 6])), [])
     assert_equal(list(nx.edge_boundary(null, [1, 2, 3], [3, 4, 5])), [])
开发者ID:4c656554,项目名称:networkx,代码行数:7,代码来源:test_boundary.py


示例4: test_empty_subgraph

 def test_empty_subgraph(self):
     # Subgraph of an empty graph is an empty graph. test 1
     nullgraph = nx.null_graph()
     E5 = nx.empty_graph(5)
     E10 = nx.empty_graph(10)
     H = E10.subgraph([])
     assert_true(nx.is_isomorphic(H, nullgraph))
     H = E10.subgraph([1, 2, 3, 4, 5])
     assert_true(nx.is_isomorphic(H, E5))
开发者ID:jklaise,项目名称:networkx,代码行数:9,代码来源:historical_tests.py


示例5: test_strong_product

def test_strong_product():
    null=nx.null_graph()
    empty1=nx.empty_graph(1)
    empty10=nx.empty_graph(10)
    K2=nx.complete_graph(2)
    K3=nx.complete_graph(3)
    K5=nx.complete_graph(5)
    K10=nx.complete_graph(10)
    P2=nx.path_graph(2)
    P3=nx.path_graph(3)
    P5=nx.path_graph(5)
    P10=nx.path_graph(10)
    # null graph
    G=strong_product(null,null)
    assert_true(nx.is_isomorphic(G,null))
    # null_graph X anything = null_graph and v.v.
    G=strong_product(null,empty10)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(null,K3)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(null,K10)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(null,P3)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(null,P10)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(empty10,null)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(K3,null)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(K10,null)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(P3,null)
    assert_true(nx.is_isomorphic(G,null))
    G=strong_product(P10,null)
    assert_true(nx.is_isomorphic(G,null))

    G=strong_product(P5,K3)
    assert_equal(nx.number_of_nodes(G),5*3)
    G=strong_product(K3,K5)
    assert_equal(nx.number_of_nodes(G),3*5)

    #No classic easily found classic results for strong product

    G = nx.erdos_renyi_graph(10,2/10.)
    H = nx.erdos_renyi_graph(10,2/10.)
    GH = strong_product(G,H)

    for (u_G,u_H) in GH.nodes_iter():
        for (v_G,v_H) in GH.nodes_iter():
            if (u_G==v_G and H.has_edge(u_H,v_H)) or \
               (u_H==v_H and G.has_edge(u_G,v_G)) or \
               (G.has_edge(u_G,v_G) and H.has_edge(u_H,v_H)):
                assert_true(GH.has_edge((u_G,u_H),(v_G,v_H)))
            else:
                assert_true(not GH.has_edge((u_G,u_H),(v_G,v_H)))
开发者ID:AhmedPho,项目名称:NetworkX_fork,代码行数:56,代码来源:test_operators.py


示例6: setUp

 def setUp(self):
     self.null = nx.null_graph()
     self.P1 = cnlti(nx.path_graph(1), first_label=1)
     self.P3 = cnlti(nx.path_graph(3), first_label=1)
     self.P10 = cnlti(nx.path_graph(10), first_label=1)
     self.K1 = cnlti(nx.complete_graph(1), first_label=1)
     self.K3 = cnlti(nx.complete_graph(3), first_label=1)
     self.K4 = cnlti(nx.complete_graph(4), first_label=1)
     self.K5 = cnlti(nx.complete_graph(5), first_label=1)
     self.K10 = cnlti(nx.complete_graph(10), first_label=1)
     self.G = nx.Graph
开发者ID:jklaise,项目名称:networkx,代码行数:11,代码来源:historical_tests.py


示例7: test_write_path

 def test_write_path(self):
     # On Windows, we can't reopen a file that is open
     # So, for test we get a valid name from tempfile but close it.
     with tempfile.NamedTemporaryFile() as f:
         fullfilename = f.name
     # file should be closed now, so write_sparse6 can open it
     nx.write_sparse6(nx.null_graph(), fullfilename)
     fh = open(fullfilename, mode='rb')
     self.assertEqual(fh.read(), b'>>sparse6<<:?\n')
     fh.close()
     import os
     os.remove(fullfilename)
开发者ID:ProgVal,项目名称:networkx,代码行数:12,代码来源:test_sparse6.py


示例8: test_subgraph_nbunch

 def test_subgraph_nbunch(self):
     nullgraph = nx.null_graph()
     K1 = nx.complete_graph(1)
     K3 = nx.complete_graph(3)
     K5 = nx.complete_graph(5)
     # Test G.subgraph(nbunch), where nbunch is a single node
     H = K5.subgraph(1)
     assert_true(nx.is_isomorphic(H, K1))
     # Test G.subgraph(nbunch), where nbunch is a set
     H = K5.subgraph(set([1]))
     assert_true(nx.is_isomorphic(H, K1))
     # Test G.subgraph(nbunch), where nbunch is an iterator
     H = K5.subgraph(iter(K3))
     assert_true(nx.is_isomorphic(H, K3))
     # Test G.subgraph(nbunch), where nbunch is another graph
     H = K5.subgraph(K3)
     assert_true(nx.is_isomorphic(H, K3))
     H = K5.subgraph([9])
     assert_true(nx.is_isomorphic(H, nullgraph))
开发者ID:jklaise,项目名称:networkx,代码行数:19,代码来源:historical_tests.py


示例9: test_null_subgraph

 def test_null_subgraph(self):
     # Subgraph of a null graph is a null graph
     nullgraph = nx.null_graph()
     G = nx.null_graph()
     H = G.subgraph([])
     assert_true(nx.is_isomorphic(H, nullgraph))
开发者ID:jklaise,项目名称:networkx,代码行数:6,代码来源:historical_tests.py


示例10: test_null

 def test_null(self):
     null = nx.null_graph()
     assert_equal(list(null.degree()), [])
     assert_equal(dict(null.degree()), {})
开发者ID:jklaise,项目名称:networkx,代码行数:4,代码来源:historical_tests.py


示例11: setUp

 def setUp(self):
     self.null=nx.null_graph()
     self.P10=cnlti(nx.path_graph(10),first_label=1)
     self.K10=cnlti(nx.complete_graph(10),first_label=1)
开发者ID:NikitaVAP,项目名称:pycdb,代码行数:4,代码来源:test_boundary.py


示例12: test_null_graph

 def test_null_graph(self):
     G = nx.null_graph()
     assert_equal(len(max_clique(G)), 0)
开发者ID:ProgVal,项目名称:networkx,代码行数:3,代码来源:test_clique.py


示例13: test_null_graph

 def test_null_graph(self):
     nx.average_shortest_path_length(nx.null_graph())
开发者ID:jianantian,项目名称:networkx,代码行数:2,代码来源:test_generic.py


示例14: test_null_graph

 def test_null_graph(self):
     result = BytesIO()
     nx.write_graph6(nx.null_graph(), result)
     self.assertEqual(result.getvalue(), b'>>graph6<<?\n')
开发者ID:aparamon,项目名称:networkx,代码行数:4,代码来源:test_graph6.py


示例15: test_write_path

 def test_write_path(self):
     with tempfile.NamedTemporaryFile() as f:
         g6.write_graph6_file(nx.null_graph(), f)
         f.seek(0)
         self.assertEqual(f.read(), b'>>graph6<<?\n')
开发者ID:aparamon,项目名称:networkx,代码行数:5,代码来源:test_graph6.py


示例16: test_null_graph

 def test_null_graph(self):
     G = nx.null_graph()
     result = BytesIO()
     nx.write_sparse6(G, result)
     self.assertEqual(result.getvalue(), b'>>sparse6<<:?\n')
开发者ID:ProgVal,项目名称:networkx,代码行数:5,代码来源:test_sparse6.py


示例17: test_special_cases

 def test_special_cases(self):
     for n, H in [(0, nx.null_graph()), (1, nx.path_graph(2)),
                  (2, nx.cycle_graph(4)), (3, nx.cubical_graph())]:
         G = nx.hypercube_graph(n)
         assert_true(nx.could_be_isomorphic(G, H))
开发者ID:jklaise,项目名称:networkx,代码行数:5,代码来源:test_lattice.py


示例18: test_cartesian_product

def test_cartesian_product():
    null=nx.null_graph()
    empty1=nx.empty_graph(1)
    empty10=nx.empty_graph(10)
    K3=nx.complete_graph(3)
    K5=nx.complete_graph(5)
    K10=nx.complete_graph(10)
    P2=nx.path_graph(2)
    P3=nx.path_graph(3)
    P5=nx.path_graph(5)
    P10=nx.path_graph(10)
    # null graph
    G=cartesian_product(null,null)
    assert_true(nx.is_isomorphic(G,null))
    # null_graph X anything = null_graph and v.v.
    G=cartesian_product(null,empty10)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,K3)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,K10)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,P3)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(null,P10)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(empty10,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(K3,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(K10,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(P3,null)
    assert_true(nx.is_isomorphic(G,null))
    G=cartesian_product(P10,null)
    assert_true(nx.is_isomorphic(G,null))

    # order(GXH)=order(G)*order(H)
    G=cartesian_product(P5,K3)
    assert_equal(nx.number_of_nodes(G),5*3)
    assert_equal(nx.number_of_edges(G),
                 nx.number_of_edges(P5)*nx.number_of_nodes(K3)+
                 nx.number_of_edges(K3)*nx.number_of_nodes(P5))
    G=cartesian_product(K3,K5)
    assert_equal(nx.number_of_nodes(G),3*5)
    assert_equal(nx.number_of_edges(G),
                 nx.number_of_edges(K5)*nx.number_of_nodes(K3)+
                 nx.number_of_edges(K3)*nx.number_of_nodes(K5))

    # test some classic product graphs
    # cube = 2-path X 2-path
    G=cartesian_product(P2,P2)
    G=cartesian_product(P2,G)
    assert_true(nx.is_isomorphic(G,nx.cubical_graph()))

    # 3x3 grid
    G=cartesian_product(P3,P3)
    assert_true(nx.is_isomorphic(G,nx.grid_2d_graph(3,3)))

    G = nx.erdos_renyi_graph(10,2/10.)
    H = nx.erdos_renyi_graph(10,2/10.)
    GH = cartesian_product(G,H)

    for (u_G,u_H) in GH.nodes_iter():
        for (v_G,v_H) in GH.nodes_iter():
            if (u_G==v_G and H.has_edge(u_H,v_H)) or \
               (u_H==v_H and G.has_edge(u_G,v_G)):
                assert_true(GH.has_edge((u_G,u_H),(v_G,v_H)))
            else:
                assert_true(not GH.has_edge((u_G,u_H),(v_G,v_H)))
开发者ID:AhmedPho,项目名称:NetworkX_fork,代码行数:69,代码来源:test_operators.py


示例19: test_null_graph

 def test_null_graph(self):
     G = nx.null_graph()
     ground_truth = set()
     self._check_communities(G, ground_truth)
开发者ID:ProgVal,项目名称:networkx,代码行数:4,代码来源:test_label_propagation.py


示例20: test_write_path

 def test_write_path(self):
     with tempfile.NamedTemporaryFile() as f:
         nx.write_sparse6(nx.null_graph(), f.name)
         self.assertEqual(f.read(), b'>>sparse6<<:?\n')
开发者ID:hagberg,项目名称:networkx,代码行数:4,代码来源:test_sparse6.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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