Adjacency Matrix Website Links For
Matrix
 

Information About

Adjacency Matrix




For Sparse Graph s, that is graphs with few edges, an Adjacency List is often the preferred representation because it uses less space. An alternative matrix representation for a graph is the Incidence Matrix .

The relationship between a graph and its adjacency matrix is studied in Spectral Graph Theory .


EXAMPLES


The adjacency matrix for the following Vertex Labeled Graph
:
is
:\begin{pmatrix}
2 & 1 & 0 & 0 & 1 & 0\
1 & 0 & 1 & 0 & 1 & 0\
0 & 1 & 0 & 1 & 0 & 0\
0 & 0 & 1 & 0 & 1 & 1\
1 & 1 & 0 & 1 & 0 & 0\
0 & 0 & 0 & 1 & 0 & 0\
\end{pmatrix}.


PROPERTIES


The adjacency matrix of an undirected graph is Symmetric , and therefore has a complete set of Eigenvalue s and orthogonal Eigenvector basis. The set of eigenvalues of a graph is the spectrum of the graph.

Suppose two directed or undirected graphs ''G''1 and ''G''2 with adjacency matrices ''A''1 and ''A''2 are given. ''G''1 and ''G''2 are Isomorphic if and only if there exists a Permutation Matrix ''P'' such that

PA


In particular, ''A''1 and ''A''2 are for details.

Note, however, that the converse is not true: two graphs may possess the same set of eigenvalues but not be isomorphic (one cannot 'hear' the shape of a graph). The multiplication with the permutation matrix can be visualized as a relabeling of the vertices.

If ''A'' is the adjacency matrix of the directed or undirected graph ''G'', then the matrix ''A''''n'' (i.e. the Matrix Product of ''n'' copies of ''A'') has an interesting interpretation: the entry in row ''i'' and column ''j'' gives the number of (directed or undirected) paths of length ''n'' from vertex ''i'' to vertex ''j''.

The matrix ''I'' − ''A'' (where ''I'' denotes the ''n''-by-''n'' for matrices:
:(''I'' − ''A'')−1 = ''I'' + ''A'' + ''A''2 + ''A''3 + ...
corresponding to the fact that the number of paths from ''i'' to ''j'' equals the number of paths of length 0 plus the number of paths of length 1 plus the number of paths of length 2 etc.
The main diagonal of every adjacency matrix corresponding to a graph without loops has all zero entries.


VARIATIONS


The (0,−1,1)-adjacency matrix of a simple graph has zero on the diagonal and entry ''a''''ij'' = −1 if ''ij'' is an edge and 1 if it is not. This matrix is used in studying Strongly Regular Graph s and Two-graph s.

A Distance Matrix is basically the same as a adjacency matrix with the difference that, instead of only providing information whether or not two vertices are connected, also tells about the ''costs'' or ''distances'' (depending on context) between them.


TRADE-OFFS AS A DATA STRUCTURE


When used as a Data Structure , the main competitor for the adjacency matrix is the Adjacency List . Because each entry in the adjacency matrix requires only one bit, they can be represented in a very compact way, occupying only ''n''2/8 bytes of contiguous space, where ''n'' is the number of vertices. Besides just avoiding wasted space, this compactness encourages Locality Of Reference .

On the other hand, for a sparse graph, adjacency lists win out, because they do not use any space to represent edges which are ''not'' present. Using a naive Linked List implementation on a 32-bit computer, an adjacency list for an undirected graph requires about 16''e'' bytes of storage, where ''e'' is the number of edges.

Noting that a simple graph can have at most ''n''2 edges, allowing loops, we can let ''d'' = ''e''/''n''2 denote the ''density'' of the graph. Then, 16''e'' > ''n''2/8, or the adjacency list representation occupies more space, precisely when ''d'' > 1/128. Thus a graph must be sparse indeed to justify an adjacency list representation.

Besides the space tradeoff, the different data structures also facilitate different operations. Finding all vertices adjacent to a given vertex in an adjacency list is as simple as reading the list. With an adjacency matrix, an entire row must instead be scanned, which takes O (n) time. Whether there is an edge between two given vertices can be determined at once with an adjacency matrix, while requiring time proportional to the minimum degree of the two vertices with the adjacency list.


REFERENCES