gives the graph with adjacency matrix amat.


gives the graph with vertices vi and adjacency matrix amat.

Details and Options

Background & Context

  • AdjacencyGraph constructs a graph from an adjacency matrix representation of an undirected or directed graph. An adjacency matrix is a square matrix whose rows and columns correspond to the vertices of a graph and whose elements aij are non-negative integers that give the numbers of (directed) edges from vertex vi to vertex vj. Adjacency matrices with diagonal entries create self-loops.
  • The option DirectedEdges (with possible values Automatic, True, or False) may be used to control whether an undirected or directed graph is constructed. By default, AdjacencyGraph returns an undirected graph if the input matrix is symmetric and a directed graph otherwise.
  • AdjacencyGraph takes the same options as Graph (e.g. EdgeStyle, VertexStyle, EdgeLabels, VertexLabels, GraphLayout, VertexCoordinates, etc.). AdjacencyGraph does not take graph weights into account, so WeightedAdjacencyGraph must be used when constructing a graph from a weighted adjacency matrix.
  • AdjacencyList returns a list of vertices adjacent to a given vertex vi and therefore corresponds to a list of the positions of nonzero elements in the i^(th) column (and, in the case of undirected graphs, the i^(th) row) of the adjacency matrix. The entire adjacency matrix of any graph (including a graph constructed using AdjacencyGraph) may be returned using AdjacencyMatrix. IncidenceGraph uses an incidence matrix representation instead of an adjacency matrix to construct a graph.


open all close all

Basic Examples  (2)

Construct a graph from an adjacency matrix:

Click for copyable input

A symmetric adjacency matrix results in an undirected graph:

Click for copyable input

Scope  (7)

Options  (83)

Applications  (2)

Properties & Relations  (6)

Introduced in 2010