Graph Convolutional Network (GCN)
A simple graph layer that takes a normalised average of the representations of a node and its neighbours and then applies a shared linear transformation; it is a first-order approximation of spectral convolution.
Overview
| Name | Graph Convolutional Network |
|---|---|
| Year introduced | 2017 |
| Researchers | Thomas N. Kipf, Max Welling |
| Institution | University of Amsterdam |
| Original paper | Semi-supervised classification with graph convolutional networks arXiv |
| Data type | Graphs |
| Domains | Recommender systems, Scientific computing, Social network analysis, Learning on graph data |
| Computational cost | $O(|E|d)$ per layer with sparse matrices. |
| Data size | A single graph with thousands to millions of nodes. |
Problem it solves
Spectral convolution on graphs was costly (it requires the eigendecomposition of the Laplacian). Semi-supervised node classification needed an efficient layer that scales to large graphs.
Background and evolution
What came before: Graph Neural Network, Spectral CNNs, ChebNet
- 2017
Kipf and Welling introduced the GCN layer for semi-supervised node classification at ICLR 2017. [ref]
Core idea
A self-loop is added to each node ($\tilde A=A+I$), then the adjacency matrix is symmetrically normalised by degree, so the new representation is a weighted average of the node and its neighbours, followed by a linear transformation and then an activation.
Interactive diagram
A simplified illustrative diagram with the dimensions of a small example, not a drawing matching every detail of the original implementation. Click any layer to see its role, dimensions and mathematical operation.
Select a layer in the diagram.
Components
| Component | Role |
|---|---|
| Input | Features $X\in\mathbb{R}^{N\times d}$ and an adjacency matrix $A$ |
| Self-loops | $\tilde A=A+I$ |
| Normalization | $\tilde D^{-1/2}\tilde A\tilde D^{-1/2}$ |
| Linear transform | A shared weight $W$ |
| Activation | ReLU |
| Output | Softmax for each node |
Equations
1. GCN propagation rule
| $H^{(l)}$ | Node representations at layer l |
| $W^{(l)}$ | Shared weight |
| $\tilde D$ | Degree matrix after adding the loops |
2. Single-node form
| $\tilde d_v$ | Node degree after the self-loop |
How it works, step by step
- Self-loops are added and the normalisation matrix is computed once.
- The features are multiplied by the weight and then by the normalised adjacency matrix.
- ReLU and Dropout are applied.
- The second layer gives the class scores.
- The loss is computed on the labelled nodes only.
Strengths and limitations
Strengths
- Simple, fast and light on parameters.
- A strong baseline for node classification.
Limitations
- Neighbour weights are fixed (by degree), not learned.
- Transductive in its original form.
- Its performance drops on heterophilous graphs.
When to use it, and when not?
Good for
- Node classification in homophilous graphs (neighbours are similar).
Not suited for
- Graphs where neighbours usually belong to different classes; try GAT or heterophily models.
Applications
| Domain | Use |
|---|---|
| Learning on graph data | Classifying nodes, links and whole graphs. |
| Recommender systems | Recommender systems that represent users and items as a bipartite graph. |
| Scientific computing | Predicting molecular properties in computational chemistry. |
| Fraud detection | Fraud detection in financial transaction networks. |
| Social network analysis | Social network analysis and community detection. |
PyTorch code
A simplified teaching code sample that runs on small synthetic data, covering: imports, model definition, data, forward pass, loss, optimizer, training loop, evaluation and inference. It is not the paper's full implementation.
# Graph Convolutional Network (GCN)
# A simplified educational example in PyTorch (not the paper's full original implementation): small synthetic data,
# runs on the CPU in seconds. The numbers it prints belong to this example only.
# 1) Import the libraries
import torch
import torch.nn as nn
import torch.nn.functional as F
torch.manual_seed(0)
# 2) Define the model
def normalize(A):
A_hat = A + torch.eye(A.shape[0]) # Ã = A + I
d = A_hat.sum(1)
D_inv_sqrt = torch.diag(d.pow(-0.5))
return D_inv_sqrt @ A_hat @ D_inv_sqrt # D̃^{-1/2} Ã D̃^{-1/2}
class GCN(nn.Module):
def __init__(self, d_in, d_hidden=16, n_classes=3, p=0.5):
super().__init__()
self.W1, self.W2, self.p = nn.Linear(d_in, d_hidden), nn.Linear(d_hidden, n_classes), p
def forward(self, X, A_norm):
H = F.relu(A_norm @ self.W1(X))
H = F.dropout(H, self.p, self.training)
return A_norm @ self.W2(H)
# 3) Prepare the data
# A synthetic graph from a stochastic block model (SBM): 3 communities, more links inside than between
N, C, D = 150, 3, 8
y = torch.arange(N) % C
P = torch.where(y[:, None] == y[None, :], 0.12, 0.01)
A = (torch.rand(N, N) < P).float().triu(1); A = A + A.T # a symmetric adjacency matrix without loops
X = torch.randn(N, D) + 0.6 * F.one_hot(y, D).float() # weak-signal features; the structure helps
idx = torch.randperm(N); train_idx, test_idx = idx[:45], idx[45:] # only 30% labelled (semi-supervised)
A_norm = normalize(A)
model = GCN(D)
# 4) Loss function and optimizer
loss_fn = nn.CrossEntropyLoss()
opt = torch.optim.Adam(model.parameters(), lr=1e-2, weight_decay=5e-4)
# 5) Training loop (full-batch: the whole graph at each step, with the loss on the labelled nodes only)
for epoch in range(120):
model.train()
out = model(X, A_norm) # forward pass for all nodes
loss = loss_fn(out[train_idx], y[train_idx])
opt.zero_grad(); loss.backward(); opt.step()
if epoch % 30 == 0:
print(f"epoch {epoch:3d} loss={loss.item():.4f}")
# 6) Evaluation on the unlabelled nodes
model.eval()
with torch.no_grad():
pred = model(X, A_norm).argmax(1)
print(f"test accuracy = {(pred[test_idx] == y[test_idx]).float().mean().item():.3f}")
# 7) Inference: the class of node 0
print("node 0 predicted community:", pred[0].item(), " true:", y[0].item())
This code was run on 2026-11-20 in 3.1 seconds (PyTorch (CPU), Python 3 – local build machine).
Sample output:
test accuracy = 0.952
Trainable parameters in the example: model = 195.
These results are for small synthetic data and few epochs, and only prove that the code runs; do not compare them with published results.
Try it and go deeper
- Graph Network Explorer
- AI Model Atlas Another section of the site
- Graph Neural Networks Lab Another section of the site
Related architectures
Graph Attention Network
Graph Attention Network (GAT)
It replaces GCN's fixed weights with learned attention coefficients for each edge, so each node decides how important each neighbour is, with multiple attention heads.
GraphSAGE
GraphSAGE
An inductive framework that learns aggregation functions over a sampled neighbourhood, so it can compute representations for new nodes the network did not see during tra…
Graph Isomorphism Network
Graph Isomorphism Network (GIN)
A GNN designed to reach the discriminative power of the Weisfeiler–Lehman test (1-WL), using sum aggregation and an MLP in the update.
Graph Neural Network
Graph Neural Network (GNN)
A family of models that learn a representation for each node by exchanging messages with its neighbours along the edges, combining node features with graph structure.
No results match the filters.
Research ideas
- Evaluate GCN against GAT and GraphSAGE on heterophilous Arabic graphs (for example, tweet networks) with multiple splits.
Starting suggestions, not confirmed research gaps; review the recent literature before adopting them.
Test your understanding
Why are self-loops $A+I$ added in GCN?
Why? Without them the new representation depends on the neighbours only.
In a graph of two connected nodes, what is the normalisation matrix $\tilde D^{-1/2}\tilde A\tilde D^{-1/2}$?
Why? The degree after the loop is 2 for each node, so each entry is $1/\sqrt{2\cdot2}=0.5$.
What is the main limitation of GCN compared with GAT?
Why? GAT learns attention coefficients for each edge.
References
Kipf, T. N., & Welling, M. (2017). Semi-supervised classification with graph convolutional networks. International Conference on Learning Representations (ICLR). https://arxiv.org/abs/1609.02907
Wu, Z., Pan, S., Chen, F., Long, G., Zhang, C., & Yu, P. S. (2021). A comprehensive survey on graph neural networks. IEEE Transactions on Neural Networks and Learning Systems, 32(1), 4–24. https://doi.org/10.1109/TNNLS.2020.2978386
