An adjacency matrix puts a graph’s connections into a table. Each row and column corresponds to a node; the cell where they meet records whether those nodes share an edge. It gives you a quick way to inspect relationships that would be cumbersome to describe one edge at a time. A zero means no connection, while a nonzero value means an edge is present. section 1.2.1 section 8.3
Read a small graph
For nodes A through E, the A row contains 1 under B and E and 0 under A, C, and D. So A connects to B and E, but not to itself. The B–A and A–B cells match: this graph is undirected, and its matrix is symmetric across the diagonal. section 1.2.1
Table 1.1 The adjacency matrix for the simple graph in figure 1.1
|
A
|
B
|
C
|
D
|
E
|
|
|---|---|---|---|---|---|
|
A
|
0
|
1
|
0
|
0
|
1
|
|
B
|
1
|
0
|
1
|
1
|
1
|
|
C
|
0
|
1
|
0
|
1
|
0
|
|
D
|
0
|
1
|
1
|
0
|
1
|
|
E
|
1
|
1
|
0
|
1
|
0
|
Use the five-node table to trace a row’s neighbors, then compare cells on opposite sides of the diagonal. section 1.2.1
The cell values also tell you what kind of connection is represented:
- In an unweighted graph, entries are 1 or 0. A weighted graph can use a larger value to make one edge more important than another. section 1.2.1
- A zero on the diagonal means that node has no edge to itself. An undirected graph has matching values across the diagonal. section 1.2.1
The matrix is one representation, not the only way to prepare graph data. An adjacency list records each node’s neighbors; an edge list records connected node pairs. In a data pipeline, choose a representation that fits the raw data, processing steps, and model. For example, relationships in a passenger table can become graph edges or an adjacency matrix, making family and social connections available for graph-based learning. section 8.3 section 1.2.5
The same matrix can be a learning target. A graph autoencoder compresses graph data into a latent representation, then learns to reconstruct edges—equivalently, to reconstruct the adjacency matrix. In a PyTorch Geometric implementation, a GNN encoder receives node features and an edge index; an inner-product decoder scores edges from the resulting node representations. A molecule-generation training loop goes further: it compares a predicted adjacency matrix with one built from the molecule’s edge index and edge attributes. section 5.2.2 section 5.4.4
Node ordering matters to the table’s layout, but a graph-learning method should not depend on an arbitrary ordering: consistently reordering its rows and columns should leave the result unaffected. A conventional two-dimensional adjacency matrix also describes pairwise edges; a hyperedge joining multiple nodes calls for a higher-dimensional incidence tensor. For evolving graphs, adjacency matrices from different times can instead be combined along the diagonal to include temporal information. section 1.2.4 section 1.2.2 section 6.6







