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โ€™))