Md. Asif Uddin

    Proposition 1I.14.P0148 of 100 in the corpus

    A graph layer must give the same answer however the nodes are numbered, and message passing is the layer that does.

    Numbering the nodes of a graph is a choice, not information. A layer that runs one rule at every node and combines neighbours with an order-free aggregator relabels its output exactly as its input was relabelled, and k such layers see k hops.

    One round of message passing at node 3A small graph: a triangle on nodes 1, 2 and 3, and a fourth node joined to node 3. Nodes 1, 2 and 4 send their states to node 3. On the right, the three messages enter a sum, the sum and node 3's own state enter an update function, and the result is node 3's new state. The same rule runs at every node, and the sum does not depend on the order of the neighbours.one round, one node1234h₁ + h₂ + h₄sum: order-freeupdate φ(h₃, ·)h₃′Every node runs the same rule on its own neighbours.Renumber the nodes and every output moves with itsnode: the layer is permutation-equivariant.
    Fig. 1 — Type C · Flow — One round of message passing at node 3 of a four-node graph. The neighbours' states are summed, so their order cannot matter, and the same rule runs at every node. Renumbering the nodes renumbers the outputs and changes nothing else.

    The input has no order

    A graph has nn nodes and mm edges (Graphs, vertices and edges 0.GR.01). A network receives it as two arrays: the adjacency matrix A\mat A, of shape n×nn\times n (Representing a graph 0.GR.02), and the node features X\mat X, of shape n×dn\times d, one row per node.

    Those arrays depend on how the nodes were numbered. Renumbering by a permutation matrix P\mat P, whose inverse is its transpose (The identity, the inverse and the transpose 0.LA.02), describes the same graph with different arrays:

    A↦PAPT,X↦PX,f(PAPT,PX)=Pf(A,X),r(PAPT,PX)=r(A,X).\begin{aligned} &\mat A\mapsto\mat P\mat A\mat P^{\mathsf T},\qquad\mat X\mapsto\mat P\mat X,\\[4pt] &f(\mat P\mat A\mat P^{\mathsf T},\mat P\mat X)=\mat Pf(\mat A,\mat X),\\ &r(\mat P\mat A\mat P^{\mathsf T},\mat P\mat X)=r(\mat A,\mat X). \end{aligned}
    (I.14.1)

    A relabelling changes the description of a graph, not the graph.

    The second line of (I.14.1) asks a node-level layer ff to be equivariant: renumber the input and the output is renumbered the same way. The third asks a graph-level readout rr to be invariant: renumbering changes nothing.

    A multilayer perceptron applied to the flattened adjacency matrix has neither property. A graph on nn nodes can be numbered in up to n!n! ways, 3,628,8003{,}628{,}800 for ten nodes, and the perceptron would have to learn separately that all of them are the same graph. It also fixes nn. A convolution escaped the same problem on a grid by reusing one local rule at every position (I.11). A graph needs one local rule that also does not care in which order a node’s neighbours are listed.

    Message passing

    A message-passing layer gives every node the same three steps. Each neighbour sends a message computed from the two nodes’ states. The messages are combined by an aggregator that sees them only as a multiset. The node updates its state from the result and its previous state:

    mv=⨁u∈N(v)ψ(hv,hu),hv′=φ(hv,mv).\begin{aligned} \vec m_v&=\bigoplus_{u\in\mathcal N(v)}\psi(\vec h_v,\vec h_u),\\ \vec h_v'&=\varphi(\vec h_v,\vec m_v). \end{aligned}
    (I.14.2)

    Every node runs the same rule on the multiset of its neighbours.

    Here N(v)\mathcal N(v) is the set of vv‘s neighbours and ⨁\bigoplus is a sum, a mean, a maximum, or an attention-weighted sum. The functions ψ\psi and φ\varphi are small networks shared by every node. Scarselli and colleagues (2009) introduced graph networks of this kind, and Gilmer and colleagues (2017) showed that most later variants are instances of (I.14.2).

    The equivariance proof takes three sentences. Renumbering moves each node together with its features and its set of neighbours. The aggregator receives the same multiset of messages under any numbering, because a multiset has no order. So every node computes the same new state as before, and only its row number changes: the output is PH′\mat P\mat H'. That is I.14.T1. A readout that sums or averages the rows is then invariant, because a sum over all nodes does not depend on their order. Zaheer and colleagues (2017) showed that sums are general here: every permutation-invariant function of a finite set from a countable domain can be written as ρ(∑iϕ(xi))\rho\big(\sum_i\phi(\vec x_i)\big).

    Sum aggregation is a product with the adjacency matrix

    With a sum aggregator and linear messages, the layer is a few matrix products:

    H′=σ(HW0+AHW1),(Ak)vu=#{walks v→uof length k}.\begin{aligned} \mat H'&=\sigma\big(\mat H\mat W_0\\ &\qquad+\mat A\mat H\mat W_1\big),\\ (\mat A^k)_{vu}&=\#\{\text{walks }v\to u\\ &\qquad\text{of length }k\}. \end{aligned}
    (I.14.3)

    Sum aggregation is a product with A, and k products reach k hops.

    Row vv of AH\mat A\mat H is the sum of vv‘s neighbours’ rows. Equivariance is now one line: (PAPT)(PH)=P(AH)(\mat P\mat A\mat P^{\mathsf T})(\mat P\mat H)=\mat P(\mat A\mat H), because PTP=I\mat P^{\mathsf T}\mat P=\mat I, and the weights act on the feature axis, which relabelling does not touch.

    The chapter’s running example is the paw: a triangle on nodes 11, 22 and 33, and node 44 joined to node 33. Its degrees are 22, 22, 33 and 11. With scalar features x=(1,2,3,4)\vec x=(1,2,3,4), the summed messages Ax\mat A\vec x are (5,4,7,3)(5,4,7,3): node 33 receives 1+2+41+2+4. The mean aggregator divides by the degrees and gives (2.5, 2, 2.333333, 3)(2.5,\,2,\,2.333333,\,3). Swap the labels of nodes 11 and 44, and both results come back with their first and last entries swapped. I.14.B01 works it through, and I.14.X02 shows a layer that reads neighbours in index order and is not equivariant.

    k layers see k hops

    The second line of (I.14.3) is the graph form of a receptive field. A walk of length kk can reach only nodes within distance kk (Walks, paths, cycles and connectivity 0.GR.03), so after kk layers a node’s state depends only on the features and edges within kk hops of it. That is I.14.T2. Like the receptive field of I.11.T3, it bounds what can matter, not what does.

    Two features of graphs make the bound bite harder than on a grid. The number of nodes within kk hops can grow like ckc^k for average degree cc, so a few layers can depend on a large part of the graph (I.14.B04). And a task whose answer depends on something three hops away cannot be solved by two layers, however wide: I.14.X07 builds two paths whose end nodes look identical for two layers and differ at the third.

    Node embeddings and readouts

    The rows of the final state matrix are node embeddings: vectors that describe each node in the context of its neighbourhood. A node-level task, such as classifying the atoms of a molecule or the proteins of an interaction network, reads them directly. A graph-level task, such as predicting a molecule’s toxicity, applies a readout first. An edge-level task combines the embeddings of the edge’s two ends. Book VII uses all three.

    One round, relabelled

    A = [[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 1], [0, 0, 1, 0]]   # the paw graph
    x = [1.0, 2.0, 3.0, 4.0]
    
    def layer(A, x):                     # sum over neighbours, then a fixed update
        return [x[v] + 0.5*sum(x[u] for u in range(len(A)) if A[v][u])
                for v in range(len(A))]
    
    p = [3, 1, 2, 0]                     # relabel: node i becomes node p[i]
    PA = [[0]*4 for _ in range(4)]
    Px = [0.0]*4
    for i in range(4):
        Px[p[i]] = x[i]
        for j in range(4):
            PA[p[i]][p[j]] = A[i][j]
    print(layer(A, x))
    print(layer(PA, Px))

    It prints [3.5, 4.0, 6.5, 5.5] and then [5.5, 4.0, 6.5, 3.5]: the same four numbers, with nodes 11 and 44 exchanged as the input was.

    Sources