class AddSelfLoops(attr: str = 'edge_weight', fill_value: Union[float, Tensor, str] = 1.0)[source]

Bases: BaseTransform

Adds self-loops to the given homogeneous or heterogeneous graph (functional name: add_self_loops).

  • attr (str, optional) – The name of the attribute of edge weights or multi-dimensional edge features to pass to torch_geometric.utils.add_self_loops(). (default: "edge_weight")

  • fill_value (float or Tensor or str, optional) – The way to generate edge features of self-loops (in case attr != None). If given as float or torch.Tensor, edge features of self-loops will be directly given by fill_value. If given as str, edge features of self-loops are computed by aggregating all features of edges that point to the specific node, according to a reduce operation. ("add", "mean", "min", "max", "mul"). (default: 1.)