def to_cugraph(g):
    """Convert a DGL graph to a :class:`cugraph.Graph` and return.

    Parameters
    ----------
    g : DGLGraph
        A homogeneous graph.

    Returns
    -------
    cugraph.Graph
        The converted cugraph graph.

    Notes
    -----
    The function only supports GPU graph input.

    Examples
    --------
    The following example uses PyTorch backend.

    >>> import dgl
    >>> import cugraph
    >>> import torch

    >>> g = dgl.graph((torch.tensor([1, 2]), torch.tensor([1, 3]))).to('cuda')
    >>> cugraph_g = g.to_cugraph()
    >>> cugraph_g.edges()
        src  dst
    0    2    3
    1    1    1
    """

    if g.device.type != "cuda":
        raise DGLError(
            f"Cannot convert a {g.device.type} graph to cugraph."
            + "Call g.to('cuda') first."
        )
    if not g.is_homogeneous:
        raise DGLError("dgl.to_cugraph only supports homogeneous graphs.")

    try:
        import cudf
        import cugraph
    except ModuleNotFoundError:
        raise ModuleNotFoundError(
            "to_cugraph requires cugraph which could not be imported"
        )

    edgelist = g.edges()
    src_ser = cudf.from_dlpack(F.zerocopy_to_dlpack(edgelist[0]))
    dst_ser = cudf.from_dlpack(F.zerocopy_to_dlpack(edgelist[1]))
    cudf_data = cudf.DataFrame({"source": src_ser, "destination": dst_ser})
    g_cugraph = cugraph.Graph(directed=True)
    g_cugraph.from_cudf_edgelist(
        cudf_data, source="source", destination="destination"
    )
    return g_cugraph
Convert a DGL graph to a :class:`cugraph.Graph` and return.

    Parameters
    ----------
    g : DGLGraph
        A homogeneous graph.

    Returns
    -------
    cugraph.Graph
        The converted cugraph graph.

    Notes
    -----
    The function only supports GPU graph input.

    Examples
    --------
    The following example uses PyTorch backend.

    >>> import dgl
    >>> import cugraph
    >>> import torch

    >>> g = dgl.graph((torch.tensor([1, 2]), torch.tensor([1, 3]))).to('cuda')
    >>> cugraph_g = g.to_cugraph()
    >>> cugraph_g.edges()
        src  dst
    0    2    3
    1    1    1
    
python/dgl/convert.py