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


Python cugraph.community.subgraph_extraction.subgraph用法及代碼示例

用法:

cugraph.community.subgraph_extraction.subgraph(G, vertices)

計算僅包含指定頂點的現有圖的子圖。該算法適用於有向圖和無向圖,並且實際上並不遍曆邊,而是簡單地拉出所有在頂點上的邊,這些邊都包含在頂點列表中。

參數

Gcugraph.Graph

cuGraph 圖說明符

verticescudf.Series 或 cudf.DataFrame

指定誘導子圖的頂點。對於multi-column 頂點,頂點應作為 cudf.DataFrame 提供

返回

Sgcugraph.Graph

包含由給定頂點集誘導的子圖的圖對象。

例子

>>> gdf = cudf.read_csv(datasets_path / 'karate.csv',
...                     delimiter = ' ',
...                     dtype=['int32', 'int32', 'float32'],
...                     header=None)
>>> G = cugraph.Graph()
>>> G.from_cudf_edgelist(gdf, source='0', destination='1')
>>> verts = np.zeros(3, dtype=np.int32)
>>> verts[0] = 0
>>> verts[1] = 1
>>> verts[2] = 2
>>> sverts = cudf.Series(verts)
>>> Sg = cugraph.subgraph(G, sverts)

相關用法


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