mindspore_gl.BatchedGraphField
- class mindspore_gl.BatchedGraphField(src_idx=None, dst_idx=None, n_nodes=None, n_edges=None, ver_subgraph_idx=None, edge_subgraph_idx=None, graph_mask=None, indices=None, indptr=None, indices_backward=None, indptr_backward=None, csr=False)[source]
The data container for a batched graph.
The edge information are stored in COO format.
- Parameters
src_idx (Tensor, optional) – A tensor with shape \((N\_EDGES)\), with int dtype, represents the source node index of COO edge matrix. Default:
None
.dst_idx (Tensor, optional) – A tensor with shape \((N\_EDGES)\), with int dtype, represents the destination node index of COO edge matrix. Default:
None
.n_nodes (int, optional) – An integer, represent the nodes count of the graph. Default:
None
.n_edges (int, optional) – An integer, represent the edges count of the graph. Default:
None
.ver_subgraph_idx (Tensor, optional) – A tensor with shape \((N\_NODES)\), with int dtype, indicates each node belonging to which subgraph. Default:
None
.edge_subgraph_idx (Tensor, optional) – A tensor with shape \((N\_EDGES,)\), with int dtype, indicates each edge belonging to which subgraph. Default:
None
.graph_mask (Tensor, optional) – A tensor with shape \((N\_GRAPHS,)\), with int dtype, indicates whether the subgraph is exist. Default:
None
.indices (Tensor, optional) – A tensor with shape \((N\_EDGES)\), with int dtype, represents the indices of CSR edge matrix. Default:
None
.indptr (Tensor, optional) – A tensor with shape \((N\_NODES)\), with int dtype, represents the indptr of CSR edge matrix. Default:
None
.indices_backward (Tensor, optional) – A tensor with shape \((N\_EDGES)\), with int dtype, represents the indices backward of CSR edge matrix. Default:
None
.indptr_backward (Tensor, optional) – A tensor with shape \((N\_NODES)\), with int dtype, represents the indptr backward of CSR edge matrix. Default:
None
.csr (bool, optional) – Is the graph is CSR type. Default:
False
.
- Supported Platforms:
Ascend
GPU
Examples
>>> import mindspore as ms >>> from mindspore_gl import BatchedGraphField >>> n_nodes = 9 >>> n_edges = 11 >>> src_idx = ms.Tensor([0, 2, 2, 3, 4, 5, 5, 6, 8, 8, 8], ms.int32) >>> dst_idx = ms.Tensor([1, 0, 1, 5, 3, 4, 6, 4, 8, 8, 8], ms.int32) >>> ver_subgraph_idx = ms.Tensor([0, 0, 0, 1, 1, 1, 1, 2, 2], ms.int32) >>> edge_subgraph_idx = ms.Tensor([0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2], ms.int32) >>> graph_mask = ms.Tensor([1, 1, 0], ms.int32) >>> batched_graph_field = BatchedGraphField(src_idx, dst_idx, n_nodes, n_edges, ... ver_subgraph_idx, edge_subgraph_idx, graph_mask) >>> print(batched_graph_field.get_batched_graph()) [Tensor(shape=[11], dtype=Int32, value= [0, 2, 2, 3, 4, 5, 5, 6, 8, 8, 8]), Tensor(shape=[11], dtype=Int32, value= [1, 0, 1, 5, 3, 4, 6, 4, 8, 8, 8]), 9, 11, Tensor(shape=[9], dtype=Int32, value= [0, 0, 0, 1, 1, 1, 1, 2, 2]), Tensor(shape=[11], dtype=Int32, value= [0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2]), Tensor(shape=[3], dtype=Int32, value= [1, 1, 0])]