dgl.graphbolt.fused_csc_sampling_graph๏ƒ

dgl.graphbolt.fused_csc_sampling_graph(csc_indptr: Tensor, indices: Tensor, node_type_offset: tensor | None = None, type_per_edge: tensor | None = None, node_type_to_id: Dict[str, int] | None = None, edge_type_to_id: Dict[str, int] | None = None, node_attributes: Dict[str, tensor] | None = None, edge_attributes: Dict[str, tensor] | None = None) โ†’ FusedCSCSamplingGraph[source]๏ƒ

Create a FusedCSCSamplingGraph object from a CSC representation.

Parameters:
  • csc_indptr (torch.Tensor) โ€“ Pointer to the start of each row in the indices. An integer tensor with shape (total_num_nodes+1,).

  • indices (torch.Tensor) โ€“ Column indices of the non-zero elements in the CSC graph. An integer tensor with shape (total_num_edges,).

  • node_type_offset (Optional[torch.tensor], optional) โ€“ Offset of node types in the graph, by default None.

  • type_per_edge (Optional[torch.tensor], optional) โ€“ Type ids of each edge in the graph, by default None.

  • node_type_to_id (Optional[Dict[str, int]], optional) โ€“ Map node types to ids, by default None.

  • edge_type_to_id (Optional[Dict[str, int]], optional) โ€“ Map edge types to ids, by default None.

  • node_attributes (Optional[Dict[str, torch.tensor]], optional) โ€“ Node attributes of the graph, by default None.

  • edge_attributes (Optional[Dict[str, torch.tensor]], optional) โ€“ Edge attributes of the graph, by default None.

Returns:

The created FusedCSCSamplingGraph object.

Return type:

FusedCSCSamplingGraph

Examples

>>> ntypes = {'n1': 0, 'n2': 1, 'n3': 2}
>>> etypes = {'n1:e1:n2': 0, 'n1:e2:n3': 1}
>>> csc_indptr = torch.tensor([0, 2, 5, 7])
>>> indices = torch.tensor([1, 3, 0, 1, 2, 0, 3])
>>> node_type_offset = torch.tensor([0, 1, 2, 3])
>>> type_per_edge = torch.tensor([0, 1, 0, 1, 1, 0, 0])
>>> graph = graphbolt.fused_csc_sampling_graph(csc_indptr, indices,
...             node_type_offset=node_type_offset,
...             type_per_edge=type_per_edge,
...             node_type_to_id=ntypes, edge_type_to_id=etypes,
...             node_attributes=None, edge_attributes=None,)
>>> print(graph)
FusedCSCSamplingGraph(csc_indptr=tensor([0, 2, 5, 7]),
                 indices=tensor([1, 3, 0, 1, 2, 0, 3]),
                 total_num_nodes=3, total_num_edges=7)