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

WeightedAdjacencyMatrix

WeightedAdjacencyMatrix[g]
gives the adjacency matrix of edge weights of the graph g.
  • An entry of the weighted adjacency matrix is the weight of a directed edge from vertex to vertex . If there is no edge the weight is taken to be 0.
  • An edge without explicit EdgeWeight specified is taken to have weight 1.
  • An undirected edge is interpreted as two directed edges with opposite directions and the same weight.
  • The vertices are assumed to be in the order given by VertexList[g].
  • The weighted adjacency matrix for a graph will have dimensions ×, where is the number of vertices.
The weighted adjacency matrix of an undirected graph:
The weighted adjacency matrix of a directed graph:
The weighted adjacency matrix of an undirected graph:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=
 
The weighted adjacency matrix of a directed graph:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=
The weighted adjacency matrix of an undirected graph is symmetric:
The weighted adjacency matrix of a directed graph can be unsymmetric:
The weighted adjacency matrix of the graph with self-loops has diagonal entries:
WeightedAdjacencyMatrix works with large graphs:
Use MatrixPlot to visualize the matrix:
Rows and columns of the weighted adjacency matrix follow the order given by VertexList:
Use WeightedAdjacencyGraph to construct a graph from a weighted adjacency matrix:
The number of rows or columns is equal to the number of vertices:
The main diagonals for a loop-free graph are all zeros:
New in 8