class HalfHop(alpha: float = 0.5, p: float = 1.0)[source]

Bases: BaseTransform

The graph upsampling augmentation from the “Half-Hop: A Graph Upsampling Approach for Slowing Down Message Passing” paper. The graph is augmented by adding artificial slow nodes between neighbors to slow down message propagation. (functional name: half_hop).


HalfHop augmentation is not supported if data has edge_weight or edge_attr.

  • alpha (float, optional) – The interpolation factor used to compute slow node features \(x = \alpha*x_src + (1-\alpha)*x_dst\) (default: 0.5)

  • p (float, optional) – The probability of half-hopping an edge. (default: 1.0)

import torch_geometric.transforms as T

transform = T.HalfHop(alpha=0.5)
data = transform(data)  # Apply transformation.
out = model(data.x, data.edge_index)  # Feed-forward.
out = out[~data.slow_node_mask]  # Get rid of slow nodes.