本文整理汇总了Python中networkx.line_graph方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.line_graph方法的具体用法?Python networkx.line_graph怎么用?Python networkx.line_graph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx
的用法示例。
在下文中一共展示了networkx.line_graph方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_line_graph
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def _create_line_graph(self, graph):
r"""Getting the embedding of graphs.
Arg types:
* **graph** *(NetworkX graph)* - The graph transformed to be a line graph.
Return types:
* **line_graph** *(NetworkX graph)* - The line graph of the source graph.
"""
graph = nx.line_graph(graph)
node_mapper = {node: i for i, node in enumerate(graph.nodes())}
edges = [[node_mapper[edge[0]], node_mapper[edge[1]]] for edge in graph.edges()]
line_graph = nx.from_edgelist(edges)
return line_graph
示例2: test_star
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_star(self):
G = nx.star_graph(5)
L = nx.line_graph(G)
assert_true(nx.is_isomorphic(L, nx.complete_graph(5)))
示例3: test_path
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_path(self):
G = nx.path_graph(5)
L = nx.line_graph(G)
assert_true(nx.is_isomorphic(L, nx.path_graph(4)))
示例4: test_cycle
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_cycle(self):
G = nx.cycle_graph(5)
L = nx.line_graph(G)
assert_true(nx.is_isomorphic(L, G))
示例5: test_digraph1
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_digraph1(self):
G = nx.DiGraph()
G.add_edges_from([(0,1),(0,2),(0,3)])
L = nx.line_graph(G)
# no edge graph, but with nodes
assert_equal(L.adj, {(0,1):{}, (0,2):{}, (0,3):{}})
示例6: test_digraph2
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_digraph2(self):
G = nx.DiGraph()
G.add_edges_from([(0,1),(1,2),(2,3)])
L = nx.line_graph(G)
assert_equal(sorted(L.edges()), [((0, 1), (1, 2)), ((1, 2), (2, 3))])
示例7: test_create2
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_create2(self):
G = nx.Graph()
G.add_edges_from([(0,1),(1,2),(2,3)])
L = nx.line_graph(G, create_using=nx.DiGraph())
assert_equal(sorted(L.edges()), [((0, 1), (1, 2)), ((1, 2), (2, 3))])
示例8: test_digraph1
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_digraph1(self):
G = nx.DiGraph()
G.add_edges_from([(0, 1), (0, 2), (0, 3)])
L = nx.line_graph(G)
# no edge graph, but with nodes
assert_equal(L.adj, {(0, 1): {}, (0, 2): {}, (0, 3): {}})
示例9: test_digraph2
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_digraph2(self):
G = nx.DiGraph()
G.add_edges_from([(0, 1), (1, 2), (2, 3)])
L = nx.line_graph(G)
assert_edges_equal(L.edges(), [((0, 1), (1, 2)), ((1, 2), (2, 3))])
示例10: test_create2
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_create2(self):
G = nx.Graph()
G.add_edges_from([(0, 1), (1, 2), (2, 3)])
L = nx.line_graph(G, create_using=nx.DiGraph())
assert_edges_equal(L.edges(), [((0, 1), (1, 2)), ((1, 2), (2, 3))])
示例11: test_line_inverse_line_complete
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_line_inverse_line_complete(self):
G = nx.complete_graph(10)
H = nx.line_graph(G)
J = nx.inverse_line_graph(H)
assert_true(nx.is_isomorphic(G, J))
示例12: test_line_inverse_line_path
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_line_inverse_line_path(self):
G = nx.path_graph(10)
H = nx.line_graph(G)
J = nx.inverse_line_graph(H)
assert_true(nx.is_isomorphic(G, J))
示例13: test_line_inverse_line_hypercube
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_line_inverse_line_hypercube(self):
G = nx.hypercube_graph(5)
H = nx.line_graph(G)
J = nx.inverse_line_graph(H)
assert_true(nx.is_isomorphic(G, J))
示例14: test_line_inverse_line_cycle
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_line_inverse_line_cycle(self):
G = nx.cycle_graph(10)
H = nx.line_graph(G)
J = nx.inverse_line_graph(H)
assert_true(nx.is_isomorphic(G, J))
示例15: test_line_inverse_line_multipartite
# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import line_graph [as 别名]
def test_line_inverse_line_multipartite(self):
G = nx.complete_multipartite_graph(3, 4, 5)
H = nx.line_graph(G)
J = nx.inverse_line_graph(H)
assert_true(nx.is_isomorphic(G, J))