gammagl.utils.to_undirected¶
- class to_undirected(edge_index, edge_attr=None, num_nodes=None, reduce: str = 'add')[source]¶
Converts the graph given by
edge_indexto an undirected graph such that \((j,i) \in \mathcal{E}\) for every edge \((i,j) \in \mathcal{E}\).- 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 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")
- Return type:
LongTensorifedge_attrisNone, else (LongTensor,TensororList[Tensor]])