GraphTheory - Maple Programming Help

Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/AdjacencyMatrix

GraphTheory

Parameters

 G - graph

Description

 • The AdjacencyMatrix command returns the adjacency matrix of a graph G whose rows and columns are indexed by the vertices. The entry $i,j$ of this matrix is 1 if there is an edge from vertex i to vertex j and 0 otherwise.
 • The default output is an n by n Matrix with the following properties:
 – If G is directed or undirected: datatype=anything and order=C_order
 – If G is undirected: shape=symmetric, storage=triangular[upper],
 – If G is directed: storage=rectangular, shape=[]
 – If G is sparse, i.e., |E| << |V|^2 then storage=sparse will be used.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left[1,2,3,4\right],\mathrm{Trail}\left(1,2,3,4,1\right)\right)$
 ${G}{:=}{\mathrm{Graph 1: an undirected unweighted graph with 4 vertices and 4 edge\left(s\right)}}$ (1)
 > $\mathrm{AdjacencyMatrix}\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]$ (2)
 > $\mathrm{Neighbors}\left(G\right)$
 $\left[\left[{2}{,}{4}\right]{,}\left[{1}{,}{3}\right]{,}\left[{2}{,}{4}\right]{,}\left[{1}{,}{3}\right]\right]$ (3)
 > $H≔\mathrm{Digraph}\left(\left[1,2,3,4\right],\mathrm{Trail}\left(1,2,3,4,1\right)\right)$
 ${H}{:=}{\mathrm{Graph 2: a directed unweighted graph with 4 vertices and 4 arc\left(s\right)}}$ (4)
 > $\mathrm{AdjacencyMatrix}\left(H\right)$
 $\left[\begin{array}{rrrr}{0}& {1}& {0}& {0}\\ {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {1}\\ {1}& {0}& {0}& {0}\end{array}\right]$ (5)
 > $\mathrm{Departures}\left(H\right)$
 $\left[\left[{2}\right]{,}\left[{3}\right]{,}\left[{4}\right]{,}\left[{1}\right]\right]$ (6)