Nepedia
Back to Discover
Advanced Reader
🔢

Adjacency matrix

math Maturity 7-9 Next article →

An adjacency matrix is a square grid used to represent a finite graph. In graph theory, a graph consists of vertices, which are points, and edges, which are lines connecting them. The matrix serves as a mathematical map for these connections. Each element in the matrix indicates whether a specific pair of vertices is adjacent. This means the matrix turns a visual network into a structured set of numbers. This transformation allows mathematicians and computer scientists to use algebra to study complex networks.

6n-graph2
6n-graph2

To build an adjacency matrix, you create a grid with the same number of rows and columns as there are vertices. For a simple graph, the matrix is a (0,1)-matrix. This means every entry is either a 0 or a 1. A 1 represents an existing edge between two vertices. A 0 represents the absence of an edge. In a simple graph, loops are not allowed. A loop is an edge that connects a vertex to itself. Because of this, the diagonal elements from the top-left to the bottom-right are always 0.

Symmetric group 4; Cayley graph 4,9 (adjacency matrix)
Symmetric group 4; Cayley graph 4,9 (adjacency matrix)

Different types of graphs change how the matrix looks. If a graph is undirected, the edges are bidirectional. This means the connection works both ways. In these cases, the adjacency matrix is symmetric. A symmetric matrix looks like a mirror image across its main diagonal. If the graph is directed, edges have a specific direction. The matrix may be asymmetric in directed graphs. You can define these matrices in two ways. One way shows an edge from vertex $i$ to vertex $j$. The other way shows an edge from $j$ to $i$. Social network analysis often uses the first definition. Physics and network science often use the second.

Symmetric group 4; Cayley graph 1,5,21 (adjacency matrix)
Symmetric group 4; Cayley graph 1,5,21 (adjacency matrix)

There are several specialized versions of this matrix. A bipartite graph has vertices split into two distinct parts. For these, you can use a smaller biadjacency matrix. This smaller grid uniquely represents the connections between the two parts. Another version is the distance matrix. Instead of showing if vertices are connected, it shows the shortest path length. The distance is the number of edges in the shortest path between two points. There is also the Seidel adjacency matrix. This is a (-1,0,1)-matrix used to study strongly regular graphs.

Symmetric group 4; Cayley graph 1,5,21 (Nauru Petersen); numbers
Symmetric group 4; Cayley graph 1,5,21 (Nauru Petersen); numbers

Algebraic properties provide deep insights into a graph's structure. One major area of study is spectral graph theory. This field looks at the eigenvalues and eigenvectors of the adjacency matrix. The set of these eigenvalues is called the spectrum of the graph. For undirected simple graphs, the matrix is symmetric. This ensures it has a complete set of real eigenvalues. The largest eigenvalue is always less than or equal to the maximum degree of the vertices. In bipartite graphs, if a number is an eigenvalue, its opposite is also an eigenvalue.

Symmetric group 4; Cayley graph 4,9; numbers
Symmetric group 4; Cayley graph 4,9; numbers

Matrix math can also reveal physical patterns within the graph. If you multiply the adjacency matrix by itself, the resulting matrix tells you about walks. The element in the $i$-th row and $j$-th column shows how many walks of length $k$ exist between those vertices. This is very useful for counting triangles. In an undirected graph, you can find the number of triangles by taking the trace of the matrix cubed and dividing by 6. The trace is the sum of the diagonal elements. This method accounts for the fact that each triangle is counted multiple times.

Symmetric group 4; Cayley graph 1,5,21 (adjacency matrix)
Symmetric group 4; Cayley graph 1,5,21 (adjacency matrix)

In computer science, the adjacency matrix is a vital data structure. It is very efficient for testing if an edge exists between two specific vertices. This check happens almost instantly. However, matrices can be wasteful for sparse graphs. A sparse graph has many vertices but very few edges. In these cases, a large portion of the matrix is filled with zeros. To save space, programmers might use an adjacency list instead. An adjacency list only stores the connections that actually exist. This makes it much more memory-efficient for large, thin networks.

Symmetric group 4; Cayley graph 4,9; numbers
Symmetric group 4; Cayley graph 4,9; numbers
661 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (5)
File:6n-graph2.svg
6n-graph2.svg
File:Symmetric group 4; Cayley graph 1,5,21 (Nauru Petersen); numbers.svg
Symmetric group 4; Cayley graph 1,5,21...
File:Symmetric group 4; Cayley graph 1,5,21 (adjacency matrix).svg
Symmetric group 4; Cayley graph 1,5,21...
File:Symmetric group 4; Cayley graph 4,9; numbers.svg
Symmetric group 4; Cayley graph 4,9; numbers.svg
File:Symmetric group 4; Cayley graph 4,9 (adjacency matrix).svg
Symmetric group 4; Cayley graph 4,9...
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.