Adjacency matrix

Adjacency matrix

In mathematics and computer science, an adjacency matrix is a means of representing which vertices (or nodes) of a graph are adjacent to which other vertices. Another matrix representation for a graph is the incidence matrix.

Specifically, the adjacency matrix of a finite graph G on n vertices is the n × n matrix where the non-diagonal entry aij is the number of edges from vertex i to vertex j, and the diagonal entry aii, depending on the convention, is either once or twice the number of edges (loops) from vertex i to itself. Undirected graphs often use the latter convention of counting loops twice, whereas directed graphs typically use the former convention. There exists a unique adjacency matrix for each isomorphism class of graphs (up to permuting rows and columns), and it is not the adjacency matrix of any other isomorphism class of graphs. In the special case of a finite simple graph, the adjacency matrix is a (0,1)-matrix with zeros on its diagonal. If the graph is undirected, the adjacency matrix is symmetric.

The relationship between a graph and the eigenvalues and eigenvectors of its adjacency matrix is studied in spectral graph theory.

Contents

Examples

The convention followed here is that an adjacent edge counts 1 in the matrix for an undirected graph.

Labeled graph Adjacency matrix
6n-graph2.svg \begin{pmatrix}
1 & 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}

Coordinates are 1-6.

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


The Nauru graph

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


Coordinates are 0-23.
White fields are zeros, colored fields are ones.

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


Directed Cayley graph of S4

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


As the graph is directed,
the matrix is not symmetric.

  • The adjacency matrix of a complete graph is all 1's except for 0's on the diagonal.
  • The adjacency matrix of an empty graph is a zero matrix.

Adjacency matrix of a bipartite graph

The adjacency matrix A of a bipartite graph whose parts have r and s vertices has the form

A = \begin{pmatrix} O & B \\ B^T & O \end{pmatrix},

where B is an r × s matrix and O is an all-zero matrix. Clearly, the matrix B uniquely represents the bipartite graphs. It is sometimes called the biadjacency matrix. Formally, let G = (U, V, E) be a bipartite graph with parts U = u1,...,ur and V = v1,...,vs. The biadjacency matrix is the r x s 0-1 matrix B in which bi,j = 1 iff (u_i, v_j) \in E.

If G is a bipartite multigraph or weighted graph then the elements bi,j are taken to be the number of edges between the vertices or the weight of the edge (ui,vj), respectively.

Properties

The adjacency matrix of an undirected simple graph is symmetric, and therefore has a complete set of real eigenvalues and an orthogonal eigenvector basis. The set of eigenvalues of a graph is the spectrum of the graph.

Suppose two directed or undirected graphs G1 and G2 with adjacency matrices A1 and A2 are given. G1 and G2 are isomorphic if and only if there exists a permutation matrix P such that

PA1P − 1 = A2.

In particular, A1 and A2 are similar and therefore have the same minimal polynomial, characteristic polynomial, eigenvalues, determinant and trace. These can therefore serve as isomorphism invariants of graphs. However, two graphs may possess the same set of eigenvalues but not be isomorphic.

If A is the adjacency matrix of the directed or undirected graph G, then the matrix An (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) walks of length n from vertex i to vertex j. This implies, for example, that the number of triangles in an undirected graph G is exactly the trace of A3 divided by 6.

The main diagonal of every adjacency matrix corresponding to a graph without loops has all zero entries.

For \left( d \right) -regular graphs, d is also an eigenvalue of A for the vector v=\left( 1,\dots,1 \right), and G is connected if and only if the multiplicity of d is 1. It can be shown that d is also an eigenvalue of A if G is a connected bipartite graph. The above are results of Perron–Frobenius theorem.

Variations

An (a, b, c)-adjacency matrix A of a simple graph has Aij = a if ij is an edge, b if it is not, and c on the diagonal. The Seidel adjacency matrix is a (−1,1,0)-adjacency matrix. This matrix is used in studying strongly regular graphs and two-graphs.[1]

