DEV Community

Hussein Mahdi
Hussein Mahdi

Posted on • Edited on • Originally published at dev.to

Revisiting the 2009 GNN Paper: Implementation (Part 2)

In Part 1, we explored the theoretical foundations that make Graph Neural Networks (GNNs) such a revolutionary approach to processing graph-structured data. We uncovered how the tau function, information diffusion, and universal approximation principles come together to create a powerful framework for understanding complex relationships in data.

Now, let's roll up our sleeves and dive into the practical aspects that make GNNs work in the real world. We'll explore the intricate architecture that brings these theoretical concepts to life, unpack the learning algorithms that allow GNNs to adapt and improve, and examine different implementation approaches that address various real-world challenges. Along the way, we'll see how researchers transformed elegant mathematical principles into practical solutions that are reshaping how we handle interconnected data.


Understanding GNN's Key Functions: A Closer Look at the Core Mechanisms

When examining pages 64–65 of the paper, we encounter two fundamental functions that form the backbone of GNN operations, along with a crucial mechanism that ensures their proper coordination over time. Let's break them down in a way that reveals their practical significance, using a real-world example to illuminate their roles.

1. The State Update Function (fw): The Network's Information Processor

The state of a node is computed from four inputs:

  • Node's own features (ln)
  • Edge features (lco[n])
  • Neighbor states (xne[n])
  • Neighbor features (lne[n])

This simple form is called the positional form.

Imagine a social network where each person represents a node in our graph. The state update function acts like a sophisticated information gatherer, collecting and processing data from multiple sources. When updating a user's profile (let's call her Alice), this function considers four crucial pieces of information.

First, it looks at Alice's own characteristics — her interests, activity level, and profile data. Then, it examines her connections: how long she's been friends with others and the nature of these relationships. The function also considers her friends' current status in the network and their characteristics. All this information comes together to update Alice's "state" in the network.

2. The Output Function (gw): Transforming States into Meaningful Results

  • Node state (xn)
  • Node features (ln)

The output function represents one of the researchers' most elegant solutions. Rather than using simple mathematical operations, they implemented it as a multilayered feedforward neural network. This function takes Alice's updated state (all the processed information about her position and relationships in the network) along with her original features, and transforms them into meaningful predictions — perhaps determining if she's likely to be an influential user, or interested in certain content.

The Global Update: Orchestrating the Network's Evolution

What makes this framework particularly powerful is how these functions work together over time through the global update mechanism (Fw):

Remember how in Part 1 we discussed GNNs' relationship with recursive neural networks? This is where that temporal aspect comes into play. The network doesn't just process information once; it continues to update and refine its understanding.

Each node's state evolves from x(t) to x(t+1) as the network processes information. The global update mechanism ensures this evolution happens synchronously across all nodes, maintaining consistency throughout the entire network. This process continues until the network reaches what the researchers call a stable state — a point where further updates don't significantly change the nodes' states.

This orchestration enables GNNs to capture both the local details of individual nodes and the broader patterns of the entire graph structure as they evolve over time. It's like watching a photograph develop: with each iteration, the picture becomes clearer and more detailed, until we have a complete understanding of the relationships within the data.


Diving Deep into GNN's Learning Process

On page 66, the researchers unveiled the intricate details of how GNNs actually learn from data. This isn't just another neural network training process; it's a sophisticated two-phase approach that ensures the network can effectively process graph-structured information while maintaining stability.

The Forward Phase

The network starts processing information at each node, then iteratively updates states until it reaches what the researchers call a stable equilibrium. This isn't just a fancy term — it's a mathematically guaranteed state, thanks to the Banach fixed point theorem (page 64), which holds provided Fw is a contraction map.

During this phase, the network repeatedly updates node states x(t) until the difference between consecutive updates becomes negligibly small. This mathematical condition ensures that the network has thoroughly processed all available information before moving to the next phase.

The Backward Phase

Here's where things get really interesting. The researchers implemented what they call the z-values computation, which moves backward through time. This process continues until the network reaches another stability condition. They based this on the Almeida–Pineda algorithm, which ensures the network learns efficiently, regardless of its starting point.

