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


Python cugraph.dask.community.louvain.louvain用法及代碼示例

用法:

cugraph.dask.community.louvain.louvain(input_graph, max_iter=100, resolution=1.0)

在多個 GPU 上使用 Louvain 方法計算輸入圖的模塊化優化分區

它使用如下所述的 Louvain 方法:

VD Blondel,J-L Guillaume、R Lambiotte 和 E Lefebvre:在大型網絡中快速展開社區層次結構,J Stat Mech P10008 (2008),http://arxiv.org/abs/0803.0476

參數

input_graphcugraph.Graph 或 NetworkX Graph

圖說明符應包含連接信息和權重。如果不存在鄰接列表,則將計算該鄰接列表。

max_iter整數,可選(默認=100)

這控製了 Louvain 算法的最大級別/迭代次數。當指定時,算法將在不超過指定的迭代次數後終止。當算法以這種方式提前終止時,不會發生錯誤。

resolution: float/double, optional (default=1.0)

在模塊化公式中稱為 gamma,這會改變社區的規模。更高的分辨率會導致更多的小型社區,更低的分辨率會導致更少的大型社區。默認為 1。

返回

partscudf.DataFrame

大小為 V 的 GPU 數據幀包含兩列,即頂點 id 和分配給它的分區 id。

df[‘vertex’]cudf.Series

包含頂點標識符

df[‘partition’]cudf.Series

包含分配給頂點的分區

modularity_score浮點數

一個浮點數,包含分區的全局模塊化分數。

例子

>>> # import cugraph.dask as dcg
>>> # ... Init a DASK Cluster
>>> #    see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> # chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> # ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize)
>>> # dg = cugraph.Graph(directed=True)
>>> # dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
>>> #                            edge_attr='value')
>>> # parts, modularity_score = dcg.louvain(dg)

相關用法


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