當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python NetworkX average_clustering用法及代碼示例

本文簡要介紹 networkx.algorithms.approximation.clustering_coefficient.average_clustering 的用法。

用法:

average_clustering(G, trials=1000, seed=None)

估計 G 的平均聚類係數。

G 中每個節點的局部聚類是實際存在於其鄰域內所有可能三角形中的三角形的分數。圖G的平均聚類係數是局部聚類的平均值。

該函數通過重複 n 次(在 trials 中定義)以下實驗來找到 G 的近似平均聚類係數:隨機選擇一個節點,隨機選擇其兩個鄰居,並檢查它們是否相連。近似係數是在多次試驗中找到的三角形的分數 [1]。

參數

GNetworkX 圖
trials整數

要執行的試驗次數(默認 1000)。

seed整數、random_state 或無(默認)

隨機數生成狀態的指示符。請參閱隨機性。

返回

c浮點數

近似的平均聚類係數。

參考

1

Schank, Thomas, and Dorothea Wagner. Approximating clustering coefficient and transitivity. Universität Karlsruhe, Fakultät für Informatik, 2004. https://doi.org/10.5445/IR/1000001239

例子

>>> from networkx.algorithms import approximation
>>> G = nx.erdos_renyi_graph(10, 0.2, seed=10)
>>> approximation.average_clustering(G, trials=1000, seed=10)
0.214

相關用法


注:本文由純淨天空篩選整理自networkx.org大神的英文原創作品 networkx.algorithms.approximation.clustering_coefficient.average_clustering。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。