Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Review] Add some python documentation #247

Merged
merged 2 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- PR #203 Added small datasets directly in the repo
- PR #215 Simplified get_rapids_dataset_root_dir(), set a default value for the root dir
- PR #233 Added csv datasets and edited test to use cudf for reading graphs
- PR #247 Added some documentation for renumbering

## Bug Fixes
- PR #226 Bump cudf dependencies to 0.7
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
/* ----------------------------------------------------------------------------*/

/**
* @Synopsis Renumber source and destination indexes to be a dense numbering
* between 0 and number of vertices minus 1.
* @Synopsis Renumber source and destination indexes to be a dense numbering,
* using contiguous values between 0 and number of vertices minus 1.
*
* Assumptions:
* * source and dest have same size and type
Expand Down
45 changes: 45 additions & 0 deletions python/cugraph/graph/c_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,51 @@ class Graph:
free(g)

def renumber(self, source_col, dest_col):
"""
Take a (potentially sparse) set of source and destination vertex
ids and renumber the vertices to create a dense set of vertex ids
using all values contiguously from 0 to the number of unique vertices
- 1.

Input columns can be either int64 or int32. The output will be mapped
to int32, since many of the cugraph functions are limited to int32.
If the number of unique values in source_col and dest_col > 2^31-1
then this function will return an error.

Return from this call will be three cudf Series - the renumbered
source_col, the renumbered dest_col and a numbering map that maps the
new ids to the original ids.

Parameters
----------
source_col : cudf.Series
This cudf.Series wraps a gdf_column of size E (E: number of edges).
The gdf column contains the source index for each edge.
Source indices must be an integer type.
dest_col : cudf.Series
This cudf.Series wraps a gdf_column of size E (E: number of edges).
The gdf column contains the destination index for each edge.
Destination indices must be an integer type.

Examples
--------
>>> import numpy as np
>>> import pytest
>>> from scipy.io import mmread
>>>
>>> import cudf
>>> import cugraph
>>>
>>>
>>> mm_file = '../datasets/karate.mtx'
>>> M = mmread(mm_file).asfptype()
>>> sources = cudf.Series(M.row)
>>> destinations = cudf.Series(M.col)
>>>
>>> G = cugraph.Graph()
>>> src_r, dst_r, numbering = G.renumber(sources, destinations)
"""

cdef gdf_column src_renumbered
cdef gdf_column dst_renumbered
cdef gdf_column numbering_map
Expand Down