Skip to content
AI360XpertBeta
Core ML

Visual explainer

Graph Neural Networks

Trace node features through neighbor aggregation and two-hop message passing. See what mean aggregation preserves, loses and smooths away.

Identical node features can sit in different neighborhoods.
Identical node features can sit in different neighborhoods.

Graph neural networks use relationships as well as node features to compute representations. A and E start with the same two-coordinate feature (2,0)(2,0), but A has neighbors B and C while E is isolated. A feature-only function receives identical inputs for A and E; a graph-aware function can distinguish their contexts. Links are observed input structure, not proof that neighbors cause a label or improve a prediction.

Gather The Old States

A target gathers its neighbors before updating.
A target gathers its neighbors before updating.

A receives B's (2,2)(2,2) and C's (0,2)(0,2). Arrows show messages entering A, while the earlier unarrowed edges showed topology. All messages in a layer use the previous layer's states. Updating one node and immediately using its new value for another would be a different computation.

GraphSAGE develops neighborhood aggregation with shared learned functions. To make a complete step checkable, our synthetic specialization is

mv=mean⁡u∈N(v)hu,hv′=hv+mv.m_v=\operatorname{mean}_{u\in N(v)}h_u,\qquad h'_v=h_v+m_v.

Here hvh_v is the old feature vector, N(v)N(v) its neighbors and mvm_v their coordinatewise mean. Self and neighbor weights are identity matrices; there is no final normalization. An isolated node has mv=0m_v=0 by our chosen convention. This is an illustrative message-passing update, not the exact normalized GraphSAGE or GCN algorithm.

Add The Neighbor Mean

The neighbor mean adds a specific vector to the target.
The neighbor mean adds a specific vector to the target.

The axes are feature coordinates, with 70 drawing units per coordinate unit. The square marks the mean (1,2)(1,2), because ((2,2)+(0,2))/2=(1,2)((2,2)+(0,2))/2=(1,2). Own marks A's (2,0)(2,0). Translating the mean vector to Own reaches New at (3,2)(3,2):

hA′=(2,0)+(1,2)=(3,2).h'_A=(2,0)+(1,2)=(3,2).

The shared direction and length of the two slanted segments show the same neighbor contribution. The picture represents feature-space arithmetic; its coordinates are not physical node positions.

Follow A Second Hop

A second layer carries D's information through B to A.
A second layer carries D's information through B to A.

Reveal D, an additional neighbor of B, with initial feature (4,0)(4,0). The full undirected path is D–B–A–C. The highlighted arrows trace a dependency across layers: D's initial state contributes to B's layer-one state, which contributes to A's layer-two state. Labels beneath B and A refer to those different layers, not one simultaneous graph snapshot.

From the original states, hB′=(2,2)+((4,0)+(2,0))/2=(5,2)h'_B=(2,2)+((4,0)+(2,0))/2=(5,2) and hC′=(0,2)+(2,0)=(2,2)h'_C=(0,2)+(2,0)=(2,2). Thus

hA′′=(3,2)+((5,2)+(2,2))/2=(6.5,4).h''_A=(3,2)+((5,2)+(2,2))/2=(6.5,4).

A cannot receive D's initial feature directly in one local layer. As a fresh check, changing only D's first coordinate from 4 to 6 leaves A's first update unchanged but increases A's second first-coordinate value from 6.5 to 7.

Compare Contextual States

Equal starting features can become different contextual states.
Equal starting features can become different contextual states.

Return to A and isolated E after one layer. Their initial features match, but A becomes (3,2)(3,2) while E remains (2,0)(2,0). Bars use 70 drawing units per feature unit; numbered rows identify coordinates 1 and 2. The point in E's second-coordinate row denotes zero. The graph has made their representations distinct under this rule. No classification accuracy follows without a trained task head, labels and held-out evaluation.

Choose Reach With Depth

Local message-passing depth controls the reachable hops.
Local message-passing depth controls the reachable hops.

The two rows show the same path and node locations. The solid enclosure contains A and its one-hop neighbors B and C; the dashed enclosure adds D at two hops. These are receptive-field sets, not distances in feature space. Extra local layers can incorporate more remote information, but useful depth depends on the graph, update function and task. Validate depth rather than prescribing two layers universally.

Isolate The Smoothing Effect

Repeated averaging can shrink differences between connected nodes.
Repeated averaging can shrink differences between connected nodes.

Now explicitly change both the graph and update rule to isolate averaging. There are two connected nodes with scalar states a=0,b=2a=0,b=2, updated synchronously by

a′=0.75a+0.25b,b′=0.25a+0.75b.a'=0.75a+0.25b,\qquad b'=0.25a+0.75b.

One step gives a′=0.5,b′=1.5a'=0.5,b'=1.5. Both rows use the same scalar axis: x=100+220vx=100+220v drawing units for state vv. Circles track A and squares track B. The gap shrinks from 2 to 1. The earlier additive rule need not contract; this separate fixture must not be mistaken for its continuation. GCN's depth discussion motivates examining depth-related degradation, but the numbers here are our exact two-node calculation.

Ignore Neighbor Order

Reordering neighbors leaves their mean unchanged.
Reordering neighbors leaves their mean unchanged.

Return to B and C's original two-coordinate vectors. Whether their collection arrives as B,C or C,B, its mean is (1,2)(1,2). The two input lanes merge into matching output chips. Mean aggregation is permutation invariant: changing neighbor order does not change the result. Node identifiers name inputs; they are not numeric features. This invariance suits an unordered neighborhood, though not every sequence-based aggregator automatically has it.

See What The Mean Loses

Distinct neighborhoods can have the same mean.
Distinct neighborhoods can have the same mean.

Two neighbors with vectors (2,2)(2,2) and (0,2)(0,2) have mean (1,2)(1,2). A different neighborhood containing just one vector (1,2)(1,2) has exactly the same mean. Both output chips match although the input counts differ. If a node's own state is also equal, our update cannot distinguish these neighborhoods. A sum would distinguish this particular pair, giving (2,4)(2,4) versus (1,2)(1,2); no single illustration proves a general expressiveness guarantee.

Where It Breaks

Averaging can erase the distinction needed to identify a node.
Averaging can erase the distinction needed to identify a node.

Return to the separate two-node scalar averaging rule from frame 7. Rows show step 0, step 1, step 4 and the limit, all on the same axis. The mean stays 1, while the difference is

bk−ak=2(0.5)k.b_k-a_k=2(0.5)^k.

At step 4, states are (0.9375,1.0625)(0.9375,1.0625), still distinct. Only in the limit do both reach 1; the deliberately overlapping circle and square show that loss of distinction. A head receiving identical limiting features cannot identify which node had the original low value. This is a concrete oversmoothing mechanism under the stated rule. Learned transforms, residual paths, normalization and graph structure can change the behavior; arbitrary GNNs need not converge to this mean.

The Quick Version

  • Equal feature rows can have different graph neighborhoods.
  • A layer gathers messages from previous-layer states.
  • Neighbor means contribute a checkable feature update.
  • Two local layers can carry two-hop information.
  • Context can distinguish equal starting features.
  • Depth changes reach without guaranteeing better predictions.
  • Repeated averaging can contract feature differences.
  • Mean aggregation ignores neighbor order.
  • Different neighborhoods can share a mean.
  • Contracting differences can eventually erase task-relevant distinctions.