支配前沿#
- dominance_frontiers(G, start)[source]#
返回有向图中所有节点的支配前沿。
- 参数:
- GDiGraph 或 MultiDiGraph
用于计算支配的图。
- start节点
支配计算的起始节点。
- 返回:
- df以节点为键的字典
一个字典,包含从
start
可达的每个节点的支配前沿列表。
- 引发:
- NetworkXNotImplemented
如果
G
是无向图。- NetworkXError
如果
start
不在G
中。
参考文献
[1]Cooper, Keith D., Harvey, Timothy J. and Kennedy, Ken. “A simple, fast dominance algorithm.” (2006). https://hdl.handle.net/1911/96345
示例
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 5), (3, 4), (4, 5)]) >>> sorted((u, sorted(df)) for u, df in nx.dominance_frontiers(G, 1).items()) [(1, []), (2, [5]), (3, [5]), (4, [5]), (5, [])]