mindspore_gl.GraphField

class mindspore_gl.GraphField(src_idx, dst_idx, n_nodes, n_edges)[source]

The data container for a graph.

The edge information are stored in COO format.

Parameters
  • src_idx (Tensor) – A tensor with shape \((N\_EDGES)\), with int dtype, represents the source node index of COO edge matrix.

  • dst_idx (Tensor) – A tensor with shape \((N\_EDGES)\), with int dtype, represents the destination node index of COO edge matrix.

  • n_nodes (int) – An integer, represent the nodes count of the graph.

  • n_edges (int) – An integer, represent the edges count of the graph.

Supported Platforms:

GPU

Examples

>>> import mindspore as ms
>>> from mindspore_gl import GraphField
>>> 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)
>>> graph_field = GraphField(src_idx, dst_idx, n_nodes, n_edges)
get_graph()[source]

Get the Graph.

Returns

List, A list of tensor, which should be used for construct function.