cugraph.from_adjlist#
- cugraph.from_adjlist(offsets, indices, values=None, create_using=<class 'cugraph.structure.graph_classes.Graph'>)[source]#
Initializes the graph from cuDF or Pandas Series representing adjacency matrix CSR data and returns a new cugraph.Graph object.
- Parameters:
- offsetscudf.Series, pandas.Series
The offsets of a CSR adjacency matrix.
- indicescudf.Series, pandas.Series
The indices of a CSR adjacency matrix.
- valuescudf.Series or pandas.Series, optional (default=None)
The values in a CSR adjacency matrix, which represent edge weights in a graph. If not provided, the resulting graph is considered unweighted.
- create_using: cugraph.Graph (instance or class), optional (default=Graph)
Specify the type of Graph to create. Can pass in an instance to create a Graph instance with specified ‘directed’ attribute.
Examples
>>> pdf = pd.read_csv(datasets_path / 'karate.csv', delimiter=' ', ... dtype={0:'int32', 1:'int32', 2:'float32'}, ... header=None) >>> M = scipy.sparse.coo_matrix((pdf[2],(pdf[0],pdf[1]))) >>> M = M.tocsr() >>> offsets = pd.Series(M.indptr) >>> indices = pd.Series(M.indices) >>> G = cugraph.from_adjlist(offsets, indices, None)