Berlin Tech Meetup: The Future of Relational Foundation Models, Systems, and Real-World Applications

Register now:
PyG/Layer8 min read

SignedConv: Learning on Graphs with Trust and Distrust

Not all edges are created equal, and not all are positive. SignedConv handles graphs where edges can be positive (trust, friendship) or negative (distrust, enmity), using balance theory to learn from both types of relationships.

PyTorch Geometric

TL;DR

  • 1SignedConv maintains separate aggregations for positive and negative neighbors. This captures social dynamics that standard GNNs miss: trust vs distrust, agree vs disagree.
  • 2Based on balance theory: friend of friend = friend, enemy of enemy = friend. SignedConv's dual representation naturally models these patterns.
  • 3Use for link sign prediction (trust/distrust), community detection in polarized networks, and fraud detection where negative signals matter.
  • 4Input: separate edge_index tensors for positive and negative edges. Output: concatenated positive and negative node representations.

Original Paper

Signed Graph Convolutional Network

Derr et al. (2018). ICDM 2018

Read paper →

What SignedConv does

SignedConv applies balance theory to graph neural networks:

  1. Separate the graph into positive edges and negative edges
  2. Aggregate separately from positive and negative neighbors
  3. Combine the two aggregations to produce node representations that capture both trust and distrust patterns

The math (simplified)

SignedConv formula
# 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 matrices

Four weight matrices capture the four balance theory patterns: friend-of-friend, friend-of-enemy, enemy-of-friend, enemy-of-enemy.

PyG implementation

signed_model.py
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.

Frequently asked questions

What is SignedConv in PyTorch Geometric?

SignedConv implements the Signed Graph Convolutional Network from Derr et al. (2018). It handles graphs with both positive edges (trust, friendship, agreement) and negative edges (distrust, enmity, disagreement) by maintaining separate aggregations for positive and negative neighbors.

What is a signed graph?

A signed graph has edges labeled as positive (+) or negative (-). Examples: trust/distrust in social networks (Epinions, Slashdot), friend/foe relationships in online platforms, agree/disagree in debate networks. The sign carries critical semantic information that standard GNNs ignore.

How does SignedConv handle positive and negative edges?

SignedConv maintains two separate representations per node: one aggregated from positive neighbors and one from negative neighbors. It applies balance theory: 'the friend of my friend is my friend' and 'the enemy of my enemy is my friend.' These two representations capture complementary social dynamics.

What is balance theory in signed graphs?

Balance theory states that certain triangle configurations are stable: (+,+,+) all friends, (+,-,-) my friend's enemy is my enemy. Unbalanced triangles (+,+,-) create social tension. SignedConv's separate aggregation of positive and negative neighbors captures these patterns naturally.

When should I use SignedConv?

Use SignedConv when your graph has meaningful positive and negative edges and you need to predict edge signs, classify nodes, or detect communities in signed networks. Common applications: link sign prediction (will this user trust or distrust?), fraud detection, political polarization analysis.

Learn more about graph ML

PyTorch Geometric is the open-source foundation for graph neural networks. Explore more layers, concepts, and production patterns.