pylibcugraphops.make_bipartite_csc_hg#

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

from the tensors defining it.

make_bipartite_csc_hg(
    offsets: device array, indices: device array, n_node_types: int,
    n_edge_types: int, node_types: device array, edge_types: device array,
    map_csc_to_coo: Optional[device array]
) -> pylibcugraphops.bipartite_csc_hg_int[32|64]
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_node_typesint

Number of node types in the graph.

n_edge_typesint

Number of edge types in the graph.

node_typesdevice array type

Node types of each node in the graph.

edge_typesdevice array type

Edge types of each edge in the graph. Follows the same indexing as ‘indices’.

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 CSR, 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_hg
>>>
>>> cupy.random.seed(0)
>>> n_src_nodes = 25
>>> n_dst_nodes = 15
>>> avg_deg = 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)
>>>
>>> n_node_types = 3
>>> n_edge_types = 7
>>> src_node_types = cupy.random.randint(0, n_node_types, n_src_nodes, dtype=cupy.int32)
>>> dst_node_types = cupy.random.randint(0, n_node_types, n_dst_nodes, dtype=cupy.int32)
>>> edge_types = cupy.random.randint(0, n_edge_types, indices.shape[0], dtype=cupy.int32)
>>>
>>> graph = make_bipartite_csc_hg(offsets, indices, n_src_nodes,
...     n_node_types, n_edge_types, src_node_types, dst_node_types, edge_types)
>>> # call aggregator with `graph` here