Back to Graph Theory Series

Part 26: Graph Machine Learning & Knowledge Graphs

September 20, 2026 Wasil Zafar 34 min read

Most machine learning assumes data arrives as a flat table of independent rows. Molecules, social networks, and knowledge bases refuse to fit that mold — they demand models that understand relationships as first-class citizens.

Table of Contents

  1. A Bit of History
  2. Why Graphs Need Different ML
  3. Graph Neural Networks
  4. Message Passing
  5. What Does a GNN Predict?
  6. Limits of Message Passing
  7. Knowledge Graphs
  8. Knowledge Graph Embeddings
  9. Real-World Applications
  10. Exercises
  11. Conclusion & Next Steps

A Bit of History

Franco Scarselli and colleagues introduced the foundational "Graph Neural Network Model" in a 2009 paper, formalizing how a neural network could operate directly on graph-structured input. The field accelerated dramatically after Thomas Kipf and Max Welling published "Semi-Supervised Classification with Graph Convolutional Networks" in 2017, introducing an efficient, scalable "graph convolutional network" (GCN) architecture that made graph neural networks practical at real scale. On the knowledge-graph side, Google's 2012 public announcement of its own "Knowledge Graph" product brought the decades-older idea of structured, graph-based knowledge representation into mainstream visibility, and Antoine Bordes and colleagues' 2013 "TransE" paper introduced one of the first widely-adopted knowledge graph embedding techniques.

Why Graphs Need Different Machine Learning

Ordinary machine-learning pipelines are happiest when every example has the same shape: one row with a fixed number of columns, one image on a fixed pixel grid, or one sequence with an explicit order. A graph breaks that regularity in three ways at once: its size can vary, each vertex can have a different number of neighbors, and those neighbors have no canonical left-to-right order. More importantly, the examples are not independent rows — the edges say which examples should influence one another.

Core Intuition Relational Data

Same Information, Very Different Geometry

Flat table fixed columns, row order is explicit rowx1x2label 10.82.1A 21.40.3B 30.21.7A 41.10.9B Rows do not automatically say who is connected to whom. Graph neighbors define the computation ABCD Degree varies from vertex to vertex. There is no canonical neighbor order. Same graph, relabeled labels changed; structure did not v7v2v9v1 A graph model should not change its meaning because IDs were renamed.
Graph learning must respect structure, not arbitrary storage order or vertex IDs.

The mathematical version of that requirement is permutation symmetry. If we merely rename the vertices, node-level outputs should be renamed in exactly the same way (permutation equivariance), while a single graph-level prediction should stay unchanged (permutation invariance).

$$f_{\text{node}}(PAP^T,PX)=P\,f_{\text{node}}(A,X)$$ $$f_{\text{graph}}(PAP^T,PX)=f_{\text{graph}}(A,X)$$

Memory Hook: Relabel, Then Recompute

If changing vertex IDs changes the graph-level answer, the model has learned the bookkeeping rather than the graph. A graph-native architecture should care about who is connected to whom, not whether a vertex happened to be stored as row 3 or row 3003.

Graph Neural Networks

A Graph Neural Network (GNN) replaces the fixed receptive field of a CNN with a graph-defined receptive field: each vertex updates itself using information from its neighbors. The learned vector at vertex \(v\), usually written \(h_v\), is an embedding — a compact set of coordinates that the model learns because those coordinates are useful for the prediction task.

A useful way to think about a GNN layer is: look one hop farther, summarize what you saw, then revise your state. Stack two layers and a vertex can be influenced by vertices up to two hops away; stack \(k\) layers and its structural receptive field reaches up to \(k\) hops. That is similar to BFS layers, except the GNN is learning what information to propagate and how to combine it.

Visual Model One GNN Layer

Neighbors Send Evidence; the Target Updates

1. Collect messages 2. Aggregate 3. Update target u1u2u3v Each neighbor computes a message AGG sum / mean / max order-independent one neighborhood summary UPDATE old state of v + aggregated message new embedding h_v The same learned rules are reused at every vertex.
Message passing turns a variable-size neighborhood into a fixed-size learned representation.

Message Passing

