- Year
- 2017–2018 (major variants)
- Type
- Deep learning on graph-structured data
What does it do?
A Graph Neural Network (GNN) is a deep learning architecture that operates directly on graph-structured data, combining node features with structural information through repeated neighborhood message passing.
The three variants covered here differ in how they aggregate neighbor information. The Graph Convolutional Network (GCN), introduced by Kipf and Welling (2017), applies a first-order approximation of spectral graph convolution using a normalized adjacency matrix. The Graph Attention Network (GAT), introduced by Veličković et al. (2018), weights each neighbor by a learned attention coefficient. GraphSAGE samples fixed-size neighborhoods and learns an aggregation function that can be applied to nodes unseen during training.
The intuition behind the method
Think of every node in a graph as a person in a social network. That person has their own profile (features), but who they know also says a lot about them. A GNN lets each node repeatedly collect messages from its neighbors, mix those messages with its own information, and update its representation — layer by layer. After a few rounds of this gossip-style exchange, each node's embedding reflects not just itself but the local subgraph around it. GCN does this with a fixed symmetric average of neighbors; GAT decides which neighbors to trust more by learning attention weights; GraphSAGE samples a fixed subset of neighbors and learns an aggregation function that can be applied to nodes it has never seen before.
History
Graph Convolutional Networks were introduced by Kipf and Welling, published at ICLR 2017; the work was first posted as an arXiv preprint in 2016, which is the date carried by its arXiv record. They simplified spectral graph convolution into an efficient first-order approximation based on a symmetrically normalized adjacency matrix. Veličković et al. (2018, ICLR) introduced Graph Attention Networks, replacing GCN's fixed neighbor averaging with learned attention coefficients on each edge. GraphSAGE is the inductive, sampling-based variant that learns an aggregation function applicable to nodes not seen during training. Hamilton's 2020 book, Graph Representation Learning, provides a general reference on the field.
When to use it
Use a GNN when the relationships between entities carry predictive signal and your data already has that structure, such as social or citation networks, molecular graphs, or knowledge graphs. You need a node feature matrix and an edge list (or adjacency matrix). A rough guideline is a minimum of around 50 nodes for meaningful training; graphs with fewer than 20 nodes are better analyzed with conventional centrality metrics. These figures are rules of thumb rather than fixed limits: the appropriate size depends on feature dimensionality, the number of labels, and the prediction task. The prediction task determines the output head: node classification, link prediction, or graph classification. Standard GCN and GAT rely on homophily, where connected nodes tend to share labels, so for heterophilic graphs consider architectures designed for that setting. For large graphs where full-batch training is memory-prohibitive, use mini-batch neighborhood sampling in the GraphSAGE style.
Limitations and considerations
- Over-smoothing: stacking many GNN layers pushes node embeddings toward a common value and can reduce performance; shallow models, often with two layers, are a common starting point.
- Scalability: full-batch GCN and GAT require holding the entire adjacency matrix and feature matrix in memory, which is infeasible for very large graphs without sampling or partitioning.
- The homophily assumption built into standard aggregation degrades performance on heterophilic graphs, where neighbors tend to have different labels.
- Very small graphs give the model little structure to learn from, so results on graphs below the rule-of-thumb size of around 50 nodes should be treated with caution.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Combines node attributes and graph topology in one model, so a prediction can draw on both a node's own features and the features of its neighborhood.
- GAT's per-edge attention coefficients show how much weight each neighbor received during aggregation, which helps inspect the model; these weights should not be read as causal importance.
- GraphSAGE learns an aggregation function rather than fixed node-specific embeddings, so it can compute representations for nodes and subgraphs absent from training, which suits growing networks.
- The same message-passing backbone is reused for node classification, link prediction, and graph classification, with only the task head changing.
Applications
- Node classification in citation networks — predicting the topic of a paper based on its content and citation links.
- Drug discovery — predicting molecular properties by treating atoms as nodes and chemical bonds as edges.
- Recommender systems — modeling users and items as a bipartite graph and predicting user-item interactions via link prediction.
- Fraud detection in financial transaction networks — identifying anomalous nodes based on their features and neighborhood structure.
- Knowledge graph completion — inferring missing relations between entities in large-scale knowledge bases.
How it works
How it works
The graph is defined by a node feature matrix X (one row per node, one column per attribute) and an edge list (or adjacency matrix) A. Undirected edges are standard for GCN and GAT; GraphSAGE also supports directed graphs. Self-loops are typically added to A so each node is included in its own aggregation.
Raw node attributes are normalized and, if necessary, embedded into a continuous vector space. Edge attributes, if present, can be incorporated as additional signals. The result is a dense feature matrix that each GNN layer will transform.
Each GNN layer computes a new node representation by aggregating the features of a node's neighbors and combining them with the node's own features through a learnable weight matrix and a non-linear activation. GCN applies a normalized adjacency multiplication (spectral convolution); GAT computes softmax attention coefficients for each edge so influential neighbors contribute more; GraphSAGE randomly samples a fixed-size neighborhood and applies a differentiable aggregator (mean, LSTM, or pooling). Stacking L layers lets information flow L hops away, but stacking many layers can cause over-smoothing, where node embeddings become increasingly similar and lose discriminative information.
The final node embeddings are fed into a task-specific head. For node classification a softmax layer assigns class probabilities to each node. For link prediction an inner product or MLP scores the likelihood of an edge between two node embeddings. For graph classification a global pooling (sum, mean, or hierarchical) aggregates all node embeddings into a single graph-level vector before the classification layer.
Model performance is measured on a held-out test set using metrics appropriate to the task: accuracy or F1 for node and graph classification, AUC-ROC for link prediction. Check class balance before reading accuracy, because a majority-class predictor can score well on skewed labels; macro-F1 or AUC-ROC gives a fairer picture in that case. Choose the split so that it matches the deployment scenario. In transductive evaluation, where training, validation, and test nodes share one graph, make sure no test labels influence training, including through label-derived features or hyperparameter selection on the test set. For link prediction, hide the test edges before message passing so that the model cannot see the edges it is asked to predict; otherwise the score is inflated by leakage. Inductive splits, where whole subgraphs are held out, are the stricter test of generalization to unseen nodes. Because graph datasets are often small, run each configuration over several random seeds and report the mean and spread rather than a single run. Finally, compare the GNN against a feature-only baseline (such as a multilayer perceptron or logistic regression on node attributes) and against a simple propagation baseline. If the GNN does not clearly outperform these, the graph structure may contribute little to the task.
Common pitfalls
- Adding layers beyond a shallow depth can make node embeddings converge; monitor the variance of embeddings across nodes as depth increases, and tune depth on validation data.
- Training on the full graph without mini-batching can exhaust memory on large networks; switch to neighbor sampling or graph partitioning once the graph outgrows available memory.
- A standard GCN's learned weights are tied to a fixed graph structure. New nodes require the graph to be re-processed and the model may need retraining, so an inductive method such as GraphSAGE is the better fit when unseen nodes must be scored.
- Ignoring the homophily assumption on heterophilic graphs produces poor results; inspect the graph's assortativity coefficient before choosing a standard GNN variant.
- With fewer than 20 nodes GNN training is unlikely to yield reliable representations; prefer conventional network centrality analysis in that regime.
Frequently asked questions
Which GNN variant should I start with — GCN, GAT, or GraphSAGE?
GCN is the simplest baseline and works well on small-to-medium homophilic graphs where all nodes are known at training time. GAT is preferable when neighbor importance varies and you want interpretable attention weights. GraphSAGE is the right choice when you need to generalize to nodes unseen during training or when the graph is too large for full-batch processing.
What is over-smoothing and how do I avoid it?
Over-smoothing occurs when many GNN layers cause node embeddings to converge toward a common value, reducing discriminative information. Shallow models, often with two layers, are a common starting point, and the best depth depends on the dataset, so it should be tuned on validation data. Techniques such as residual connections, jumping knowledge networks, and DropEdge can help if deeper architectures are necessary.
Do GNNs require labeled data for all nodes?
No. GCN and GAT are commonly used in semi-supervised settings where only a small fraction of nodes carry labels; the graph structure propagates information from labeled to unlabeled nodes. GraphSAGE can also be trained in a fully supervised or unsupervised manner depending on the task.
How large does the graph need to be?
A rough guideline is a minimum of around 50 nodes for meaningful GNN training. Graphs with fewer than 20 nodes are better analyzed with centrality-based methods. These figures are rules of thumb: the required size depends on feature dimensionality, the number of labels, and the task. For very large graphs, mini-batch neighbor sampling (as in GraphSAGE) or graph partitioning keeps memory usage manageable.
Related methods
Sources
Kipf, T.N. & Welling, M. (2017). Semi-Supervised Classification with Graph Convolutional Networks. International Conference on Learning Representations (ICLR).
Open DOI referenceVeličković, P., Cucurull, G., Casanova, A., Romero, A., Liò, P., & Bengio, Y. (2018). Graph Attention Networks. International Conference on Learning Representations (ICLR).
Open DOI referenceHamilton, W.L. (2020). Graph Representation Learning. Morgan & Claypool.
Open DOI reference