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

Python networkx.minimum_node_cut函数代码示例

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

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



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

示例1: test_brandes_erlebach_book

def test_brandes_erlebach_book():
    # Figure 1 chapter 7: Connectivity
    # http://www.informatik.uni-augsburg.de/thi/personen/kammer/Graph_Connectivity.pdf
    G = nx.Graph()
    G.add_edges_from([(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 6), (3, 4),
                      (3, 6), (4, 6), (4, 7), (5, 7), (6, 8), (6, 9), (7, 8),
                      (7, 10), (8, 11), (9, 10), (9, 11), (10, 11)])
    for flow_func in flow_funcs:
        kwargs = dict(flow_func=flow_func)
        # edge cutsets
        assert_equal(3, len(nx.minimum_edge_cut(G, 1, 11, **kwargs)),
                     msg=msg.format(flow_func.__name__))
        edge_cut = nx.minimum_edge_cut(G, **kwargs)
        # Node 5 has only two edges
        assert_equal(2, len(edge_cut), msg=msg.format(flow_func.__name__))
        H = G.copy()
        H.remove_edges_from(edge_cut)
        assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
        # node cuts
        assert_equal(set([6, 7]), minimum_st_node_cut(G, 1, 11, **kwargs),
                     msg=msg.format(flow_func.__name__))
        assert_equal(set([6, 7]), nx.minimum_node_cut(G, 1, 11, **kwargs),
                     msg=msg.format(flow_func.__name__))
        node_cut = nx.minimum_node_cut(G, **kwargs)
        assert_equal(2, len(node_cut), msg=msg.format(flow_func.__name__))
        H = G.copy()
        H.remove_nodes_from(node_cut)
        assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
开发者ID:ProgVal,项目名称:networkx,代码行数:28,代码来源:test_cuts.py


示例2: test_white_harary_paper

def test_white_harary_paper():
    # Figure 1b white and harary (2001)
    # http://eclectic.ss.uci.edu/~drwhite/sm-w23.PDF
    # A graph with high adhesion (edge connectivity) and low cohesion
    # (node connectivity)
    G = nx.disjoint_union(nx.complete_graph(4), nx.complete_graph(4))
    G.remove_node(7)
    for i in range(4, 7):
        G.add_edge(0, i)
    G = nx.disjoint_union(G, nx.complete_graph(4))
    G.remove_node(G.order() - 1)
    for i in range(7, 10):
        G.add_edge(0, i)
    for flow_func in flow_funcs:
        kwargs = dict(flow_func=flow_func)
        # edge cuts
        edge_cut = nx.minimum_edge_cut(G, **kwargs)
        assert_equal(3, len(edge_cut), msg=msg.format(flow_func.__name__))
        H = G.copy()
        H.remove_edges_from(edge_cut)
        assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
        # node cuts
        node_cut = nx.minimum_node_cut(G, **kwargs)
        assert_equal(set([0]), node_cut, msg=msg.format(flow_func.__name__))
        H = G.copy()
        H.remove_nodes_from(node_cut)
        assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
开发者ID:ProgVal,项目名称:networkx,代码行数:27,代码来源:test_cuts.py


示例3: test_node_cutset_random_graphs

def test_node_cutset_random_graphs():
    for i in range(5):
        G = nx.fast_gnp_random_graph(50,0.2)
        cutset = nx.minimum_node_cut(G)
        assert_equal(nx.node_connectivity(G), len(cutset))
        G.remove_nodes_from(cutset)
        assert_false(nx.is_connected(G))
开发者ID:Friedsoap,项目名称:networkx,代码行数:7,代码来源:test_cuts.py


示例4: test_articulation_points

def test_articulation_points():
    Ggen = _generate_no_biconnected()
    for i in range(5):
        G = next(Ggen)
        cut = nx.minimum_node_cut(G)
        assert_true(len(cut) == 1)
        assert_true(cut.pop() in set(nx.articulation_points(G)))
开发者ID:Friedsoap,项目名称:networkx,代码行数:7,代码来源:test_cuts.py


示例5: merge

	def merge(self,minN):
		
		import numpy as np
		merged=[]
		merged_cliq=[]
		while len(DiGraph.nodes(self)):
			#print(len(self.nodes()))
			contcmp,ct_cliq=self.splitG(minN)

			if not DiGraph.nodes(self):
				break
			merged=merged+contcmp 
			merged_cliq=merged_cliq+ct_cliq

			try:
				#print("point1")
				cut_nodes=minimum_node_cut(self)

				#print("point2")
			except:
				nodes=DiGraph.nodes(self)
				index=np.random.randint(len(nodes))
				cut_nodes=[nodes[index]]

			for node in cut_nodes:
				DiGraph.remove_node(self,node)

		self.topics=merged
		self.topic_cliq=merged_cliq
