Skip to content

Commit c5ce119

Browse files
authored
Updating docs (#1448)
* added Hungarian to api.rst * fixed missing examples * fixed syntax Authors: - Brad Rees (@BradReesWork) Approvers: - Rick Ratzel (@rlratzel) - Alex Fender (@afender) URL: #1448
1 parent a7c4ebd commit c5ce119

File tree

12 files changed

+142
-70
lines changed

12 files changed

+142
-70
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ As of Release 0.18 - including 0.18 nightly
8686
| | Renumbering | Single-GPU | multiple columns, any data type |
8787
| | Symmetrize | Multi-GPU | |
8888
| Other | | | |
89-
| | Hungarian Algorithm | Single-GPU | |
9089
| | Minimum Spanning Tree | Single-GPU | |
9190
| | Maximum Spanning Tree | Single-GPU | |
9291
| | |

docs/source/api.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ Katz Centrality
4848
:undoc-members:
4949

5050

51+
Katz Centrality (MG)
52+
--------------------
53+
54+
.. automodule:: cugraph.dask.centrality.katz_centrality
55+
:members:
56+
:undoc-members:
57+
5158
Community
5259
=========
5360

@@ -86,6 +93,14 @@ Louvain
8693
:members:
8794
:undoc-members:
8895

96+
Louvain (MG)
97+
------------
98+
99+
.. automodule:: cugraph.dask.community.louvain
100+
:members:
101+
:undoc-members:
102+
103+
89104
Spectral Clustering
90105
-------------------
91106

@@ -148,6 +163,17 @@ Force Atlas 2
148163
:undoc-members:
149164

150165

166+
Linear Assignment
167+
=================
168+
169+
Hungarian
170+
-------------
171+
172+
.. automodule:: cugraph.linear_assignment.hungarian
173+
:members:
174+
:undoc-members:
175+
176+
151177
Link Analysis
152178
=============
153179

@@ -165,6 +191,13 @@ Pagerank
165191
:members:
166192
:undoc-members:
167193

194+
Pagerank (MG)
195+
---------
196+
197+
.. automodule:: cugraph.dask.link_analysis.pagerank
198+
:members: pagerank
199+
:undoc-members:
200+
168201

169202
Link Prediction
170203
===============
@@ -202,13 +235,27 @@ Breadth-first-search
202235
:members:
203236
:undoc-members:
204237

238+
Breadth-first-search (MG)
239+
--------------------
240+
241+
.. automodule:: cugraph.dask.traversal.bfs
242+
:members:
243+
:undoc-members:
244+
205245
Single-source-shortest-path
206246
---------------------------
207247

208248
.. automodule:: cugraph.traversal.sssp
209249
:members:
210250
:undoc-members:
211251

252+
Single-source-shortest-path (MG)
253+
---------------------------
254+
255+
.. automodule:: cugraph.dask.traversal.sssp
256+
:members:
257+
:undoc-members:
258+
212259

213260
Tree
214261
=========
@@ -227,3 +274,18 @@ Maximum Spanning Tree
227274
:members:
228275
:undoc-members:
229276

277+
278+
DASK MG Helper functions
279+
===========================
280+
281+
.. automodule:: cugraph.comms.comms
282+
:members: initialize
283+
:undoc-members:
284+
285+
.. automodule:: cugraph.comms.comms
286+
:members: destroy
287+
:undoc-members:
288+
289+
.. automodule:: cugraph.dask.common.read_utils
290+
:members: get_chunksize
291+
:undoc-members:

docs/source/dask-cugraph.rst

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,41 @@ With cuGraph and Dask, whether you’re using a single NVIDIA GPU or multiple no
1313

1414
If your graph comfortably fits in memory on a single GPU, you would want to use the single-GPU version of cuGraph. If you want to distribute your workflow across multiple GPUs and have more data than you can fit in memory on a single GPU, you would want to use cuGraph's multi-GPU features.
1515

16+
Example
17+
========
1618

17-
Distributed Graph Algorithms
18-
----------------------------
19+
.. code-block:: python
1920
20-
.. automodule:: cugraph.dask.link_analysis.pagerank
21-
:members: pagerank
22-
:undoc-members:
21+
from dask.distributed import Client, wait
22+
from dask_cuda import LocalCUDACluster
23+
import cugraph.comms as Comms
24+
import cugraph.dask as dask_cugraph
2325
24-
.. automodule:: cugraph.dask.traversal.bfs
25-
:members: bfs
26-
:undoc-members:
26+
cluster = LocalCUDACluster()
27+
client = Client(cluster)
28+
Comms.initialize(p2p=True)
2729
30+
# Helper function to set the reader chunk size to automatically get one partition per GPU
31+
chunksize = dask_cugraph.get_chunksize(input_data_path)
2832
29-
Helper functions
30-
----------------
33+
# Multi-GPU CSV reader
34+
e_list = dask_cudf.read_csv(input_data_path,
35+
chunksize = chunksize,
36+
delimiter=' ',
37+
names=['src', 'dst'],
38+
dtype=['int32', 'int32'])
3139
32-
.. automodule:: cugraph.comms.comms
33-
:members: initialize
34-
:undoc-members:
40+
G = cugraph.DiGraph()
41+
G.from_dask_cudf_edgelist(e_list, source='src', destination='dst')
3542
36-
.. automodule:: cugraph.comms.comms
37-
:members: destroy
38-
:undoc-members:
43+
# now run PageRank
44+
pr_df = dask_cugraph.pagerank(G, tol=1e-4)
3945
40-
.. automodule:: cugraph.dask.common.read_utils
41-
:members: get_chunksize
42-
:undoc-members:
46+
# All done, clean up
47+
Comms.destroy()
48+
client.close()
49+
cluster.close()
4350
44-
Consolidation
45-
=============
4651
47-
cuGraph can transparently interpret the Dask cuDF Dataframe as a regular Dataframe when loading the edge list. This is particularly helpful for workflows extracting a single GPU sized edge list from a distributed dataset. From there any existing single GPU feature will just work on this input.
52+
|
4853
49-
For instance, consolidation allows leveraging Dask cuDF CSV reader to load file(s) on multiple GPUs and consolidate this input to a single GPU graph. Reading is often the time and memory bottleneck, with this feature users can call the Multi-GPU version of the reader without changing anything else.
50-
51-
Batch Processing
52-
================
53-
54-
cuGraph can leverage multi GPUs to increase processing speed for graphs that fit on a single GPU, providing faster analytics on such graphs.
55-
You will be able to use the Graph the same way as you used to in a Single GPU environment, but analytics that support batch processing will automatically use the GPUs available to the dask client.
56-
For example, Betweenness Centrality scores can be slow to obtain depending on the number of vertices used in the approximation. Thank to Multi GPUs Batch Processing,
57-
you can create Single GPU graph as you would regularly do it using cuDF CSV reader, enable Batch analytics on it, and obtain scores much faster as each GPU will handle a sub-set of the sources.
58-
In order to use Batch Analytics you need to set up a Dask Cluster and Client in addition to the cuGraph communicator, then you can simply call `enable_batch()` on you graph, and algorithms supporting batch processing will use multiple GPUs.
59-
60-
Algorithms supporting Batch Processing
61-
--------------------------------------
62-
.. automodule:: cugraph.centrality
63-
:members: betweenness_centrality
64-
:undoc-members:
65-
:noindex:
66-
67-
.. automodule:: cugraph.centrality
68-
:members: edge_betweenness_centrality
69-
:undoc-members:
70-
:noindex:

python/cugraph/bsp/traversal/bfs_bsp.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -11,7 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
14+
import warnings
1515
import cudf
1616
from collections import OrderedDict
1717

@@ -59,6 +59,12 @@ def bfs_df_pregel(_df, start, src_col='src', dst_col='dst', copy_data=True):
5959
6060
"""
6161

62+
warnings.warn(
63+
"This feature is deprecated and will be"
64+
"dropped from cuGraph in release 0.20.",
65+
FutureWarning,
66+
)
67+
6268
# extract the src and dst into a dataframe that can be modified
6369
if copy_data:
6470
coo_data = _df[[src_col, dst_col]]

python/cugraph/community/egonet.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ def ego_graph(G, n, radius=1, center=True, undirected=False, distance=None):
7474
G_ego : cuGraph.Graph or networkx.Graph
7575
A graph descriptor with a minimum spanning tree or forest.
7676
The networkx graph will not have all attributes copied over
77+
78+
Examples
79+
--------
80+
>>> M = cudf.read_csv('datasets/karate.csv',
81+
delimiter = ' ',
82+
dtype=['int32', 'int32', 'float32'],
83+
header=None)
84+
>>> G = cugraph.Graph()
85+
>>> G.from_cudf_edgelist(M, source='0', destination='1')
86+
>>> ego_graph = cugraph.ego_graph(G, seed, radius=2)
87+
7788
"""
7889

7990
(G, input_type) = ensure_cugraph_obj(G, nx_weight_attr="weight")

python/cugraph/components/connectivity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -378,7 +378,7 @@ def connected_components(G,
378378
header=None)
379379
>>> G = cugraph.Graph()
380380
>>> G.from_cudf_edgelist(M, source='0', destination='1', edge_attr=None)
381-
>>> df = cugraph.strongly_connected_components(G)
381+
>>> df = cugraph.connected_components(G, connection="weak")
382382
"""
383383
if connection == "weak":
384384
return weakly_connected_components(G, directed,

python/cugraph/dask/centrality/katz_centrality.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -115,7 +115,8 @@ def katz_centrality(input_graph,
115115
Examples
116116
--------
117117
>>> import cugraph.dask as dcg
118-
>>> Comms.initialize(p2p=True)
118+
>>> ... Init a DASK Cluster
119+
>> see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
119120
>>> chunksize = dcg.get_chunksize(input_data_path)
120121
>>> ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize,
121122
delimiter=' ',
@@ -125,7 +126,6 @@ def katz_centrality(input_graph,
125126
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
126127
edge_attr='value')
127128
>>> pr = dcg.katz_centrality(dg)
128-
>>> Comms.destroy()
129129
"""
130130

131131
nstart = None

python/cugraph/dask/community/louvain.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -55,7 +55,8 @@ def louvain(input_graph, max_iter=100, resolution=1.0):
5555
Examples
5656
--------
5757
>>> import cugraph.dask as dcg
58-
>>> Comms.initialize(p2p=True)
58+
>>> ... Init a DASK Cluster
59+
>> see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
5960
>>> chunksize = dcg.get_chunksize(input_data_path)
6061
>>> ddf = dask_cudf.read_csv('datasets/karate.csv', chunksize=chunksize,
6162
delimiter=' ',

python/cugraph/dask/link_analysis/pagerank.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -105,7 +105,8 @@ def pagerank(input_graph,
105105
Examples
106106
--------
107107
>>> import cugraph.dask as dcg
108-
>>> Comms.initialize(p2p=True)
108+
>>> ... Init a DASK Cluster
109+
>> see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
109110
>>> chunksize = dcg.get_chunksize(input_data_path)
110111
>>> ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize,
111112
delimiter=' ',
@@ -115,7 +116,6 @@ def pagerank(input_graph,
115116
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
116117
edge_attr='value')
117118
>>> pr = dcg.pagerank(dg)
118-
>>> Comms.destroy()
119119
"""
120120
from cugraph.structure.graph import null_check
121121

python/cugraph/dask/traversal/bfs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
1+
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -76,7 +76,8 @@ def bfs(graph,
7676
Examples
7777
--------
7878
>>> import cugraph.dask as dcg
79-
>>> Comms.initialize(p2p=True)
79+
>>> ... Init a DASK Cluster
80+
>> see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
8081
>>> chunksize = dcg.get_chunksize(input_data_path)
8182
>>> ddf = dask_cudf.read_csv(input_data_path, chunksize=chunksize,
8283
delimiter=' ',
@@ -85,7 +86,6 @@ def bfs(graph,
8586
>>> dg = cugraph.DiGraph()
8687
>>> dg.from_dask_cudf_edgelist(ddf, 'src', 'dst')
8788
>>> df = dcg.bfs(dg, 0)
88-
>>> Comms.destroy()
8989
"""
9090

9191
client = default_client()

0 commit comments

Comments
 (0)