networkx.algorithms.approximation.kcomponents.k_components
的用法。用法:
k_components(G, min_density=0.95)
返回圖 G 的近似 k-component 結構。
k
- 組件是圖 G 的最大子圖,它至少具有節點連接性k
:我們需要至少刪除k
節點才能將其分解為更多組件。k
- 組件具有固有的層次結構,因為它們在連接性方麵是嵌套的:連接圖可以包含多個 2 組件,每個組件都可以包含一個或多個 3 組件,依此類推。此實現基於快速啟發法來近似圖的
k
組件結構 [1]。反過來,它基於快速近似算法,用於找到兩個節點之間的節點獨立路徑數量的良好下界 [2]。- G:NetworkX 圖
無向圖
- min_density:Float
密度鬆弛閾值。默認值 0.95
- k_components:dict
以連接級別
k
作為鍵的字典和形成級別k
的 k-component 作為值的節點集列表。
- NetworkXNotImplemented
如果 G 是有向的。
參數:
返回:
拋出:
注意:
用於計算
k
組件結構 [1] 的近似算法的邏輯基於對k
核心和雙連通組件重複應用簡單而快速的算法,以縮小我們所使用的節點對的數量。必須計算 White 和 Newman 的近似算法來查找節點獨立路徑 [2]。更正式地說,該算法基於惠特尼定理,該定理規定了任何圖 G 的節點連通性、邊連通性和最小度之間的包含關係。該定理意味著每個k
組件都嵌套在k
邊內- 組件,而該組件又包含在k
核心中。因此,該算法計算每個k
核心的每個雙連通部分中的節點對之間的節點獨立路徑,並對每個k
從 3 到輸入圖中節點的最大核心數重複此過程。因為在實踐中,一個雙分量內的
k
級核心的許多節點實際上是k級分量的一部分,因此算法所需的輔助圖可能非常密集。因此,我們使用補圖數據結構(參見AntiGraph
)來節省內存。 AntiGraph 僅存儲實際輔助圖中存在的not
邊的信息。當將算法應用於此補圖數據結構時,它的行為就好像它是密集版本一樣。參考:
- 1(1,2)
Torrents, J. and F. Ferraro (2015) Structural Cohesion: Visualization and Heuristics for Fast Computation. https://arxiv.org/pdf/1503.04476v1
- 2(1,2)
White, Douglas R., and Mark Newman (2001) A Fast Algorithm for Node-Independent Paths. Santa Fe Institute Working Paper #01-07-035 https://www.santafe.edu/research/results/working-papers/fast-approximation-algorithms-for-finding-node-ind
- 3
Moody, J. and D. White (2003). Social cohesion and embeddedness: A hierarchical conception of social groups. American Sociological Review 68(1), 103-28. https://doi.org/10.2307/3088904
例子:
>>> # Petersen graph has 10 nodes and it is triconnected, thus all >>> # nodes are in a single component on all three connectivity levels >>> from networkx.algorithms import approximation as apxa >>> G = nx.petersen_graph() >>> k_components = apxa.k_components(G)
相關用法
- Python NetworkX k_clique_communities用法及代碼示例
- Python NetworkX k_edge_components用法及代碼示例
- Python NetworkX k_edge_augmentation用法及代碼示例
- Python NetworkX k_edge_subgraphs用法及代碼示例
- Python NetworkX katz_centrality用法及代碼示例
- Python NetworkX kamada_kawai_layout用法及代碼示例
- Python NetworkX katz_centrality_numpy用法及代碼示例
- Python NetworkX kosaraju_strongly_connected_components用法及代碼示例
- Python NetworkX karate_club_graph用法及代碼示例
- Python NetworkX negative_edge_cycle用法及代碼示例
- Python NetworkX voronoi_cells用法及代碼示例
- Python NetworkX numerical_edge_match用法及代碼示例
- Python NetworkX inverse_line_graph用法及代碼示例
- Python NetworkX LFR_benchmark_graph用法及代碼示例
- Python NetworkX write_graph6用法及代碼示例
- Python NetworkX DiGraph.__contains__用法及代碼示例
- Python NetworkX average_degree_connectivity用法及代碼示例
- Python NetworkX eulerian_circuit用法及代碼示例
- Python NetworkX single_source_dijkstra_path_length用法及代碼示例
- Python NetworkX from_dict_of_dicts用法及代碼示例
- Python NetworkX weisfeiler_lehman_subgraph_hashes用法及代碼示例
- Python NetworkX transitive_closure_dag用法及代碼示例
- Python NetworkX intersection用法及代碼示例
- Python NetworkX MultiGraph.size用法及代碼示例
- Python NetworkX Graph.size用法及代碼示例
注:本文由純淨天空篩選整理自networkx.org大神的英文原創作品 networkx.algorithms.approximation.kcomponents.k_components。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。