WeightedAdjacencyMatrix

WeightedAdjacencyMatrix[g]

gives the adjacency matrix of edge weights of the graph g.

WeightedAdjacencyMatrix[{vw,}]

uses rules vw to specify the graph g.

Details and Options

  • WeightedAdjacencyMatrix returns a SparseArray object, which can be converted to an ordinary matrix using Normal.
  • An entry wij of the weighted adjacency matrix is the weight of a directed edge from vertex νi to vertex νj. 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 vi 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.

Examples

open allclose all

Basic Examples  (2)

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=

Scope  (5)

Properties & Relations  (4)

See Also

WeightedAdjacencyGraph  WeightedGraphQ  EdgeWeight  VertexWeight  AdjacencyMatrix  IncidenceMatrix  KirchhoffMatrix

Introduced in 2010
(8.0)
| Updated in 2015
(10.3)