torch_geometric.transforms.ToUndirected

class ToUndirected(reduce: str = 'add', merge: bool = True)[source]

Bases: BaseTransform

Converts a homogeneous or heterogeneous graph to an undirected graph such that \((j,i) \in \mathcal{E}\) for every edge \((i,j) \in \mathcal{E}\) (functional name: to_undirected). In heterogeneous graphs, will add “reverse” connections for all existing edge types.

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

  • merge (bool, optional) – If set to False, will create reverse edge types for connections pointing to the same source and target node type. If set to True, reverse edges will be merged into the original relation. This option only has effects in HeteroData graph data. (default: True)