本文整理汇总了Python中networkx.cnlti函数的典型用法代码示例。如果您正苦于以下问题:Python cnlti函数的具体用法?Python cnlti怎么用?Python cnlti使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cnlti函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
G1 = cnlti(nx.grid_2d_graph(2, 2), first_label=0, ordering="sorted")
G2 = cnlti(nx.lollipop_graph(3, 3), first_label=4, ordering="sorted")
G3 = cnlti(nx.house_graph(), first_label=10, ordering="sorted")
self.G = nx.union(G1, G2)
self.G = nx.union(self.G, G3)
self.DG = nx.DiGraph([(1, 2), (1, 3), (2, 3)])
self.grid = cnlti(nx.grid_2d_graph(4, 4), first_label=1)
self.gc = []
G = nx.DiGraph()
G.add_edges_from([(1, 2), (2, 3), (2, 8), (3, 4), (3, 7), (4, 5),
(5, 3), (5, 6), (7, 4), (7, 6), (8, 1), (8, 7)])
C = [[3, 4, 5, 7], [1, 2, 8], [6]]
self.gc.append((G, C))
G = nx.DiGraph()
G.add_edges_from([(1, 2), (1, 3), (1, 4), (4, 2), (3, 4), (2, 3)])
C = [[2, 3, 4],[1]]
self.gc.append((G, C))
G = nx.DiGraph()
G.add_edges_from([(1, 2), (2, 3), (3, 2), (2, 1)])
C = [[1, 2, 3]]
self.gc.append((G,C))
# Eppstein's tests
G = nx.DiGraph({0:[1], 1:[2, 3], 2:[4, 5], 3:[4, 5], 4:[6], 5:[], 6:[]})
C = [[0], [1], [2],[ 3], [4], [5], [6]]
self.gc.append((G,C))
G = nx.DiGraph({0:[1], 1:[2, 3, 4], 2:[0, 3], 3:[4], 4:[3]})
C = [[0, 1, 2], [3, 4]]
self.gc.append((G, C))
开发者ID:4c656554,项目名称:networkx,代码行数:34,代码来源:test_connected.py
示例2: setUp
def setUp(self):
G1=cnlti(nx.grid_2d_graph(2,2),first_label=0,ordering="sorted")
G2=cnlti(nx.lollipop_graph(3,3),first_label=4,ordering="sorted")
G3=cnlti(nx.house_graph(),first_label=10,ordering="sorted")
self.G=nx.union(G1,G2)
self.G=nx.union(self.G,G3)
self.DG=nx.DiGraph([(1,2),(1,3),(2,3)])
self.grid=cnlti(nx.grid_2d_graph(4,4),first_label=1)
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:8,代码来源:test_connected.py
示例3: test_shortest_simple_paths
def test_shortest_simple_paths():
G = cnlti(nx.grid_2d_graph(4, 4), first_label=1, ordering="sorted")
paths = nx.shortest_simple_paths(G, 1, 12)
assert_equal(next(paths), [1, 2, 3, 4, 8, 12])
assert_equal(next(paths), [1, 5, 6, 7, 8, 12])
assert_equal([len(path) for path in nx.shortest_simple_paths(G, 1, 12)],
sorted([len(path) for path in nx.all_simple_paths(G, 1, 12)]))
开发者ID:iaciac,项目名称:networkx,代码行数:7,代码来源:test_simple_paths.py
示例4: setUp
def setUp(self):
z=[3,4,3,4,2,4,2,1,1,1,1]
self.G=cnlti(nx.generators.havel_hakimi_graph(z),first_label=1)
self.cl=list(nx.find_cliques(self.G))
H=nx.complete_graph(6)
H=nx.relabel_nodes(H,dict( [(i,i+1) for i in range(6)]))
H.remove_edges_from([(2,6),(2,5),(2,4),(1,3),(5,3)])
self.H=H
开发者ID:Bramas,项目名称:networkx,代码行数:8,代码来源:test_clique.py
示例5: test_path_graph
def test_path_graph(self):
P10 = cnlti(nx.path_graph(10), first_label=1)
assert_equal(nx.node_boundary(P10, []), set())
assert_equal(nx.node_boundary(P10, [], []), set())
assert_equal(nx.node_boundary(P10, [1, 2, 3]), {4})
assert_equal(nx.node_boundary(P10, [4, 5, 6]), {3, 7})
assert_equal(nx.node_boundary(P10, [3, 4, 5, 6, 7]), {2, 8})
assert_equal(nx.node_boundary(P10, [8, 9, 10]), {7})
assert_equal(nx.node_boundary(P10, [4, 5, 6], [9, 10]), set())
开发者ID:4c656554,项目名称:networkx,代码行数:9,代码来源:test_boundary.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_complete_graph
def test_complete_graph(self):
K10 = cnlti(nx.complete_graph(10), first_label=1)
assert_equal(nx.node_boundary(K10, []), set())
assert_equal(nx.node_boundary(K10, [], []), set())
assert_equal(nx.node_boundary(K10, [1, 2, 3]), {4, 5, 6, 7, 8, 9, 10})
assert_equal(nx.node_boundary(K10, [4, 5, 6]), {1, 2, 3, 7, 8, 9, 10})
assert_equal(nx.node_boundary(K10, [3, 4, 5, 6, 7]), {1, 2, 8, 9, 10})
assert_equal(nx.node_boundary(K10, [4, 5, 6], []), set())
assert_equal(nx.node_boundary(K10, K10), set())
assert_equal(nx.node_boundary(K10, [1, 2, 3], [3, 4, 5]), {4, 5})
开发者ID:4c656554,项目名称:networkx,代码行数:10,代码来源:test_boundary.py
示例8: setUp
def setUp(self):
from networkx import convert_node_labels_to_integers as cnlti
self.grid = cnlti(nx.grid_2d_graph(4, 4), first_label=1,
ordering="sorted")
self.cycle = nx.cycle_graph(7)
self.directed_cycle = nx.cycle_graph(7, create_using=nx.DiGraph())
self.neg_weights = nx.DiGraph()
self.neg_weights.add_edge(0, 1, weight=1)
self.neg_weights.add_edge(0, 2, weight=3)
self.neg_weights.add_edge(1, 3, weight=1)
self.neg_weights.add_edge(2, 3, weight=-2)
开发者ID:jianantian,项目名称:networkx,代码行数:11,代码来源:test_generic.py
示例9: setUp
def setUp(self):
from networkx import convert_node_labels_to_integers as cnlti
self.grid = cnlti(nx.grid_2d_graph(4, 4), first_label=1, ordering="sorted")
self.cycle = nx.cycle_graph(7)
self.directed_cycle = nx.cycle_graph(7, create_using=nx.DiGraph())
self.XG = nx.DiGraph()
self.XG.add_weighted_edges_from(
[
("s", "u", 10),
("s", "x", 5),
("u", "v", 1),
("u", "x", 2),
("v", "y", 1),
("x", "u", 3),
("x", "v", 5),
("x", "y", 2),
("y", "s", 7),
("y", "v", 6),
]
)
self.MXG = nx.MultiDiGraph(self.XG)
self.MXG.add_edge("s", "u", weight=15)
self.XG2 = nx.DiGraph()
self.XG2.add_weighted_edges_from(
[[1, 4, 1], [4, 5, 1], [5, 6, 1], [6, 3, 1], [1, 3, 50], [1, 2, 100], [2, 3, 100]]
)
self.XG3 = nx.Graph()
self.XG3.add_weighted_edges_from([[0, 1, 2], [1, 2, 12], [2, 3, 1], [3, 4, 5], [4, 5, 1], [5, 0, 10]])
self.XG4 = nx.Graph()
self.XG4.add_weighted_edges_from(
[[0, 1, 2], [1, 2, 2], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]]
)
self.MXG4 = nx.MultiGraph(self.XG4)
self.MXG4.add_edge(0, 1, weight=3)
self.G = nx.DiGraph() # no weights
self.G.add_edges_from(
[
("s", "u"),
("s", "x"),
("u", "v"),
("u", "x"),
("v", "y"),
("x", "u"),
("x", "v"),
("x", "y"),
("y", "s"),
("y", "v"),
]
)
开发者ID:Bludge0n,项目名称:AREsoft,代码行数:52,代码来源:test_weighted.py
示例10: test_bidirectional_shortest_path_restricted
def test_bidirectional_shortest_path_restricted():
grid = cnlti(nx.grid_2d_graph(4, 4), first_label=1, ordering="sorted")
cycle = nx.cycle_graph(7)
directed_cycle = nx.cycle_graph(7, create_using=nx.DiGraph())
length, path = _bidirectional_shortest_path(cycle, 0, 3)
assert_equal(path, [0, 1, 2, 3])
length, path = _bidirectional_shortest_path(cycle, 0, 3, ignore_nodes=[1])
assert_equal(path, [0, 6, 5, 4, 3])
length, path = _bidirectional_shortest_path(grid, 1, 12)
assert_equal(path, [1, 2, 3, 4, 8, 12])
length, path = _bidirectional_shortest_path(grid, 1, 12, ignore_nodes=[2])
assert_equal(path, [1, 5, 6, 10, 11, 12])
length, path = _bidirectional_shortest_path(grid, 1, 12, ignore_nodes=[2, 6])
assert_equal(path, [1, 5, 9, 10, 11, 12])
length, path = _bidirectional_shortest_path(grid, 1, 12, ignore_nodes=[2, 6], ignore_edges=[(10, 11)])
assert_equal(path, [1, 5, 9, 10, 14, 15, 16, 12])
length, path = _bidirectional_shortest_path(directed_cycle, 0, 3)
assert_equal(path, [0, 1, 2, 3])
assert_raises(nx.NetworkXNoPath, _bidirectional_shortest_path, directed_cycle, 0, 3, ignore_nodes=[1])
length, path = _bidirectional_shortest_path(directed_cycle, 0, 3, ignore_edges=[(2, 1)])
assert_equal(path, [0, 1, 2, 3])
assert_raises(nx.NetworkXNoPath, _bidirectional_shortest_path, directed_cycle, 0, 3, ignore_edges=[(1, 2)])
开发者ID:nishnik,项目名称:networkx,代码行数:22,代码来源:test_simple_paths.py
示例11: setUp
def setUp(self):
from networkx import convert_node_labels_to_integers as cnlti
self.grid=cnlti(nx.grid_2d_graph(4,4),first_label=1,ordering="sorted")
self.cycle=nx.cycle_graph(7)
self.directed_cycle=nx.cycle_graph(7,create_using=nx.DiGraph())
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:5,代码来源:test_generic.py
示例12: setUp
def setUp(self):
G=networkx.Graph()
from networkx import convert_node_labels_to_integers as cnlti
G=cnlti(networkx.grid_2d_graph(4,4),first_label=1,ordering="sorted")
self.G=G
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:5,代码来源:test_distance_measures.py
示例13: 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
示例14: setUp
def setUp(self):
G = cnlti(nx.grid_2d_graph(4, 4), first_label=1, ordering="sorted")
self.G = G
开发者ID:networkx,项目名称:networkx,代码行数:3,代码来源:test_distance_measures.py
注:本文中的networkx.cnlti函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论