开发者ID:Liping90,项目名称:dis_decribe,代码行数:29,代码来源:clique_net.py


示例6: test_articulation_points

def test_articulation_points():
    Ggen = _generate_no_biconnected()
    for flow_func in flow_funcs:
        for i in range(3):
            G = next(Ggen)
            cut = nx.minimum_node_cut(G, flow_func=flow_func)
            assert_true(len(cut) == 1, msg=msg.format(flow_func.__name__))
            assert_true(cut.pop() in set(nx.articulation_points(G)), msg=msg.format(flow_func.__name__))
开发者ID:nishnik,项目名称:networkx,代码行数:8,代码来源:test_cuts.py


示例7: test_node_cutset_random_graphs

def test_node_cutset_random_graphs():
    for i in range(5):
        G = nx.fast_gnp_random_graph(50,0.2)
        if not nx.is_connected(G):
            ccs = iter(nx.connected_components(G))
            start = next(ccs)[0]
            G.add_edges_from( (start,c[0]) for c in ccs )
        cutset = nx.minimum_node_cut(G)
        assert_equal(nx.node_connectivity(G), len(cutset))
        G.remove_nodes_from(cutset)
        assert_false(nx.is_connected(G))
开发者ID:AlistairNWard,项目名称:configurationClass,代码行数:11,代码来源:test_cuts.py


示例8: test_node_cutset_random_graphs

def test_node_cutset_random_graphs():
    for flow_func in flow_funcs:
        for i in range(3):
            G = nx.fast_gnp_random_graph(50, 0.25)
            if not nx.is_connected(G):
                ccs = iter(nx.connected_components(G))
                start = arbitrary_element(next(ccs))
                G.add_edges_from((start, arbitrary_element(c)) for c in ccs)
            cutset = nx.minimum_node_cut(G, flow_func=flow_func)
            assert_equal(nx.node_connectivity(G), len(cutset), msg=msg.format(flow_func.__name__))
            G.remove_nodes_from(cutset)
            assert_false(nx.is_connected(G), msg=msg.format(flow_func.__name__))
开发者ID:nishnik,项目名称:networkx,代码行数:12,代码来源:test_cuts.py


示例9: test_octahedral_cutset

def test_octahedral_cutset():
    G=nx.octahedral_graph()
    # edge cuts
    edge_cut = nx.minimum_edge_cut(G)
    assert_equal(4, len(edge_cut))
    H = G.copy()
    H.remove_edges_from(edge_cut)
    assert_false(nx.is_connected(H))
    # node cuts
    node_cut = nx.minimum_node_cut(G)
    assert_equal(4,len(node_cut))
    H = G.copy()
    H.remove_nodes_from(node_cut)
    assert_false(nx.is_connected(H))
开发者ID:Friedsoap,项目名称:networkx,代码行数:14,代码来源:test_cuts.py


示例10: test_icosahedral_cutset

def test_icosahedral_cutset():
    G = nx.icosahedral_graph()
    for flow_func in flow_funcs:
        kwargs = dict(flow_func=flow_func)
        # edge cuts
        edge_cut = nx.minimum_edge_cut(G, **kwargs)
        assert_equal(5, len(edge_cut), msg=msg.format(flow_func.__name__))
        H = G.copy()
        H.remove_edges_from(edge_cut)
        assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
        # node cuts
        node_cut = nx.minimum_node_cut(G, **kwargs)
        assert_equal(5, len(node_cut), msg=msg.format(flow_func.__name__))
        H = G.copy()
        H.remove_nodes_from(node_cut)
        assert_false(nx.is_connected(H), msg=msg.format(flow_func.__name__))
开发者ID:ProgVal,项目名称:networkx,代码行数:16,代码来源:test_cuts.py


示例11: minimum_cut

 def minimum_cut(self):
     # Sometimes begin nodes may not even be in the graph!
     if self.begin_node not in self.nx_graph.nodes():
         return None
     return nx.minimum_node_cut(
         self.nx_graph, self.begin_node, self.end_node)
开发者ID:brettc,项目名称:bricolage,代码行数:6,代码来源:graph_maker.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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