gammagl.utils.coalesce

class coalesce(edge_index, edge_attr=None, num_nodes=None, reduce='add', is_sorted=False, sort_by_row=True)[source]

Row-wise sorts edge_index and removes its duplicated entries. Duplicate entries in edge_attr are merged by scattering them together according to the given reduce option.

Parameters:
  • edge_index (tensor) – The edge indices.

  • edge_attr (tensor, list[tensor], optional) – Edge weights or multi- dimensional edge features. If given as a list, will re-shuffle and remove duplicates for all its entries. (default: None)

  • num_nodes (int, optional) – The number of nodes, i.e. max_val + 1 of edge_index. (default: None)

  • reduce (str, optional) – The reduce operation to use for merging edge features ("add", "mean", "min", "max", "mul"). (default: "add")

  • is_sorted (bool, optional) – If set to True, will expect edge_index to be already sorted row-wise.

  • sort_by_row (bool, optional) – If set to False, will sort edge_index column-wise.

Returns:

(LongTensor, Tensor or List[Tensor]])

Return type:

LongTensor if edge_attr is None, else