The dominant modern framework writes each layer as two conceptual functions: a message function decides what one neighbor should send, and an update function decides how the receiving vertex should combine the neighborhood summary with its previous state. A generic layer can be written as:

$$m_v^{(\ell)}=\operatorname{AGG}_{u\in N(v)} M_\ell\!\left(h_v^{(\ell)},h_u^{(\ell)},e_{uv}\right)$$ $$h_v^{(\ell+1)}=U_\ell\!\left(h_v^{(\ell)},m_v^{(\ell)}\right)$$

The crucial word is AGG. Sum, mean, max, attention-with-symmetric pooling, and similar constructions do not depend on the order in which neighbors are listed. Shared message/update functions plus a permutation-invariant aggregator produce the desired permutation-equivariant node computation.

Key Insight: Symmetric Aggregation Is the Relabeling Guarantee

If a vertex has neighbors \(\{a,b,c\}\), the model should get the same neighborhood summary whether the data structure presents them as \((a,b,c)\), \((c,a,b)\), or any other ordering. The graph has a set of neighbors, not a meaningful sequence of neighbors.

How the Receptive Field Grows

Stacking layers expands who can influence the target v 1 layer1-hop context v 2 layersup to 2 hops v 3 layersup to 3 hops
Depth controls structural reach: after \(k\) message-passing layers, information can potentially arrive from vertices up to \(k\) hops away.

What Does a GNN Predict?

Once embeddings have been computed, the final prediction head depends on the unit you care about. Graph machine learning is not one task; it is a family of tasks that differ mainly in where the output lives.

Node-level one output per vertex Example: classify one accountas fraud / not fraud Edge / link-level one output per pair or edge predict? Example: will these users connect?link prediction Graph-level one output for the whole graph POOL + PREDICT Example: molecule toxicity
Node embeddings can feed node predictions directly, combine in pairs for link predictions, or be pooled into one graph embedding for whole-graph prediction.
$$h_G=\operatorname{READOUT}\left(\{h_v:v\in V\}\right)$$

The graph-level READOUT must also be permutation-invariant — common choices are sum, mean, max, or learned pooling. Training then looks familiar: make predictions, compare them with known targets using a loss function, and use backpropagation to adjust the message, update, and prediction parameters.

Limits of Message Passing

GNNs are powerful, but “more layers” is not automatically better. The same compression that makes message passing scalable also creates characteristic failure modes.

Additional Context Modern GNN Limits

Two Ways Information Can Degrade

Oversmoothing deep mixing can make node states too similar early layers: distinct embeddings many layers: harder to distinguish Oversquashing too much distant information through a narrow channel bottletarget many remote signals must fit into fixed-size messages
Depth expands structural reach, but representation quality can degrade through excessive mixing or information bottlenecks.

Other challenges include heterophily (neighbors may be deliberately different rather than similar), very large neighborhoods, and limited structural expressiveness. Many standard message-passing GNNs are closely connected to the 1-dimensional Weisfeiler-Lehman graph-refinement test, so some non-isomorphic structures remain indistinguishable to them.

Do Not Read a GNN Embedding as a Literal Map

An embedding is a learned coordinate system optimized for a task. Nearby vectors often indicate similar learned representations, but the axes usually do not have a direct human meaning, and geometric proximity alone is not a proof of causal or semantic equivalence.

Knowledge Graphs

A knowledge graph makes relation types first-class data. Instead of a plain unlabeled edge \(u-v\), each fact is a directed triple \((h,r,t)\): a head entity, a relation, and a tail entity. The same pair of entities may participate in several different relation types, and direction can matter.

$$\text{fact}=(h,r,t)$$
Facts become typed, directed edges ResearcherLabPaperUniversityCity works_atauthoredaffiliated_withlocated_in Multi-hop query: Researcher -> Lab -> University -> City
A knowledge graph preserves relation semantics, so a path is not merely connectivity — the sequence of relation labels matters.

Knowledge graphs support symbolic traversal (“follow these relation types”), learned link prediction, and hybrids of the two. One important modeling convention is the open-world assumption: a missing triple often means “unknown,” not automatically “false.” That is why completing a knowledge graph is different from simply classifying every absent edge as a negative fact.

Knowledge Graph Embeddings

