minimum_cycle_basis#
- minimum_cycle_basis(G, weight=None)[source]#
返回图 G 的最小权重环基
最小权重意味着所有环的总权重(对于无权图是长度)最小的环基。
- Parameters:
- GNetworkX 图
- weight: 字符串
用于边权重的边属性名称
- Returns:
- 一个环列表。每个环列表是一个形成环(循环)的节点列表。注意,节点不一定按其在环中出现的顺序返回。
See also
Examples
>>> G = nx.Graph() >>> nx.add_cycle(G, [0, 1, 2, 3]) >>> nx.add_cycle(G, [0, 3, 4, 5]) >>> nx.minimum_cycle_basis(G) [[5, 4, 3, 0], [3, 2, 1, 0]]
- 参考文献:
[1] Kavitha, Telikepalli, et al. “An O(m^2n) Algorithm for Minimum Cycle Basis of Graphs.” http://link.springer.com/article/10.1007/s00453-007-9064-z [2] de Pina, J. 1995. Applications of shortest path methods. Ph.D. thesis, University of Amsterdam, Netherlands