inverse_line_graph#
- inverse_line_graph(G)[来源]#
返回图 G 的逆线图。
如果 H 是一个图,且 G 是 H 的线图,使得 G = L(H)。那么 H 是 G 的逆线图。
并非所有图都是线图,这些图没有逆线图。在这些情况下,此函数会引发 NetworkXError。
- 参数:
- G图
一个 NetworkX 图
- 返回:
- H图
G 的逆线图。
- 抛出:
- NetworkXNotImplemented
如果 G 是有向图或多重图
- NetworkXError
如果 G 不是线图
注意
这是 Roussopoulos 算法 [R90abc5507a69-1]_ 的实现。
如果 G 包含多个连通分量,则该算法不起作用。您应该分别对每个连通分量进行逆运算
>>> K5 = nx.complete_graph(5) >>> P4 = nx.Graph([("a", "b"), ("b", "c"), ("c", "d")]) >>> G = nx.union(K5, P4) >>> root_graphs = [] >>> for comp in nx.connected_components(G): ... root_graphs.append(nx.inverse_line_graph(G.subgraph(comp))) >>> len(root_graphs) 2
参考文献
[1]Roussopoulos, N.D. , “A max {m, n} algorithm for determining the graph H from its line graph G”, Information Processing Letters 2, (1973), 108–112, ISSN 0020-0190, DOI 链接