An adjacency matrix is a square matrix used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not within the graph.

If the graph is undirected, the adjacency matrix is symmetric.

Counting towards an adjacency matrix representation involves having the columns and rows of the matrix represent whether or not the vertex of the graph has an edge connecting another vertex. If it does, write down the number of edges. In a simple undirected graph, that will always be one if it’s connected. In the case of a non-simple graph, self loops are counted as double, in order to maintain the property where the degree of the vertex is equal to the sum of that column or row.

For example, the following graph can be represented by the following adjacency matrix:

Qs

Why should a matrix be represented by an adjacency matrix?