What makes this approach particularly elegant is its exponential convergence rate. Rather than slowly inching toward a solution, the network rapidly homes in on optimal parameters, making it both mathematically sophisticated and practically efficient. This two-phase design represents a crucial innovation in graph processing. By carefully balancing forward information flow with backward learning, the researchers created a system that could not only understand complex graph structures but also learn from them effectively.

εf and εb are small constant thresholds that decide when each phase has converged. They vary from problem to problem, and are generally small decimal values — in the paper's own experiments, both were set to 10⁻³. They are not learning rates; the learning rate is λ, which appears in the weight update below.


A Detailed Look at GNN's Training Flow

After exploring the basic mechanisms and learning algorithms, the researchers begin to outline how training works, starting on pages 66 and 67 of their paper, by providing a comprehensive flowchart that translates theoretical concepts into practical applications. This flowchart is not just a simple diagram; it is a detailed roadmap that shows exactly how these networks process and learn from graph-structured data.

The researchers break down the training process into seven carefully orchestrated stages, starting from the initialization of weights through to the final trained model. Before we dive into each stage, it's important to understand that this flowchart represents a complete training cycle — something the researchers call an epoch. Each cycle moves through forward computation, cost evaluation, gradient calculation, and weight updates, gradually refining the network's understanding of the graph structure.

1. Start. Initialize the graph with random weights w.

2. Forward Pass.

Iterate the state and output for every node until the state converges. This is Equation 5, the form the paper's FORWARD function actually runs:

The neighbor states carry a time index xne[n](t): each step recomputes a node's state from its neighbors' states at the previous step. This iteration is repeated until the state stops changing — that is, until it reaches the stable state x:

At that point x(t) has settled to the fixed point x, and it is this stable state that the backward pass operates on.

Compute the cost function — the quadratic error between the predicted output and the target, summed over every supervised node (Eq. 6):

3. Backward Pass.

Compute the stable state z by iterating backward until convergence (Eq. 7):

This equation combines two effects:

  • Local output effects, through ∂ew/∂o · ∂Gw/∂x
  • Graph structure propagation, through z(t+1) · ∂Fw/∂x

This backward recursion is iterated until it stops changing — that is, until it reaches the stable state z:

Because Fw is a contraction, this convergence is exponentially fast, so only a handful of iterations are needed in practice. It is this stable z that is then used to compute the gradient.

Then compute the gradient of the cost function with respect to the weights (Eq. 8):

This combines the direct effect of the weights on the output (through Gw) and the indirect effect of the weights on the state (through Fw), propagated via the state variable z.

4. Convergence Check. After the weights are updated and the state is recomputed, check whether the overall training loop should stop. The paper does not give a formula here — Table I simply states the loop runs "until a stopping criterion," and the text describes this as continuing until the output reaches a desired accuracy or another stopping criterion is met. In the paper's own experiments, this meant a fixed cap of at most 5000 epochs together with best-validation-cost model selection. If the criterion is not yet met, the loop repeats.

Note that this loop-level check is separate from the two convergence conditions that live inside the passes above: εf stops the forward state iteration (step 2) and εb stops the backward z iteration (step 3). Those decide when each individual pass has settled; the criterion here decides when training as a whole is finished.

5. Update Weights. Adjust the weights using the computed gradient:

where λ is the learning rate.

6. Repeat. Repeat the forward pass, cost computation, backward pass, and weight update until convergence.

7. End.

Explanation of the Flowchart

  • Forward Pass: the network computes the state and output for each node based on the current weights.
  • Cost Function: the error between the predicted output and the actual target is calculated.
  • Backward Pass: the gradient of the cost function with respect to the weights is computed. This ensures that the network can learn effectively by adjusting its weights.
  • Convergence Check: the network checks whether training has converged — whether the error has stopped improving or the epoch limit is reached. If not, it runs another epoch.
  • Weight Update: the weights are adjusted to minimize the error, using gradient descent.

Two Approaches to Transition Functions

On page 68, the researchers describe how to implement the transition function we explained earlier. It specifies how each node updates its state by collecting and processing information from its neighboring nodes. The researchers devised several ways to implement it, some of which were mentioned previously, so we will cover them in detail as stated on pages 64 and 68.

