用法:
immediate_dominators(G, start)
返回有向图的所有节点的直接支配者。
- G:DiGraph 或 MultiDiGraph
要计算支配地位的图表。
- start:节点
优势计算的起始节点。
- idom:由节点键入的字典
包含从
start
可到达的每个节点的直接支配者的字典。
- NetworkXNotImplemented
如果
G
是无向的。- NetworkXError
如果
start
不在G
中。
参数:
返回:
抛出:
注意:
除了
start
之外,直接支配者是支配树中相应节点的父级。参考:
- 1
K. D. Cooper, T. J. Harvey, and K. Kennedy. A simple, fast dominance algorithm. Software Practice & Experience, 4:110, 2001.
例子:
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 5), (3, 4), (4, 5)]) >>> sorted(nx.immediate_dominators(G, 1).items()) [(1, 1), (2, 1), (3, 1), (4, 3), (5, 1)]
相关用法
- Python networkx.algorithms.dominance.dominance_frontiers用法及代码示例
- Python networkx.algorithms.dag.all_topological_sorts用法及代码示例
- Python networkx.algorithms.dag.dag_longest_path_length用法及代码示例
- Python networkx.algorithms.dag.topological_generations用法及代码示例
- Python networkx.algorithms.dag.dag_to_branching用法及代码示例
- Python networkx.algorithms.dag.antichains用法及代码示例
- Python networkx.algorithms.dag.ancestors用法及代码示例
- Python networkx.algorithms.dag.transitive_closure用法及代码示例
- Python networkx.algorithms.dag.lexicographical_topological_sort用法及代码示例
- Python networkx.algorithms.distance_regular.is_distance_regular用法及代码示例
- Python networkx.algorithms.dag.descendants用法及代码示例
- Python networkx.algorithms.distance_regular.global_parameters用法及代码示例
- Python networkx.algorithms.distance_regular.is_strongly_regular用法及代码示例
- Python networkx.algorithms.distance_regular.intersection_array用法及代码示例
- Python networkx.algorithms.dag.topological_sort用法及代码示例
- Python networkx.algorithms.dag.transitive_reduction用法及代码示例
- Python networkx.algorithms.dag.dag_longest_path用法及代码示例
- Python networkx.algorithms.dag.transitive_closure_dag用法及代码示例
- Python networkx.algorithms.dag.is_directed_acyclic_graph用法及代码示例
- Python networkx.algorithms.dag.is_aperiodic用法及代码示例
注:本文由纯净天空筛选整理自networkx.org大神的英文原创作品 networkx.algorithms.dominance.immediate_dominators。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。