cugraph.Graph.from_cudf_adjlist#

Graph.from_cudf_adjlist(offset_col, index_col, value_col=None, renumber=True, store_transposed=False)[source]#

Initialize a graph from the adjacency list. It is an error to call this method on an initialized Graph object. The passed offset_col and index_col arguments wrap gdf_column objects that represent a graph using the adjacency list format. If value_col is None, an unweighted graph is created. If value_col is not None, a weighted graph is created. Undirected edges must be stored as directed edges in both directions.

Parameters:
offset_colcudf.Series

This cudf.Series wraps a gdf_column of size V + 1 (V: number of vertices). The gdf column contains the offsets for the vertices in this graph. Offsets must be in the range [0, E] (E: number of edges)

index_colcudf.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 in the range [0, V) (V: number of vertices).

value_colcudf.Series, optional (default=None)

This pointer can be None. If not, this cudf.Series wraps a gdf_column of size E (E: number of edges). The gdf column contains the weight value for each edge. The expected type of the gdf_column element is floating point number.

renumberbool, optional (default=True)

Indicate whether or not to renumber the source and destination vertex IDs.

store_transposedbool, optional (default=False)

If True, stores the transpose of the adjacency matrix. Required for certain algorithms.

Examples

>>> gdf = cudf.read_csv(datasets_path / 'karate.csv', delimiter=' ',
...                     dtype=['int32', 'int32', 'float32'],
...                     header=None)
>>> M = gdf.to_pandas()
>>> M = scipy.sparse.coo_matrix((M['2'],(M['0'],M['1'])))
>>> M = M.tocsr()
>>> offsets = cudf.Series(M.indptr)
>>> indices = cudf.Series(M.indices)
>>> G = cugraph.Graph()
>>> G.from_cudf_adjlist(offsets, indices, None)