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_indexand removes its duplicated entries. Duplicate entries inedge_attrare merged by scattering them together according to the givenreduceoption.- 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 + 1ofedge_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_indexto be already sorted row-wise.sort_by_row (bool, optional) – If set to
False, will sortedge_indexcolumn-wise.
- Returns:
(
LongTensor,TensororList[Tensor]])- Return type:
LongTensorifedge_attrisNone, else