What SignedConv does
SignedConv applies balance theory to graph neural networks:
- Separate the graph into positive edges and negative edges
- Aggregate separately from positive and negative neighbors
- Combine the two aggregations to produce node representations that capture both trust and distrust patterns
The math (simplified)
# Separate aggregation for positive and negative neighbors
h_i^+ = AGG_pos({ h_j : j in N_pos(i) }) # friends
h_i^- = AGG_neg({ h_j : j in N_neg(i) }) # enemies
# Balance theory-informed combination
z_i = CONCAT(
W_1 · h_i^+ + W_2 · h_i^-, # positive representation
W_3 · h_i^+ + W_4 · h_i^- # negative representation
)
Where:
N_pos(i) = positive neighbors (trust, friend)
N_neg(i) = negative neighbors (distrust, enemy)
W_1..W_4 = learnable weight matricesFour weight matrices capture the four balance theory patterns: friend-of-friend, friend-of-enemy, enemy-of-friend, enemy-of-enemy.
PyG implementation
import torch
import torch.nn.functional as F
from torch_geometric.nn import SignedConv
class SignedGCN(torch.nn.Module):
def __init__(self, in_channels, hidden, out_channels):
super().__init__()
self.conv1 = SignedConv(in_channels, hidden, first_aggr=True)
self.conv2 = SignedConv(hidden, out_channels, first_aggr=False)
def forward(self, x, pos_edge_index, neg_edge_index):
x = self.conv1(x, pos_edge_index, neg_edge_index)
x = F.relu(x)
x = self.conv2(x, pos_edge_index, neg_edge_index)
return x
# Separate positive and negative edges
model = SignedGCN(in_channels=64, hidden=32, out_channels=16)
# pos_edge_index: edges where sign = +1
# neg_edge_index: edges where sign = -1
out = model(x, pos_edge_index, neg_edge_index)first_aggr=True for the first layer (handles input features). first_aggr=False for subsequent layers (handles already-split positive/negative representations).
When to use SignedConv
- Link sign prediction. Predicting whether a future interaction will be positive (trust) or negative (distrust) in social networks.
- Polarization analysis. Detecting communities in politically polarized networks, debate forums, or product review ecosystems.
- Fraud detection with negative signals. Chargebacks, complaints, and returns are negative signals that complement positive purchase history. SignedConv models both.
When not to use SignedConv
- Unsigned graphs. If all edges are positive (standard social networks, citation graphs), SignedConv adds unnecessary complexity. Use GCNConv or GATConv.
- Multi-type edges beyond binary sign. If you have more than two edge types (not just positive/negative), use RGCNConv or HGTConv for full heterogeneous support.