BasicGraph Neural Networks

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

NameGraph Convolutional Network
Year introduced2017
ResearchersThomas N. Kipf, Max Welling
InstitutionUniversity of Amsterdam
Original paperSemi-supervised classification with graph convolutional networks arXiv
Data typeGraphs
DomainsRecommender systems, Scientific computing, Social network analysis, Learning on graph data
Computational cost$O(|E|d)$ per layer with sparse matrices.
Data sizeA 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

  1. 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.

Example: In a scientific citation network, a paper whose topic we do not know is linked to papers on "reinforcement learning"; after two GCN layers its representation moves close to those papers, so the model predicts its topic.

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

ComponentRole
InputFeatures $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 transformA shared weight $W$
ActivationReLU
OutputSoftmax for each node

Equations

1. GCN propagation rule

$$H^{(l+1)}=\sigma\!\left(\tilde D^{-\frac12}\tilde A\tilde D^{-\frac12}H^{(l)}W^{(l)}\right),\quad \tilde A=A+I_N,\;\tilde D_{ii}=\sum_j\tilde A_{ij}$$

Symbols
$H^{(l)}$Node representations at layer l
$W^{(l)}$Shared weight
$\tilde D$Degree matrix after adding the loops
Dimensions
$H^{(l)}\in\mathbb{R}^{N\times d_l}$, $W^{(l)}\in\mathbb{R}^{d_l\times d_{l+1}}$
Numerical example
Two connected nodes: $\tilde A=\begin{pmatrix}1&1\\1&1\end{pmatrix}$, $\tilde D=2I$, so the normalisation gives $\begin{pmatrix}0.5&0.5\\0.5&0.5\end{pmatrix}$, i.e. the average of the two nodes.
Relation to the architecture
It determines how neighbour features are merged in each layer.

2. Single-node form

$$h_v^{(l+1)}=\sigma\!\left(\sum_{u\in\mathcal{N}(v)\cup\{v\}}\frac{1}{\sqrt{\tilde d_u\tilde d_v}}W^{(l)\top}h_u^{(l)}\right)$$

Symbols
$\tilde d_v$Node degree after the self-loop
Dimensions
$h_v\in\mathbb{R}^{d_{l+1}}$
Numerical example
A node of degree 2 with a neighbour of degree 4: weight coefficient $1/\sqrt{8}\approx0.354$.
Relation to the architecture
It shows that high-degree neighbours get a lower weight.

How it works, step by step

  1. Self-loops are added and the normalisation matrix is computed once.
  2. The features are multiplied by the weight and then by the normalised adjacency matrix.
  3. ReLU and Dropout are applied.
  4. The second layer gives the class scores.
  5. 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

DomainUse
Learning on graph dataClassifying nodes, links and whole graphs.
Recommender systemsRecommender systems that represent users and items as a bipartite graph.
Scientific computingPredicting molecular properties in computational chemistry.
Fraud detectionFraud detection in financial transaction networks.
Social network analysisSocial 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.

Python (PyTorch)
# 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

Related architectures

Intermediate2018

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.

Graph Neural Networks

Basic2017

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 Neural Networks

Intermediate2019

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 Networks

Basic2009

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.

Graph Neural Networks

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

  1. Mathematical

    Why are self-loops $A+I$ added in GCN?

  2. Mathematical

    In a graph of two connected nodes, what is the normalisation matrix $\tilde D^{-1/2}\tilde A\tilde D^{-1/2}$?

  3. Comparison

    What is the main limitation of GCN compared with GAT?

References

  1. 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

    arXivAutomatically verified via OpenAlex/arXiv – 2026-11-20

  2. 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

    DOIAutomatically verified via Crossref – 2026-11-20