 IncidenceMatrix - Maple Help

GraphTheory

 IncidenceMatrix
 construct incidence matrix Calling Sequence IncidenceMatrix(G) IncidenceMatrix(G, reverse) Parameters

 G - graph reverse - (literal) reverse the sign convention for digraphs Description

 • IncidenceMatrix(G) returns the incidence matrix of a graph G whose rows are indexed by the vertices and columns by the edges of G.  The order of the edges is defined by Edges(G).
 • If G is undirected the entry $i,j$ of this $\left\{0,1\right\}$-matrix is $1$ iff vertex i is incident to edge j.
 • If G is directed the entry $i,j$ of this $\left\{-1,0,1\right\}$-matrix is $1$ iff vertex i is the head of arc j and $-1$ iff vertex i is the tail of arc j.
 • If G is directed and reverse is specified, the entry $i,j$ of this $\left\{-1,0,1\right\}$-matrix is $-1$ iff vertex i is the head of arc j and $1$ iff vertex i is the tail of arc j. Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{CompleteGraph}\left(4\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected graph with 4 vertices and 6 edge\left(s\right)}}$ (1)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{1}{,}{4}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{2}{,}{4}\right\}{,}\left\{{3}{,}{4}\right\}\right\}$ (2)
 > $\mathrm{IncidenceMatrix}\left(G\right)$
 $\left[\begin{array}{cccccc}{1}& {1}& {1}& {0}& {0}& {0}\\ {1}& {0}& {0}& {1}& {1}& {0}\\ {0}& {1}& {0}& {1}& {0}& {1}\\ {0}& {0}& {1}& {0}& {1}& {1}\end{array}\right]$ (3)
 > $\mathrm{DG}≔\mathrm{Digraph}\left(\mathrm{Trail}\left(1,2,3,4,5,3\right),\mathrm{Trail}\left(1,5,2,4,1\right)\right)$
 ${\mathrm{DG}}{≔}{\mathrm{Graph 2: a directed graph with 5 vertices and 9 arc\left(s\right)}}$ (4)
 > $\mathrm{Edges}\left(\mathrm{DG}\right)$
 $\left\{\left[{1}{,}{2}\right]{,}\left[{1}{,}{5}\right]{,}\left[{2}{,}{3}\right]{,}\left[{2}{,}{4}\right]{,}\left[{3}{,}{4}\right]{,}\left[{4}{,}{1}\right]{,}\left[{4}{,}{5}\right]{,}\left[{5}{,}{2}\right]{,}\left[{5}{,}{3}\right]\right\}$ (5)
 > $\mathrm{IncidenceMatrix}\left(\mathrm{DG}\right)$
 $\left[\begin{array}{ccccccccc}{-1}& {-1}& {0}& {0}& {0}& {1}& {0}& {0}& {0}\\ {1}& {0}& {-1}& {-1}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {1}& {0}& {-1}& {0}& {0}& {0}& {1}\\ {0}& {0}& {0}& {1}& {1}& {-1}& {-1}& {0}& {0}\\ {0}& {1}& {0}& {0}& {0}& {0}& {1}& {-1}& {-1}\end{array}\right]$ (6)
 > $\mathrm{IncidenceMatrix}\left(\mathrm{DG},\mathrm{reverse}\right)$
 $\left[\begin{array}{ccccccccc}{1}& {1}& {0}& {0}& {0}& {-1}& {0}& {0}& {0}\\ {-1}& {0}& {1}& {1}& {0}& {0}& {0}& {-1}& {0}\\ {0}& {0}& {-1}& {0}& {1}& {0}& {0}& {0}& {-1}\\ {0}& {0}& {0}& {-1}& {-1}& {1}& {1}& {0}& {0}\\ {0}& {-1}& {0}& {0}& {0}& {0}& {-1}& {1}& {1}\end{array}\right]$ (7)