AdjacencyMatrix

As of Version 10, all the functionality of the GraphUtilities package is built into the Wolfram System. >>

AdjacencyMatrix[g]
gives the SparseArray object representing the graph g.


gives the SparseArray object representing the graph g, adding additional unconnected vertices, if necessary, to create a graph with n vertices.

DetailsDetails

  • AdjacencyMatrix functionality is now available in the built-in Wolfram Language function AdjacencyMatrix.
  • To use , you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
  • The graph g can be specified by a rule list, an adjacency matrix, or the Combinatorica representation of a graph.
  • The rows/columns of the SparseArray object correspond to vertices in the order returned by VertexList[g].

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

In[1]:=
Click for copyable input

The adjacency matrix of a graph specified by a rule list:

In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]//MatrixForm=

This function has been superseded by AdjacencyMatrix in the Wolfram System:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]//MatrixForm=