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 inedge_attr
are merged by scattering them together according to the givenreduce
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
ofedge_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 expectedge_index
to be already sorted row-wise.sort_by_row (bool, optional) – If set to
False
, will sortedge_index
column-wise.
- Returns:
(
LongTensor
,Tensor
orList[Tensor]]
)- Return type:
LongTensor
ifedge_attr
isNone
, else