Graphs as Data: Adjacency and Node Features
Before any graph neural network can run, a graph has to be turned into numbers — an adjacency matrix recording who is connected to whom, and a feature matrix recording what each node itself looks like — and everything a GNN does starts from these two objects.
Prerequisites: Graph Theory Basics, Graph Representations
A neural network needs numbers to operate on — matrices it can multiply, add, and take gradients through. A graph, as a mental object, is nodes and connections: a network of counterparties, a supply chain, a correlation structure between assets. To make a graph usable by any neural network, including a graph neural network, it first has to be converted into two plain numeric objects: a matrix describing the connections, and a matrix describing what each node is. Every graph-ML method, no matter how sophisticated, starts from exactly these two ingredients.
The analogy: a seating chart and a set of name tags
Think of a graph as a room full of people at a mixer. The adjacency matrix is the seating chart's connection list — a record of who is standing next to whom, with nothing at all about who any individual person actually is. The node feature matrix is the set of name tags, one per person, listing whatever attributes matter — job title, years of experience, department — with nothing about the room's layout. Neither object alone describes the mixer fully: you need the seating chart to know who can talk to whom, and the name tags to know anything about the individuals doing the talking. A graph neural network's entire job is to combine both.
The two matrices, defined
For a graph with nodes, the adjacency matrix is , with if nodes and are connected (an edge exists) and otherwise — for a weighted graph, can instead hold the edge's weight, e.g. exposure size between two counterparties. The node feature matrix is , one row per node, each row a -dimensional vector of that node's own attributes — for a company in a supply-chain graph, perhaps revenue, sector code, and credit rating.
In words: answers "who is connected to whom," entirely structural, no node attributes involved; answers "what does each node look like," entirely attribute-based, no connection information involved. A graph neural network's first layer typically combines them by having each node gather its neighbors' rows of , using to know which rows count as neighbors.
Worked example 1: building both matrices for a tiny counterparty network
Four firms, , with trading relationships , , , and . The adjacency matrix (rows/columns in that order):
Row for firm reads — connected to , , and , matching the three edges touching above. Now suppose each firm has a 2-feature vector (leverage ratio, sector code): . Firm 's row, , is its leverage and sector — completely independent information from the adjacency row just computed; you need both to know that " is a highly levered, sector-1 firm connected to three others."
Worked example 2: one step of neighbor aggregation using both matrices
A common first GNN operation averages each node's own features with its neighbors' features. For firm , neighbors are and (from row ), with features and ; 's own feature is . Averaging all three: . Firm , by contrast, has only one neighbor, , with feature ; averaging 's own with just that one neighbor: . Notice how much 's updated feature shifts toward 's values simply because has only one connection — a direct, numeric illustration of why a node's position in (how many and which neighbors it has) directly shapes what a GNN computes for it, on top of whatever says about the node itself.
Think of the adjacency matrix the same way you'd think of the transformation matrix above: it's a fixed matrix that reshapes what a vector of node features becomes after one round of neighbor mixing, exactly as a 2×2 matrix reshapes a vector on the plane.
Every graph, before any model touches it, is reduced to two matrices: an adjacency matrix recording connections with no information about the nodes themselves, and a feature matrix recording node attributes with no information about connections — a graph neural network's job is combining the two, typically by having each node aggregate its neighbors' feature rows as identified by .
What this means in practice
This split matters for what a graph-ML pipeline has to assemble: a correlation-based asset graph needs a thresholding rule to turn continuous correlations into an , plus a choice of directed (payment flow) versus undirected (mutual exposure); a firm's feature vector in is chosen and normalized entirely separately from that structure.
A richer cannot substitute for missing structure in , or vice versa. A firm's own financials say nothing about contagion risk from its counterparties, and the counterparty structure alone says nothing about how exposed the firm itself is; a GNN's value comes from needing both together, and a pipeline that builds only one well loses exactly the information a graph model was meant to add.
Related concepts
Practice in interviews
Further reading
- Hamilton, Graph Representation Learning (2020), Ch. 1-2