pylibcugraphops.make_bipartite_csc#

pylibcugraphops.make_bipartite_csc = <nanobind.nb_func object>#
Creates a basic CSC graph representation for a bipartite graph

from the tensors defining it.

make_bipartite_csc(
    offsets: device array, indices: device array, n_src_nodes: int,
    map_csc_to_coo: Optional[device array]
) -> pylibcugraphops.bipartite_csc_int[32|64]
Parameters:
offsetsdevice array type

Monotonically increasing array with each location pointing to the start offset of the neighborhood of that node in the indices. It’s length is one more than the length of out_nodes.

indicesdevice array type

Contains the adjacency lists of all the out nodes.

n_src_nodesint

number of input nodes (equals max(indices) + 1)

map_csc_to_coodevice array type | None

Contains edge feature indices for each of the above edge, pointing to that row in the edge embedding table. This can be used to avoid having to reorder edge features when we sort edges while creating a compressed sparse representation, or apply other transformations on the graph structure.

Returns:
graph_csc

An opaque python object representing the bipartite graph to be used in aggregators.

Examples

>>> import cupy
>>> from pylibcugraphops import make_bipartite_csc
>>>
>>> cupy.random.seed(0)
>>> n_dst_nodes = 15
>>> n_src_nodes = 25
>>> avg_degree = 5
>>> fg_dtype = cupy.int32
>>> # use any distribution to generate n_edges (with non-negative values)
>>> n_edges = cupy.random.randint(0, 2 * avg_degree, n_src_nodes, dtype=fg_dtype)
>>> offsets = cupy.zeros(n_dst_nodes+1, dtype=fg_dtype)
>>> offsets[1:] = cupy.cumsum(n_edges)
>>> indices = cupy.random.randint(0, n_src_nodes, offsets[-1].item(), dtype=fg_dtype)
>>>
>>> graph = make_bipartite_csc(offsets, indices, n_src_nodes)
>>> # call aggregator with `graph` here