GNN Intro
GNN Intro
2026 Summer GNN Study Group
Graph Representation Learning
The essence of representation learning is ultimately designing and implementing how to preserve similarity in a graph within the embedding space. That is, the goal is to make nodes that are close in the original graph also close in the embedding. Here, the choices of what counts as similar, how to read out that similarity, and which operations reproduce that similarity become the model’s structural assumption, that is, its inductive bias.
This can be organized along two axes.
- Similarity design: how are the graph similarity \(s_G\) and the decoder that recovers similarity from embeddings each defined?
- Learning design: what structure of encoder is used, and how is the loss defined?
Formulating this as the ENC–\(s_G\)–DEC framework gives the following.
- Graph similarity \(s_G : V \times V \to \mathbb{R}^+\). For example, adjacency \(s_G(v_i, v_j) = A_{ij}\) or random walk co-occurrence probability.
- Encoder \(\text{ENC} : V \to \mathbb{R}^d\), that is \(z_i = \text{ENC}(v_i)\). It holds the learnable parameters.
- Decoder \(\text{DEC} : \mathbb{R}^d \times \mathbb{R}^d \to \mathbb{R}^+\). For example, inner product \(z_i^\top z_j\) or negative Euclidean distance \(-\lVert z_i - z_j \rVert^2\).
Learning minimizes the loss so that the decoded similarity approaches the original similarity.
\[\mathcal{L} = \sum_{(v_i, v_j) \in \mathcal{D}} \ell\big(\text{DEC}(z_i, z_j),\ s_G(v_i, v_j)\big)\]Node Embedding Approach
Embeddings of edges or subgraphs mostly reduce to post-processing of node embeddings, and even when learned directly, the procedure is essentially the same as node embedding. So understanding node embedding is the key.
Within the ENC–\(s_G\)–DEC framework, approaches can be split into two based on the layer at which learning occurs.
- Shallow: directly optimize the per-node embedding itself against a predetermined \(s_G\).
- NN-based: learn the operation that produces similarity, such as an autoencoder or message passing, to obtain embeddings indirectly. Parameters are shared across nodes.
Shallow Embedding
The simplest encoder is a lookup with almost nothing to learn. An embedding matrix \(Z \in \mathbb{R}^{d \times \vert V\vert }\) is kept, and the embedding of node \(v_i\) is simply pulled out as the \(i\)-th column of that matrix.
\[Z \in \mathbb{R}^{d \times \vert \mathcal{V}\vert }, \qquad \text{ENC}(v_i) = Z_{\cdot i} = z_i\]Here \(e_i\) is a one-hot vector whose only nonzero component is the \(i\)-th. That is, each node directly optimizes its own free parameters \(z_i\), so parameters are not shared across nodes, node features are not used, and it does not generalize to nodes unseen in training; it has a transductive nature.
In detail, there are two branches.
- Factorization family: fix a similarity matrix \(S\) and use inner product as the decoder. The goal is to approximate \(S\) with low rank.
- Random walk family: define similarity as co-occurrence probability in node sequences. Use softmax as the decoder, and approximate with Negative Log Likelihood and negative sampling.
Factorization family
First the similarity to be preserved is fixed as a matrix \(S\). The adjacency matrix \(A\), \(k\) reflecting \(A^k\)-hop, or metrics like Katz, Rooted PageRank, and Jaccard become \(S\). Setting the decoder to inner product, it becomes a low-rank factorization problem of fitting the embedding product \(Z^\top Z\) to approximate \(S\) well.
\[\min_{Z}\ \lVert S - Z^\top Z \rVert_F^2\]It can also be viewed as distance-based. The objective of placing embeddings closer the stronger a pair is connected is cleanly organized by the Graph Laplacian \(L\).
\[\sum_{i, j} W_{ij}\, \lVert z_i - z_j \rVert_2^2 = 2\,\mathrm{tr}(Z L Z^\top)\]
Graph Laplacian
The Graph Laplacian is a transformed form of the adjacency matrix that represents a graph’s connection structure, and the most basic among them, the unnormalized Laplacian, is the form obtained by subtracting the adjacency matrix \(A\) from the degree matrix \(D\).
\[L = D - A, \qquad D = \mathrm{diag}(d_1, \dots, d_n),\quad d_i = \sum_j A_{ij}\]Looking component by component, in a graph without self-loops, the diagonal entries are the node’s degree, connected node pairs are -1, and the rest are 0.
\[L[i,j] = \begin{cases} d_i & i = j \\ -1 & i \ne j,\ (i,j) \in \mathcal{E} \\ 0 & \text{otherwise} \end{cases}\]The unnormalized Laplacian has the following properties.
- It is symmetric, that is \(L = L^\top\).
- It is positive semi-definite. All eigenvalues are at least 0.
-
For any vector \(x \in \mathbb{R}^{\vert V\vert }\), the quadratic form equals the sum of squared differences between neighbors.
\[x^\top L x = \frac{1}{2} \sum_{u \in \mathcal{V}} \sum_{v \in \mathcal{V}} A[u,v]\,(x[u] - x[v])^2 = \sum_{(u,v) \in \mathcal{E}} (x[u] - x[v])^2\]
Because of property 3, the following holds:
\[x^\top L x = \frac{1}{2} \sum_{i, j} A_{ij}\, (x_i - x_j)^2 \ \ge\ 0\]This quadratic form is exactly a smoothness measure of how much values differ between neighbors. Extending this identity from a vector to an embedding matrix \(Z\) yields \(\sum_{i,j} W_{ij} \lVert z_i - z_j \rVert_2^2 = 2\,\mathrm{tr}(Z L Z^\top)\) directly. That is, the objective of placing connected nodes’ embeddings close is the same as minimizing the Laplacian quadratic form. The smallest eigenvalue 0 corresponds to a vector that is constant per connected component. The smaller the eigenvalue of an eigenvector, the more it is a smooth signal that changes slowly over the graph, and these eigenvectors are also used as material for the positional encoding mentioned later. Note that GCN-type neighbor-averaging propagation is essentially one with this normalized Laplacian, so stacking too many layers keeps smoothing the signal and eventually leads to over-smoothing.
Note) The normalized Laplacian with matched scale is also often used.
\[L_{\text{sym}} = I - D^{-1/2} A D^{-1/2}, \qquad L_{\text{rw}} = I - D^{-1} A\]Random walk family
Instead of a fixed matrix, similarity is defined as “how often they appear together in random walks.” The decoder is softmax, modeling the probability that a walk starting at node \(u\) meets \(v\) as the embedding inner product.
\[P(v \mid u) = \frac{\exp(z_u^\top z_v)}{\sum_{n \in V} \exp(z_u^\top z_n)}\]Letting \(N_\mathcal{R}(u)\) be the set of nodes actually visited by a walk starting at \(u\), the objective is the Negative Log Likelihood that explains this co-occurrence well.
\[\mathcal{L} = \sum_{u \in V} \sum_{v \in N_\mathcal{R}(u)} -\log P(v \mid u)\]The problem is that the softmax denominator sweeps over all nodes, costing \(O(\vert V\vert )\). So in practice it is approximated with negative sampling, a contrastive training that pulls together one truly neighboring pair and pushes away \(k\) randomly drawn nodes.
\[\mathcal{L} = \sum_{u \in V} \sum_{v \in N_\mathcal{R}(u)} \Big[ -\log \sigma(z_u^\top z_v) - \sum_{i=1}^{k} \mathbb{E}_{\,n \sim P_n}\big[ \log \sigma(-z_u^\top z_n) \big] \Big]\]The methods diverge in how the walk is rolled out. DeepWalk uses a uniform random walk, and node2vec adjusts between local search and global search with biased walks. When coming from the previous node \(t\) to the current node \(v\), the unnormalized weight of going to the next candidate \(x\) is as follows.
\[\alpha_{pq}(t, v, x) = \begin{cases} \frac{1}{p} & d_{tx} = 0 \\ 1 & d_{tx} = 1 \\ \frac{1}{q} & d_{tx} = 2 \end{cases}\]\(d_{tx}\) is the shortest distance between the previous node \(t\) and the candidate \(x\). If the return parameter \(p\) is small, it returns to where it came from and sweeps narrowly like BFS, and if the in-out parameter \(q\) is small, it goes farther out and searches broadly like DFS.
NN-based Embedding
The inputs are node features \(x_i\) and neighbors \(N(i)\). It splits into two branches.
Neighborhood Autoencoder: DNGR, SDNE
Since the shallow approach keeps a free vector per node, the number of parameters grows proportional to \(\vert V\vert\). To reduce this, instead of directly storing a per-node vector, the function itself that “compresses and reconstructs the similarity vector” is learned and shared across nodes.
For each node \(i\), a neighbor distribution vector \(s_i \in \mathbb{R}^{\vert \mathcal{V}\vert }\) holding similarities to all nodes in the graph is made. This is the \(i\)-th row of the similarity matrix \(S\). This \(s_i\) is compressed and reconstructed with an autoencoder, and the objective is as follows.
\[\min_{\theta, \phi} \sum_i \big\lVert s_i - \text{DEC}_\phi\big(\text{ENC}_\theta(s_i)\big) \big\rVert_2^2\]- Parameters are shared across nodes, so computation is efficient.
- However, it is transductive: the input dimension is fixed at \(\vert \mathcal{V}\vert\), so it is hard to apply to large graphs or unseen graphs, and it is hard to naturally use node features.
Neighborhood Aggregation: GCN, GraphSAGE, GAT
With message passing, the operation of aggregating neighbor representations and combining them with one’s own representation is repeated over several layers.
\[h_i^{(0)} = x_i\] \[h_i^{(k)} = \text{UPDATE}^{(k)}\!\Big(h_i^{(k-1)},\ \text{AGG}^{(k)}\big\{ h_j^{(k-1)} : j \in N(i) \big\}\Big), \qquad z_i = h_i^{(K)}\]- Depending on how AGG and COMBINE are chosen, it branches into GCN, GraphSAGE, GAT, etc. This approach is inductive. The model size is independent of graph size, it can use node features or graph meta information, and it applies well even to unseen graphs.
Since message passing as the ENC takes charge of structural assumptions, the DEC and loss can be flexibly attached to fit the task.
- link prediction: negative sampling on \(\text{DEC}(z_i, z_j) = \sigma(z_i^\top z_j)\).
- node classification: cross-entropy on \(\hat{y}_i = \text{softmax}(W z_i)\).
- graph or subgraph tasks: collect node embeddings with READOUT and then attach a per-task DEC.
This “stacking layers while aggregating” operation is exactly the message passing of GNNs, examined in detail below.
GNN
What is a GNN?
A GNN is a neural network that takes the graph itself as input, transforms and outputs the representation of each node while preserving the graph’s connection structure. What differs from a general neural network is the constraint that “it must preserve the graph structure,” and broadly, it is one means of realizing graph representation learning.
Organizing the inputs and outputs gives the following.
- Input: Node features \(X \in \mathbb{R}^{n \times d}\), Adjacency \(A \in \{0,1\}^{n \times n}\), and optionally Edge features
- Output: Node embeddings \(H \in \mathbb{R}^{n \times d'}\), and optionally graph embedding or edge prediction
Why GNN?
There are advantages in two respects.
First, the form of the input is free. A general neural network presumes a standardized structure such as grid-shaped images or sequence-shaped text, but a GNN only needs to be “expressible as a graph,” so it can handle relational data directly even when it is not such a standardized structure.
Second, it is better than simply flattening the graph into a single vector. The adjacency matrix is usually sparse yet grows in size as \(O(n^2)\), which is inefficient, and simply unfolding it loses local connection structure information. Moreover, because of the permutation problem where changing just the node order changes the representation, the same graph can appear as different vectors. A GNN maintains permutation invariance and equivariance, and its computation grows with the number of edges rather than the square of nodes, so it avoids these drawbacks.
Types of input node features
The input features given to nodes are broadly divided into three categories.
- Natural features: attributes the data itself has.
- Structural features: extracted from the graph structure when there are no natural features. Degree, centrality, clustering coefficient, or learned random features, etc.
- Positional encodings: a method inspired by Transformers, encoding each node’s position within the graph using Laplacian eigenvectors or random walk probabilities.
Message Passing
The core assumption of a GNN is “a node learns from its neighbors.” Message passing starts from here. Intuitively, the flow is as follows.
- Each node starts from its own feature.
- It exchanges information with neighbors.
- It combines what it heard with what it already knew.
- This process is repeated several times.
- Repeating \(k\) times, each node comes to have information about its \(k\)-hop neighbors.
The update of one layer is as follows.
\[h_v^{(l+1)} = \text{UPDATE}\Big(h_v^{(l)},\ \text{AGGREGATE}\big\{ h_u^{(l)} : u \in N(v) \big\}\Big)\]Breaking this into three steps gives the following.
- MESSAGE: \(m_{v \leftarrow u} = \text{MESSAGE}(h_u^{(l)}, h_v^{(l)}, e_{uv})\). Builds the message to send to the target from the edge attributes and the source node’s feature.
- AGGREGATE: \(m_v = \text{AGGREGATE}\big(\{ m_{v \leftarrow u} : u \in N(v) \}\big)\). Combines the messages that came from neighbors. Sum, mean, max, attention, etc. are used, and since it must be order-independent, it must necessarily be permutation-invariant.
- UPDATE: \(h_v^{(l+1)} = \text{UPDATE}(h_v^{(l)}, m_v)\). Combines the aggregated message with the node’s current representation. Usually a neural network such as an MLP or GRU is used.
This pattern itself is shared by all GNNs; what differs is only how each of the MESSAGE, AGGREGATE, and UPDATE functions is designed.
Stacking Layers

The receptive field widening as layers are stacked
One round of message passing corresponds to one layer. Therefore, the more layers are stacked, the farther nodes’ information reaches, and \(L\) layers gather information up to each node’s \(L\)-hop neighbors.
Limitations
The 1-WL test and the upper bound of GNN expressive power
1-WL is the first-order version of the Weisfeiler-Leman test, an old algorithm that judges whether two graphs are the same or not by repeatedly refining colors. It is also called color refinement, and the procedure is as follows.

- Give all nodes the same initial color. If node features exist, use them as the initial color.
- At each node, gather the current colors of its neighbors as a multiset.
- Bundle its own color with the neighbor color multiset and assign a new color via an injective hash.
- Repeat 2 and 3 until colors no longer change.
- Compare the final color histograms of the two graphs.
Hashing
WL’s hash takes each node’s (my color, neighbor color multiset) pair and turns it into a single new color. There are two rules.
- Nodes whose input pairs are completely the same must receive the same color.
- If they differ at all, they must receive different colors. This absence of collision is the meaning of injective.
That is, this is a consistent relabeling that assigns an unused number to each combination seen so far. For example, the neighbor count automatically separates colors as in \((\text{gray}, \{\!\{\text{gray}\}\!\}) \to 1\), \((\text{gray}, \{\!\{\text{gray}, \text{gray}\}\!\}) \to 2\).
Because it is injective, not a bit of information leaks. If two nodes end up the same color, that means the input pairs were really the same. Precisely for this reason, when a GNN’s AGGREGATE and UPDATE imitate this hashing with vectors, if injectivity breaks (e.g., mean, max), it becomes weaker than 1-WL.

However, 1-WL has an expressive-power limitation that it cannot distinguish two graphs like those in the image above. This causes problems when comparing similarity between graphs or dealing with the graph isomorphism problem.
But a GNN’s message passing corresponds to the 1-WL test. One layer of a standard message passing GNN consists of aggregate, which gathers neighbor representations, and update, which combines with one’s own representation, and this corresponds to 1-WL’s process of “gathering the neighbor color multiset and making a new color with a hash.” Aggregate corresponds to gathering neighbor colors, update to the hash, and layer repetition to color refinement repetition. So in the ability to distinguish two different graphs, a standard GNN cannot surpass 1-WL. That is, any standard GNN produces the same representation for graphs that 1-WL cannot distinguish. This is the meaning of saying that the upper bound of message passing GNN expressive power is 1-WL.
To actually reach that upper bound, both operations must be injective. In aggregate, sum distinguishes different neighbor multisets, while mean and max lose information. In update, a sufficiently wide MLP plays the role of an injective function, but a single linear layer does not. GIN, which uses sum aggregation together with MLP update, is exactly the structure that reaches the 1-WL upper bound, and GCN, which uses aggregation close to mean and linear update, has lower expressive power than that. To go beyond 1-WL, structural information must be added separately, with methods such as Laplacian-eigenvector-based positional encoding, structural features like triangle or cycle counts, and graph transformers using global attention.
Over-smoothing

Change in embeddings as layers get deeper
Stacking too many layers causes over-smoothing. It is a phenomenon where node embeddings become generally similar to each other and lose discriminative power. In the scatter plot above too, the embedding vectors can be seen becoming similar to each other as layers increase up to 5. So GNNs in practice usually stack only about 2 to 4 layers.

Embeddings growing more similar toward 5 layers
Besides this, GNNs have limitations called under-reaching and over-squashing. Under-reaching is the case where a node holding needed information is farther away than the number of layers so it cannot be reached at all, and over-squashing is the phenomenon where a lot of distant information passes through a narrow path and is compressed like a bottleneck and lost. The figure above shows under-reaching, over-smoothing, and over-squashing side by side.
References
Introduction to Graph Neural Networks (GNNs)
Message Passing Neural Networks (MPNN)
Overview on Graph Representation Learning
Two Node Embedding Approaches - Shallow and NN-based
Stanford CS224W notes: Node Representation Learning
Kumo.ai: The Weisfeiler-Leman Test and GNN Expressiveness
1-WL Expressiveness Is (Almost) All You Need
APXML: GNN Expressive Power and the WL Test
velog: 그래프 기계학습 - High-Order GNNs
Graph Laplacian 설명 (Unnormalized Laplacian, Normalized Laplacian)