This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

AdjacencyMatrix

AdjacencyMatrix[g]
gives the vertex-vertex adjacency matrix of the graph g.
  • 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.
The adjacency matrix of an undirected graph:
The adjacency matrix of a directed graph:
The adjacency matrix of an undirected graph:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=
 
The adjacency matrix of a directed graph:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=
The adjacency matrix of an undirected graph is symmetric:
The adjacency matrix of a directed graph can be unsymmetric:
The adjacency matrix of the graph with self-loops has diagonal entries:
AdjacencyMatrix works with large graphs:
Use MatrixPlot to visualize the matrix:
Compute the degree for an undirected graph from its adjacency matrix:
Compute the in-degree for a directed graph from its adjacency matrix:
Compute the out-degree for a directed graph from its adjacency matrix:
Count the number of paths between all vertices in at most steps for a directed graph:
There are two paths from 1 to 5 in two steps:
Count the number of paths from to in at most steps for a directed graph:
Compute the cocitation matrix, where the cocitation for two vertices is the number of common ancestors:
The cocitation between and :
Compute the coupling matrix, where the coupling between two vertices is the number of common descendants:
The coupling between and :
Rows and columns of the adjacency matrix follow the order given by VertexList:
Use VertexIndex to find the matrix row and column corresponding to a pair of vertices:
Check whether and are adjacent vertices:
Compare with EdgeQ:
An undirected graph has a symmetric adjacency matrix:
Use AdjacencyGraph to construct a graph from an adjacency matrix:
The main diagonal of the adjacency matrix for any graph without loops has all zero entries:
The number of rows or columns of the adjacency matrix is equal to the number of vertices:
A d-regular graph g is connected iff the multiplicity of its d eigenvalue is one:
The graph is 3-regular:
The multiplicity is one so it is connected:
For a complete graph all entries outside the diagonal are ones in the adjacency matrix:
A complete -partite graph has zero diagonal block entries:
A TuranGraph is bipartite:
A StarGraph has ones in the first column and first row only:
For a path, rows of an adjacency matrix will contain one or two elements:
The adjacency matrix of a line graph can be computed by its IncidenceMatrix:
An empty graph has no adjacency matrix:
New in 8