all_pairs_node_connectivity#
- all_pairs_node_connectivity(G, nbunch=None, flow_func=None)[source]#
计算图 G 中所有节点对之间的节点连通性。
- Parameters:
- GNetworkX 图
无向图
- nbunch: 容器
节点容器。如果提供,将仅计算 nbunch 中节点对之间的节点连通性。
- flow_func函数
用于计算一对节点之间最大流的函数。该函数必须至少接受三个参数:一个有向图、一个源节点和一个目标节点,并返回遵循 NetworkX 约定的残余网络(详见
maximum_flow()
)。如果 flow_func 为 None,则使用默认的最大流函数(edmonds_karp()
)。详见下文。默认函数的选取可能会随版本变化,不应依赖于此。默认值:None。
- Returns:
- all_pairs字典
包含 G 中所有节点对之间节点连通性的字典,如果提供了 nbunch,则仅包含 nbunch 中的节点对。
See also
local_node_connectivity()
edge_connectivity()
local_edge_connectivity()
maximum_flow()
edmonds_karp()
preflow_push()
shortest_augmenting_path()
Additional backends implement this function
- parallelParallel backend for NetworkX algorithms
The parallel implementation first divides a list of all permutation (in case of directed graphs) and combinations (in case of undirected graphs) of
nbunch
into chunks and then creates a generator to lazily compute the local node connectivities for each chunk, and then employs joblib’sParallel
function to execute these computations in parallel across all available CPU cores. At the end, the results are aggregated into a single dictionary and returned.- Additional parameters:
- get_chunksstr, function (default = “chunks”)
A function that takes in
list(iter_func(nbunch, 2))
as input and returns an iterablepairs_chunks
, hereiter_func
ispermutations
in case of directed graphs andcombinations
in case of undirected graphs. The default is to create chunks by slicing the list inton
chunks, wheren
is the number of CPU cores, such that size of each chunk is atmost 10, and at least 1.
[Source]