当前位置: 首页>>代码示例>>Python>>正文


Python networkx.is_isomorphic函数代码示例

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


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

示例1: test_biconnected_component_subgraphs_cycle

def test_biconnected_component_subgraphs_cycle():
    G=nx.cycle_graph(3)
    G.add_cycle([1,3,4,5])
    G.add_edge(1,3,eattr='red')  # test copying of edge data
    G.node[1]['nattr']='blue'
    G.graph['gattr']='green'
    Gc = set(biconnected.biconnected_component_subgraphs(G))
    assert_equal(len(Gc),2)
    g1,g2=Gc
    if 0 in g1:
        assert_true(nx.is_isomorphic(g1,nx.Graph([(0,1),(0,2),(1,2)])))
        assert_true(nx.is_isomorphic(g2,nx.Graph([(1,3),(1,5),(3,4),(4,5)])))
        assert_equal(g2[1][3]['eattr'],'red')
        assert_equal(g2.node[1]['nattr'],'blue')
        assert_equal(g2.graph['gattr'],'green')
        g2[1][3]['eattr']='blue'
        assert_equal(g2[1][3]['eattr'],'blue')
        assert_equal(G[1][3]['eattr'],'red')
    else:
        assert_true(nx.is_isomorphic(g1,nx.Graph([(1,3),(1,5),(3,4),(4,5)])))
        assert_true(nx.is_isomorphic(g2,nx.Graph([(0,1),(0,2),(1,2)])))
        assert_equal(g1[1][3]['eattr'],'red')
        assert_equal(g1.node[1]['nattr'],'blue')
        assert_equal(g1.graph['gattr'],'green')
        g1[1][3]['eattr']='blue'
        assert_equal(g1[1][3]['eattr'],'blue')
        assert_equal(G[1][3]['eattr'],'red')
开发者ID:NikitaVAP,项目名称:pycdb,代码行数:27,代码来源:test_biconnected.py

示例2: test_multigraph

 def test_multigraph(self):
     G = nx.MultiGraph()
     G.add_edge(1, 2, key="first")
     G.add_edge(1, 2, key="second", color="blue")
     H = adjacency_graph(adjacency_data(G))
     nx.is_isomorphic(G, H)
     assert_equal(H[1][2]["second"]["color"], "blue")
开发者ID:ciarancourtney,项目名称:cloudify-trial,代码行数:7,代码来源:test_adjacency.py

示例3: test_multigraph

 def test_multigraph(self):
     G = nx.MultiGraph()
     G.add_edge(1, 2, key='first')
     G.add_edge(1, 2, key='second', color='blue')
     H = node_link_graph(node_link_data(G))
     nx.is_isomorphic(G, H)
     assert_equal(H[1][2]['second']['color'], 'blue')
开发者ID:jklaise,项目名称:networkx,代码行数:7,代码来源:test_node_link.py

示例4: test_graph

 def test_graph(self):
     G = nx.DiGraph()
     G.add_nodes_from([1, 2, 3], color='red')
     G.add_edge(1, 2, foo=7)
     G.add_edge(1, 3, foo=10)
     G.add_edge(3, 4, foo=10)
     H = tree_graph(tree_data(G, 1))
     nx.is_isomorphic(G, H)
开发者ID:ProgVal,项目名称:networkx,代码行数:8,代码来源:test_tree.py

示例5: test_node_input

 def test_node_input(self):
     G = nx.grid_2d_graph(4, 2, periodic=True)
     H = nx.grid_2d_graph(range(4), range(2), periodic=True)
     assert_true(nx.is_isomorphic(H, G))
     H = nx.grid_2d_graph("abcd", "ef", periodic=True)
     assert_true(nx.is_isomorphic(H, G))
     G = nx.grid_2d_graph(5, 6)
     H = nx.grid_2d_graph(range(5), range(6))
     assert_edges_equal(H, G)
开发者ID:jklaise,项目名称:networkx,代码行数:9,代码来源:test_lattice.py

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

示例7: test_triangle_graph

 def test_triangle_graph(self):
     G = nx.complete_graph(3)
     H = nx.inverse_line_graph(G)
     alternative_solution = nx.Graph()
     alternative_solution.add_edges_from([[0, 1], [0, 2], [0, 3]])
     # there are two alternative inverse line graphs for this case
     # so long as we get one of them the test should pass
     assert_true(nx.is_isomorphic(H, G) or
                 nx.is_isomorphic(H, alternative_solution))
开发者ID:aparamon,项目名称:networkx,代码行数:9,代码来源:test_inverse_line.py

示例8: test_expected_degree_graph

def test_expected_degree_graph():
    # test that fixed seed delivers the same graph
    deg_seq = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
    G1 = nx.expected_degree_graph(deg_seq, seed=1000)
    G2 = nx.expected_degree_graph(deg_seq, seed=1000)
    assert_true(nx.is_isomorphic(G1, G2))

    G1 = nx.expected_degree_graph(deg_seq, seed=10)
    G2 = nx.expected_degree_graph(deg_seq, seed=10)
    assert_true(nx.is_isomorphic(G1, G2))
