cugraph.Graph.from_cudf_edgelist#

Graph.from_cudf_edgelist(input_df, source='source', destination='destination', edge_attr=None, weight=None, edge_id=None, edge_type=None, renumber=True, store_transposed=False, symmetrize=None, vertices=None)[source]#

Initialize a graph from the edge list. It is an error to call this method on an initialized Graph object. The passed input_df argument wraps gdf_column objects that represent a graph using the edge list format. source argument is source column name and destination argument is destination column name. By default, renumbering is enabled to map the source and destination vertices into an index in the range [0, V) where V is the number of vertices. If the input vertices are a single column of integers in the range [0, V), renumbering can be disabled and the original external vertex ids will be used. If weights are present, edge_attr argument is the weights column name.

Parameters:
input_dfcudf.DataFrame or dask_cudf.DataFrame

A DataFrame that contains edge information If a dask_cudf.DataFrame is passed it will be reinterpreted as a cudf.DataFrame. For the distributed path please use from_dask_cudf_edgelist.

sourcestr or array-like, optional (default=’source’)

source column name or array of column names

destinationstr or array-like, optional (default=’destination’)

destination column name or array of column names

edge_attrstr or List[str], optional (default=None)

Names of the edge attributes. Can either be a single string representing the weight column name, or a list of length 3 holding [weight, edge_id, edge_type]. If this argument is provided, then the weight/edge_id/edge_type arguments must be left empty.

weightstr, optional (default=None)

Name of the weight column in the input dataframe.

edge_idstr, optional (default=None)

Name of the edge id column in the input dataframe.

edge_typestr, optional (default=None)

Name of the edge type column in the input dataframe.

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.

symmetrize: bool, optional (default=None)

If True, symmetrize the edge list for an undirected graph. Setting this flag to True for a directed graph returns an error. The default behavior symmetrizes the edges if the graph is undirected. This flag cannot be set to True if the edgelist contains edge IDs or edge Types. If the incoming edgelist is intended for an undirected graph and it is known to be symmetric, this flag can be set to False to skip the symmetrization step for better performance.

verticescudf.Series or List, optional (default=None)

A cudf.Series or list containing all vertices of the graph. This is optional, but must be used if the graph contains isolated vertices which cannot be represented in the source and destination arrays. If specified, this array must contain every vertex identifier, including vertex identifiers that are already included in the source and destination arrays.

Examples

>>> df = cudf.read_csv(datasets_path / 'karate.csv', delimiter=' ',
...                    dtype=['int32', 'int32', 'float32'],
...                    header=None)
>>> G = cugraph.Graph()
>>> G.from_cudf_edgelist(df, source='0', destination='1',
...                      edge_attr='2', renumber=False)