They identify two main approaches.

1. Local (positional) implementation — Equation 1, page 64

Where:

  • xn: state of node n
  • ln: label of node n
  • lco[n]: labels of edges connected to n
  • xne[n]: states of neighboring nodes
  • lne[n]: labels of neighboring nodes

In this approach, the transition function takes into account the exact positions of neighboring nodes. It is like giving each neighbor a specific seat at the table — its location matters.

2. Non-local (non-positional) implementation — Equation 3, pages 64 and 68

This version is more flexible and does not care about the specific positions of neighbors. It treats all neighbors equally, like guests at a round table where the seating order does not matter. The function collects information from all neighbors uniformly.

The researchers describe two ways to implement this non-positional version.

Linear implementation. The contribution of each neighbor is an affine function of that neighbor's state (Eq. 12):

The matrix and the vector are produced by two separate feedforward networks (Eqs. 13–14):

Here μ ∈ (0, 1), s is the state dimension, and resize reshapes an s²-dimensional vector into an s × s matrix. Provided the transition network's outputs are bounded so that ‖φw(ln, l(n,u), lu)‖1 ≤ s — easily arranged with a bounded activation such as tanh — it follows that:

which makes Fw a contraction map for any parameter set w.

  • Uses two separate neural networks: a transition network (generating An,u) and a forcing network (generating bn)
  • The transition network determines how the states of neighbors affect the node
  • The forcing network modifies the state of the node with a bias term
  • Stability is structural: it holds by construction, not by training

Nonlinear implementation. Here hw is a multilayered feedforward network. Since three-layered networks are universal approximators, hw can approximate any desired function — but not every parameter set w is admissible, because Fw must still be a contraction. This is enforced by adding a penalty term to the cost:

where L(y) = (y − μ)² if y > μ, and 0 otherwise. The parameter μ sets the desired contraction constant; β weights the penalty.

  • Uses a single multilayer neural network
  • More flexible in learning complex relationships
  • Requires careful training to maintain stability
  • Stability is enforced by penalty, not by construction

Both implementations serve the same purpose but offer different trade-offs between computational efficiency and expressive power.


The Original GNN: Laying the Foundation for Modern GNNs

The 2009 model is not what runs today, but almost everything that does traces back to it. Its lasting contribution was an idea, not an architecture: a node can build its own representation by repeatedly exchanging information with its neighbors until the graph settles. The paper called this information diffusion; the field later renamed it message passing, and it became the organizing principle of modern graph learning. GCN, GraphSAGE, GAT, and the MPNN framework all share the same skeleton — gather from neighbors, update, repeat. What changed is mainly that modern GNNs drop the requirement to iterate to a fixed point and instead run a few fixed layers, which is simpler to train and just as effective. (The one partial exception, early spectral GNNs, grew from graph signal processing rather than diffusion — but the influential GCN reduces in practice to neighbor-averaging, i.e. message passing again.)

The distance travelled is easiest to see in a descendant: GraphSAGE underpins Pinterest's PinSage, which runs over roughly 3 billion nodes and 18 billion edges. The 2009 paper was validated on small benchmarks — mutagenic-compound classification, a 5000-node synthetic web graph. The same core mechanism now serves hundreds of millions of people.


Conclusion

In diving deep into the practical side of Graph Neural Networks, we've seen how elegant mathematical principles become powerful real-world tools. The researchers built something remarkable here: they found a way to make neural networks truly understand and work with graph structures. Whether using the straightforward linear approach or the more flexible nonlinear method, GNNs show us how complex data relationships can be learned and processed effectively.

What makes this work particularly exciting is how it bridges theory and practice. The careful balance between information flow and learning stability opens doors for using GNNs in everything from analyzing molecules to understanding social networks. Looking ahead, this practical foundation gives us not just working solutions for today's challenges, but a framework that will keep evolving as we push the boundaries of what artificial intelligence can do with interconnected data.


Refrences

  • Scarselli, F., Gori, M., Tsoi, A. C., Hagenbuchner, M., & Monfardini, G. (2009). The Graph Neural Network Model. IEEE Transactions on Neural Networks, 20(1), 61–80.

Top comments (0)