开发者ID:iaciac,项目名称:networkx,代码行数:10,代码来源:test_degree_seq.py

示例9: test_remove_one_contig

 def test_remove_one_contig(self):
     my_graph = nx.Graph()
     my_graph.add_edges_from([('Contig1', 'Contig2'), ('Contig1', 'Contig3'), ('Contig1', 'Contig4')])
     remove_contigs = RemoveContigs(my_graph)
     expected_graph = nx.Graph()
     expected_graph.add_nodes_from(['Contig2', 'Contig3', 'Contig4'])
     remove_contigs.remove_contigs_high_degree()
     self.assertTrue(nx.is_isomorphic(expected_graph, remove_contigs.graph))
     remove_contigs.remove_extra_contigs()
     self.assertTrue(nx.is_isomorphic(nx.Graph(), remove_contigs.graph))
开发者ID:JTumelty,项目名称:madansi,代码行数:10,代码来源:test_RemoveContigs.py

示例10: test_random_seed

    def test_random_seed(self):
        """Tests that each call with the same random seed generates the
        same graph.

        """
        deg_seq = [3] * 12
        G1 = nx.configuration_model(deg_seq, seed=1000)
        G2 = nx.configuration_model(deg_seq, seed=1000)
        assert_true(nx.is_isomorphic(G1, G2))
        G1 = nx.configuration_model(deg_seq, seed=10)
        G2 = nx.configuration_model(deg_seq, seed=10)
        assert_true(nx.is_isomorphic(G1, G2))
开发者ID:jianantian,项目名称:networkx,代码行数:12,代码来源:test_degree_seq.py

示例11: test_navigable_small_world

    def test_navigable_small_world(self):
        G = nx.navigable_small_world_graph(5, p=1, q=0)
        gg = nx.grid_2d_graph(5, 5).to_directed()
        assert_true(nx.is_isomorphic(G, gg))

        G = nx.navigable_small_world_graph(5, p=1, q=0, dim=3)
        gg = nx.grid_graph([5, 5, 5]).to_directed()
        assert_true(nx.is_isomorphic(G, gg))

        G = nx.navigable_small_world_graph(5, p=1, q=0, dim=1)
        gg = nx.grid_graph([5]).to_directed()
        assert_true(nx.is_isomorphic(G, gg))
开发者ID:ProgVal,项目名称:networkx,代码行数:12,代码来源:test_geometric.py

示例12: test_biconnected_component_subgraphs_cycle

def test_biconnected_component_subgraphs_cycle():
    G=nx.cycle_graph(3)
    nx.add_cycle(G, [1, 3, 4, 5])
    Gc = set(nx.biconnected_component_subgraphs(G))
    assert_equal(len(Gc), 2)
    g1, g2=Gc
    if 0 in g1:
        assert_true(nx.is_isomorphic(g1, nx.Graph([(0,1),(0,2),(1,2)])))
        assert_true(nx.is_isomorphic(g2, nx.Graph([(1,3),(1,5),(3,4),(4,5)])))
    else:
        assert_true(nx.is_isomorphic(g1, nx.Graph([(1,3),(1,5),(3,4),(4,5)])))
        assert_true(nx.is_isomorphic(g2, nx.Graph([(0,1),(0,2),(1,2)])))
开发者ID:AmesianX,项目名称:networkx,代码行数:12,代码来源:test_biconnected.py

示例13: test_ego

 def test_ego(self):
     G=nx.star_graph(3)
     H=nx.ego_graph(G,0)
     assert_true(nx.is_isomorphic(G,H))
     G.add_edge(1,11)
     G.add_edge(2,22)
     G.add_edge(3,33)
     H=nx.ego_graph(G,0)
     assert_true(nx.is_isomorphic(nx.star_graph(3),H))
     G=nx.path_graph(3)
     H=nx.ego_graph(G,0)
     assert_equal(H.edges(), [(0, 1)])
开发者ID:AhmedPho,项目名称:NetworkX_fork,代码行数:12,代码来源:test_ego.py

示例14: test_cartesian_product_classic

def test_cartesian_product_classic():
    # test some classic product graphs
    P2 = nx.path_graph(2)
    P3 = nx.path_graph(3)
    # 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)))
开发者ID:Bludge0n,项目名称:AREsoft,代码行数:12,代码来源:test_product.py

示例15: test_tensor_product_classic_result

def test_tensor_product_classic_result():
    K2 = nx.complete_graph(2)
    G = nx.petersen_graph()
    G = tensor_product(G,K2)
    assert_true(nx.is_isomorphic(G,nx.desargues_graph()))

    G = nx.cycle_graph(5)
    G = tensor_product(G,K2)
    assert_true(nx.is_isomorphic(G,nx.cycle_graph(10)))

    G = nx.tetrahedral_graph()
    G = tensor_product(G,K2)
    assert_true(nx.is_isomorphic(G,nx.cubical_graph()))
开发者ID:Bludge0n,项目名称:AREsoft,代码行数:13,代码来源:test_product.py


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