networks

 construct the adjacency matrix of a graph

Parameters

 G - graph or network

Description

 • Important: The networks package has been deprecated.  Use the superseding command GraphTheory[AdjacencyMatrix] instead.
 • Two vertices are said to be adjacent if one or more edges connect them.  This routine constructs an adjacency matrix whose rows and columns are indexed by the vertices and whose i-jth entry is the number of edges from vertex i to vertex j.
 • This routine is normally loaded via the command with(networks) but may also be referenced using the full name networks[adjacency](...).

Examples

Important: The networks package has been deprecated.  Use the superseding command GraphTheory[AdjacencyMatrix] instead.

 > $\mathrm{with}\left(\mathrm{networks}\right):$
 > $G≔\mathrm{cycle}\left(4\right):$
 > $\mathrm{adjacency}\left(G\right)$
 $\left[\begin{array}{rrrr}{0}& {1}& {0}& {1}\\ {1}& {0}& {1}& {0}\\ {0}& {1}& {0}& {1}\\ {1}& {0}& {1}& {0}\end{array}\right]$ (1)
 > $G≔\mathrm{complete}\left(4\right):$
 > $\mathrm{adjacency}\left(G\right)$
 $\left[\begin{array}{rrrr}{0}& {1}& {1}& {1}\\ {1}& {0}& {1}& {1}\\ {1}& {1}& {0}& {1}\\ {1}& {1}& {1}& {0}\end{array}\right]$ (2)
 > $\mathrm{addedge}\left(\left\{2,3\right\},G\right)$
 ${\mathrm{e7}}$ (3)
 > $\mathrm{adjacency}\left(G\right)$
 $\left[\begin{array}{rrrr}{0}& {1}& {1}& {1}\\ {1}& {0}& {2}& {1}\\ {1}& {2}& {0}& {1}\\ {1}& {1}& {1}& {0}\end{array}\right]$ (4)
 > $\mathrm{addedge}\left(\left[1,2\right],G\right)$
 ${\mathrm{e8}}$ (5)
 > $\mathrm{adjacency}\left(G\right)$
 $\left[\begin{array}{rrrr}{0}& {2}& {1}& {1}\\ {1}& {0}& {2}& {1}\\ {1}& {2}& {0}& {1}\\ {1}& {1}& {1}& {0}\end{array}\right]$ (6)