skip to content

Why does sum aggregation distinguish neighbourhoods that mean and max aggregation cannot?

level: middleimportance: must knowfreq 60%

answer

  1. a bag, not a list
  2. counts versus proportions versus extremes
  3. duplicating every neighbour must change the answer
  4. injective on multisets is the goal
  5. the 1-WL ceiling still binds

basics

~20 s

A neighbourhood is a multiset, and only sum keeps both which features appear and how many times. Mean keeps proportions but loses counts; max keeps only extremes. Sum is the more distinguishing aggregator, which is why GIN uses it.

solid answer

~50 s

Aggregation maps an unordered bag of neighbour features to one vector, and the question is how much of the bag survives. Take `{A, B}` and `{A, A, B, B}`: mean returns `(A + B) / 2` for both and max returns the coordinatewise maximum of `A` and `B` for both, so a layer using either cannot tell those neighbourhoods apart, while sum returns `A + B` versus `2A + 2B`. Max loses more still: `{A, B}` and `{A, B, B}` collapse under max but are separated by sum and mean. This is the argument behind GIN, which sums over the neighbour multiset, adds a scaled self term, and applies a small feed-forward network, precisely because sum is the choice that can be injective on multisets. The ceiling is real though: even sum only matches the 1-WL test, so a 6-cycle and two disjoint triangles with identical node features stay indistinguishable.

go deeper

for a junior

Know the one-line ranking and one concrete bag that shows it: mean gives the same answer for two neighbours and four neighbours of the same two kinds, sum does not. Naming sum as the aggregator GIN uses is enough at this level.

for a middle

Work a counterexample out loud for both mean and max, and explain that a neighbourhood is a multiset so injectivity on multisets is the property being chased. Expect to be asked why GIN adds a scaled self term before the feed-forward layer.

for a senior

Demonstrate that you weigh expressiveness against scale: sum couples output magnitude to degree, which hurts on skewed graphs and under connectivity drift. Be ready to say which aggregator you shipped and what evidence made the call.

for a principal

Own the position that pooling choice is a modelling assumption about where the label lives — in counts, in composition, or in an extreme neighbour — and that the 1-WL ceiling means genuinely structure-dependent tasks need richer inputs rather than another aggregator experiment.

## The neighbourhood is a multiset A node's neighbours have no order, but they can repeat *feature values*: two neighbours may carry the same vector. So what the aggregator really receives is a **multiset** — a bag where multiplicity matters but position does not. The expressive power of a layer is decided by how much of that bag the aggregator preserves. If two different multisets map to the same vector, no amount of downstream depth can ever separate the two nodes; the information is gone before the update ever runs. ## Working the three aggregators on concrete bags Let `A` and `B` be two distinct feature vectors. **Bag pair 1: `{A, B}` versus `{A, A, B, B}`.** - Sum: `A + B` versus `2A + 2B` — different. - Mean: `(A + B) / 2` versus `(2A + 2B) / 4 = (A + B) / 2` — identical. - Max: coordinatewise `max(A, B)` in both — identical. Mean and max both fail here, and the reason is instructive: mean sees only *proportions*, so doubling every neighbour is invisible to it; max sees only the *extremes*, so multiplicity of any kind is invisible to it. **Bag pair 2: `{A, B}` versus `{A, B, B}`.** - Sum: `A + B` versus `A + 2B` — different. - Mean: `(A + B) / 2` versus `(A + 2B) / 3` — different. - Max: `max(A, B)` in both — identical. So the ordering of distinguishing power over multisets is sum > mean > max. Sum retains counts *and* composition; mean retains composition only; max retains the coordinatewise envelope only. ## Why GIN uses sum The Graph Isomorphism Network makes this precise. Its layer is, in words, a small feed-forward network applied to `(1 + eps) * h_v + sum over neighbours of h_u`: a sum over the neighbour multiset, the node's own state scaled by a learnable factor so it is never confused with a neighbour, and then a learned nonlinear map. The point of the construction is that a sum followed by a sufficiently expressive network can be made injective on multisets of bounded-size feature vectors, so distinct neighbourhoods produce distinct outputs. Swap the sum for a mean or a max and the injectivity is lost immediately, by the counterexamples above. ## The ceiling that sum does not break Sum is the most expressive of the three, not a solution to graph isomorphism. A message-passing GNN of this shape is at most as powerful as the **1-dimensional Weisfeiler-Leman colour-refinement test**: repeatedly relabel each node by a hash of its own label and the multiset of its neighbours' labels, and see whether two graphs end up with different label distributions. The standard counterexample is a 6-cycle versus two disjoint triangles, with every node carrying the same initial feature. Both graphs are 2-regular, so at every round every node in both graphs has an identical state; sum, mean and max are all equally helpless, and a sum readout over six identical nodes gives the same graph vector either way. Recognising this ceiling — and that escaping it needs extra input signal such as distinguishing node identifiers or structural counts, not a better pooling operator — is what separates a candidate who has read the GIN result from one who has only memorised *sum is best*. ## When the most expressive aggregator is the wrong one Expressive power is not the only axis. - **Sum entangles degree with content.** The output magnitude scales with the number of neighbours, so on a skewed-degree graph hub nodes produce vectors of a wholly different scale from leaf nodes, and a degree distribution that shifts between training and serving shifts the layer's input distribution with it. When degree is genuinely predictive that coupling is a feature; when degree is an artefact of how the graph was collected it is a liability. - **Mean is degree-invariant.** It answers *what does a typical neighbour look like*, which is the right question when you want a node's representation to be comparable across very different degrees. - **Max surfaces the extreme.** On an intrusion-detection graph of hosts and the peers they talked to, one contact with a hostile signature is the whole answer; max carries that peer's message straight through, while mean would divide it by the 400 ordinary connections around it and bury it in noise. In practice the choice is empirical and cheap to test: sum when counts and multiplicity carry the label, mean when you need degree-invariance, max when the label is driven by an extreme neighbour rather than the typical one.

  • Does sum aggregation let a message-passing GNN distinguish any two non-isomorphic graphs?
    No. Sum is the most expressive of the standard aggregators, but the whole message-passing family is bounded by the 1-WL colour-refinement test. A 6-cycle and two disjoint triangles with identical node features are 2-regular, so every node holds the same state in both graphs at every round and the graph vectors match. Breaking that needs extra input signal, not a better pooling operator.
  • What practical problem does sum aggregation create on a graph with a very skewed degree distribution?
    The pooled vector's magnitude scales with degree, so a hub with 10,000 neighbours produces activations orders of magnitude larger than a leaf's, which strains normalisation and makes representations non-comparable across degrees. It also couples the layer to the degree distribution, so a shift in connectivity between training and serving shifts the input scale. Mean, or feeding degree explicitly as a feature, are the usual answers.
  • If mean and max discard information, why would you ever choose them?
    Because the discarded information is sometimes noise. Mean gives degree-invariant representations when a node's degree is an artefact of collection rather than a signal. Max is right when the label is driven by a single extreme neighbour — one hostile peer among hundreds of benign ones — which a mean would dilute away. Expressive power is one axis; robustness and comparability across degrees are others.

saying these in an interview costs you the question

  • Says sum, mean and max are interchangeable stylistic choices
  • Claims sum aggregation makes a GNN able to solve graph isomorphism
  • Thinks mean aggregation retains how many neighbours there were
  • Assumes max aggregation is always the safe default
  • Treats repeated neighbour feature vectors as impossible

context