The adjacency matrix of a graph is a matrix in which, for example, the entry in row and column () is the number of edges joining nodes C and F.

Difference to Incidence Matrices

The adjacency matrix represents relations between node-node pairs. An incidence matrix represents relations between node-vertex pairs.

Loops

A loop is a single edge connecting a node to itself. If node A has a loop, then its corresponding entry on the adjacency matrix will have value 1, as a loop is considered 1 edge.

Example

An undirected graph on the left and the adjacency matrix on the right: A directed graph example:

Target
ABCD
SourceA0000
B1010
C0001
D0100
Note how the adjacency matrix is no longer symmetric, compared to the undirected graph example.