BUILT-IN WOLFRAM LANGUAGE SYMBOL

# AdjacencyMatrix

AdjacencyMatrix[g]

gives the vertex–vertex adjacency matrix of the graph g.

## DetailsDetails

- An adjacency matrix is also known as a connectivity matrix.
- AdjacencyMatrix returns a SparseArray object, which can be converted to an ordinary matrix using Normal.
- An entry of the adjacency matrix is the number of directed edges from vertex to vertex .
- The diagonal entries count the number of loops for vertex .
- An undirected edge is interpreted as two directed edges with opposite directions.
- The vertices are assumed to be in the order given by VertexList[g].
- The adjacency matrix for a graph will have dimensions ×, where is the number of vertices.

## BackgroundBackground

- AdjacencyMatrix returns a square matrix whose rows and columns correspond to the vertices of a graph and whose elements are non-negative integers that give the numbers of (directed) edges from vertex to vertex . An adjacency matrix provides a useful representation of a graph that can be used to compute many properties by means of simple operations on matrices. Examples of computations on graphs that can be performed efficiently given an adjacency matrix include vertex degrees, in- and out-degrees, counts of paths between vertices in at most steps, graph spectrum, and many others.
- For a graph on vertices, the adjacency matrix has dimensions . For an undirected graph, the adjacency matrix is symmetric. For a finite simple graph (i.e., an undirected, unweighted graph with no self-loops or multiple edges), the adjacency matrix must have 0s on the diagonal, and its matrix elements are given by if is adjacent to and otherwise.
- An explicit adjacency matrix representation of a graph based on a particular ordering of vertices is unique. However, since the vertices of a graph may be permuted, there is a class of adjacency matrices that represents the corresponding isomorphism class of graphs. Nonetheless, the adjacency matrix for an isomorphism class is unique modulo permutation of rows and columns of the matrix (corresponding precisely to relabeling of the graph vertices).
- AdjacencyGraph can be used to construct a graph from an adjacency matrix. IncidenceMatrix gives another matrix representation of a graph that gives vertex-edge relationships instead of vertex-vertex relationships. AdjacencyMatrix does not take graph weights into account, so WeightedAdjacencyMatrix must be used when computing the adjacency matrix of a graph having edge weights.

Introduced in 2010

(8.0)

© 2015 Wolfram. All rights reserved.