Knowledge graph embeddings compress entities and relation types into vectors so that plausible triples receive better scores than implausible ones. TransE is the classic geometric example: treat a relation as a translation in vector space.

$$\mathbf e_h+\mathbf e_r\approx \mathbf e_t$$ $$s(h,r,t)=\left\|\mathbf e_h+\mathbf e_r-\mathbf e_t\right\|$$
Embedding Intuition TransE

A Relation as a Learned Translation

h t relation vector r small residual A true triple should place h + r close to t in embedding space. Link prediction: try candidate tails and choose the ones with the best score.
TransE converts a symbolic relation into a geometric translation; training learns coordinates that make observed triples score well.

Training typically contrasts observed triples with corrupted triples created by replacing a head or tail entity. The model learns to give true facts lower distance scores than these negative candidates.

GNNs and Knowledge-Graph Embeddings Solve Different Problems

ApproachMain computationNatural strengthTypical output
Message-passing GNNAggregate neighborhood featuresUses attributes + local topologyNode, edge, or graph predictions
KG embeddingScore typed triples geometricallyMulti-relational link predictionEntity/relation vectors + triple scores
Relational GNNMessage passing conditioned on relation typeCombines both viewsContextual entity embeddings

Real-World Applications

Case Study

Drug Discovery via Molecular Graph Neural Networks

Pharmaceutical researchers represent candidate molecules directly as graphs — atoms as vertices, chemical bonds as edges — and use message passing to turn local chemical environments into learned atom embeddings. A permutation-invariant readout then combines those atom states into a molecule-level embedding, which can feed a predictor for properties such as solubility, toxicity, or binding-related targets.

1. Molecular graph CNCOC 2. Message passing atoms exchange local chemical context learn atom embeddings 3. Pool sum / mean attention graph vector 4. Predict toxicitysolubilityproperty The whole pipeline is invariant to arbitrary atom numbering.
Molecular GNNs naturally separate local relational computation from a graph-level readout.
Drug DiscoveryGraph Neural NetworksGraph-Level Prediction
Part 26 Mental Model
  • Why GNNs?Graphs have variable size, unordered neighborhoods, and relational dependence.
  • Message passingCollect neighbor messages, aggregate symmetrically, update the target.
  • Depth\(k\) layers give a structural receptive field of up to \(k\) hops.
  • Prediction levelOutputs can live on vertices, edges/links, or the whole graph.
  • Knowledge graphFacts are typed directed triples \((h,r,t)\), not plain edges.
  • Embedding viewLearn coordinates that make useful structural or relational patterns easy to score.

Exercises

  1. Take a vertex with three neighbors and write one message-passing update using a mean aggregator. Then permute the order of those neighbors and explain why the result should be unchanged.
  2. Draw a small graph around a target vertex and shade its 1-hop, 2-hop, and 3-hop neighborhoods. Relate those regions to the receptive field of a 1-, 2-, and 3-layer message-passing GNN.
  3. For each task — fraud detection on users, friend recommendation, and molecule toxicity prediction — decide whether the output is node-level, link-level, or graph-level, and justify your choice.
  4. Represent four facts as knowledge-graph triples and write one multi-hop query whose answer depends on the sequence of relation types, not just graph connectivity.
  5. Challenge: Using the TransE equations above, explain algebraically why a symmetric relation can be awkward for a single translation vector. What would have to be true of \(r\) if both \(h+r\approx t\) and \(t+r\approx h\)?

Conclusion & Next Steps

Graph machine learning keeps the core lesson of graph theory intact: relationships change the problem. GNNs turn neighborhoods into learned representations while respecting permutation symmetry; graph-level readouts turn many node states into one prediction; knowledge graphs make relation types explicit; and embedding models translate symbolic facts into geometry that can be scored and completed. The recurring question is no longer only “what paths or cuts exist?” but also “what representation should a model learn from this structure?”

With theory, algorithms, large-scale processing, network science, and graph-native machine learning now connected, the series turns next to the sciences where graph abstractions have been useful for much longer than modern AI — chemistry, biology, and physics.

Next in the Series

In Part 27: Graph Applications in Science, we'll explore graph theory's surprisingly deep roots in chemistry, biology, and physics.