torch_geometric.transforms.VirtualNode

class VirtualNode[source]

Bases: BaseTransform

Appends a virtual node to the given homogeneous graph that is connected to all other nodes, as described in the “Neural Message Passing for Quantum Chemistry” paper (functional name: virtual_node). The virtual node serves as a global scratch space that each node both reads from and writes to in every step of message passing. This allows information to travel long distances during the propagation phase.

Node and edge features of the virtual node are added as zero-filled input features. Furthermore, special edge types will be added both for in-coming and out-going information to and from the virtual node.