dgl.from_cugraph

dgl.from_cugraph(cugraph_graph)[source]

Create a graph from a cugraph.Graph object.

Parameters

cugraph_graph (cugraph.Graph) –

The cugraph graph object holding the graph structure. Node and edge attributes are dropped.

If the input graph is undirected, DGL converts it to a directed graph by cugraph.Graph.to_directed().

Returns

The created graph.

Return type

DGLGraph

Examples

The following example uses PyTorch backend.

>>> import dgl
>>> import cugraph
>>> import cudf

Create a cugraph graph. >>> cugraph_g = cugraph.Graph(directed=True) >>> df = cudf.DataFrame({“source”:[0, 1, 2, 3],

“destination”:[1, 2, 3, 0]})

>>> cugraph_g.from_cudf_edgelist(df)

Convert it into a DGLGraph >>> g = dgl.from_cugraph(cugraph_g) >>> g.edges() (tensor([1, 2, 3, 0], device=’cuda:0’), tensor([2, 3, 0, 1], device=’cuda:0’))