The distance matrix has in position (i,j) the distance between vertices vi and vj . The distance is the length of a shortest path connecting the vertices. Unless lengths of edges are explicitly provided, the length of a path is the number of edges in it. The distance matrix resembles a high power of the adjacency matrix, but instead of telling only whether or not two vertices are connected, it gives the exact distance between them.

Data structures

For use as a data structure, the main alternative to the adjacency matrix is the adjacency list. Because each entry in the adjacency matrix requires only one bit, it can be represented in a very compact way, occupying only n2 / 8 bytes of contiguous space, where n is the number of vertices. Besides avoiding wasted space, this compactness encourages locality of reference.

In contrast, for a sparse graph adjacency lists win out, because they use no space to represent edges that are not present. Using a naïve array implementation on a 32-bit computer, an adjacency list for an undirected graph requires about 8e bytes of storage, where e is the number of edges.

Noting that a simple graph can have at most n2 edges, allowing loops, we can let d = e / n2 denote the density of the graph. Then, 8e > n2 / 8, or the adjacency list representation occupies more space precisely when d > 1 / 64. 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

  1. ^ Seidel, J. J. (1968). "Strongly Regular Graphs with (−1,1,0) Adjacency Matrix Having Eigenvalue 3". Lin. Alg. Appl. 1 (2): 281–298. doi:10.1016/0024-3795(68)90008-6. 

Further reading

External links

  • Fluffschack — an educational Java web start game demonstrating the relationship between adjacency matrices and graphs.

Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Seidel adjacency matrix — In mathematics, in graph theory, the Seidel adjacency matrix of a simple graph G (also called the Seidel matrix and the original name the (−1,1,0) adjacency matrix) is the symmetric matrix with a row and column for each vertex, having 0 on the… …   Wikipedia

  • Matrix theory — is a branch of mathematics which focuses on the study of matrices. Initially a sub branch of linear algebra, it has grown to cover subjects related to graph theory, algebra, combinatorics, and statistics as well.HistoryThe term matrix was first… …   Wikipedia

  • Adjacency list — In graph theory, an adjacency list is the representation of all edges or arcs in a graph as a list.If the graph is undirected, every entry is a set of two nodes containing the two ends of the corresponding edge; if it is directed, every entry is… …   Wikipedia

  • Matrix (mathematics) — Specific elements of a matrix are often denoted by a variable with two subscripts. For instance, a2,1 represents the element at the second row and first column of a matrix A. In mathematics, a matrix (plural matrices, or less commonly matrixes)… …   Wikipedia

  • Matrix addition — In mathematics, matrix addition is the operation of adding two matrices by adding the corresponding entries together. However, there are other operations which could also be considered as a kind of addition for matrices, the direct sum and the… …   Wikipedia

  • Distance matrix — In mathematics, computer science and graph theory, a distance matrix is a matrix (two dimensional array) containing the distances, taken pairwise, of a set of points. This matrix will have a size of N×N where N is the number of points, nodes or… …   Wikipedia

  • Logical matrix — A logical matrix, binary matrix, relation matrix, Boolean matrix, or (0,1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pair of finite sets. Contents 1… …   Wikipedia

  • Incidence matrix — In mathematics, an incidence matrix is a matrix that shows the relationship between two classes of objects. If the first class is X and the second is Y, the matrix has one row for each element of X and one column for each element of Y. The entry… …   Wikipedia

  • Binary matrix — In mathematics, particularly matrix theory, a binary matrix or (0,1) matrix is a matrix in which each entry is either zero or one. For example::egin{pmatrix}0 11 0end{pmatrix} is a 2 × 2 binary matrix.Frequently operations on binary matrices are …   Wikipedia

  • Laplacian matrix — In the mathematical field of graph theory the Laplacian matrix, sometimes called admittance matrix or Kirchhoff matrix, is a matrix representation of a graph. Together with Kirchhoff s theorem it can be used to calculate the number of spanning… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”