mindspore_gl.HeterGraphField

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

The data container for a heterogeneous graph. The edge information are stored in COO format.

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

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

  • n_nodes (List[int]) – A list of integer, represent the nodes count of the graph.

  • n_edges (List[int]) – A list of integer, represent the edges count of the graph.

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore as ms
>>> from mindspore_gl import HeterGraphField
>>> n_nodes = [9, 2]
>>> n_edges = [11, 1]
>>> src_idx = [ms.Tensor([0, 2, 2, 3, 4, 5, 5, 6, 8, 8, 8], ms.int32), ms.Tensor([0], ms.int32)]
>>> dst_idx = [ms.Tensor([1, 0, 1, 5, 3, 4, 6, 4, 8, 8, 8], ms.int32), ms.Tensor([1], ms.int32)]
>>> heter_graph_field = HeterGraphField(src_idx, dst_idx, n_nodes, n_edges)
>>> print(heter_graph_field.get_heter_graph())
[[Tensor(shape=[11], dtype=Int32, value= [0, 2, 2, 3, 4, 5, 5, 6, 8, 8, 8]),
Tensor(shape=[1], dtype=Int32, value= [0])],
[Tensor(shape=[11], dtype=Int32, value= [1, 0, 1, 5, 3, 4, 6, 4, 8, 8, 8]),
Tensor(shape=[1], dtype=Int32, value= [1])], [9, 2], [11, 1]]
get_heter_graph()[source]

Get the hetergenous Graph.

Returns

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