IncidenceMatrix

IncidenceMatrix[g]
gives the vertex-edge incidence matrix of the graph g.

DetailsDetails

  • IncidenceMatrix returns a SparseArray object, which can be converted to an ordinary matrix using Normal.
  • For an undirected graph, an entry of the incidence matrix is given by:
  • 0vertex is not incident to edge
    1vertex is incident to edge
    2vertex is incident to edge and a self-loop
  • For a directed graph, an entry of the incidence matrix is given by:
  • 0vertex is not incident to edge
    1vertex is incident to edge and is the head of
    -1vertex is incident to edge and is the tail of
    2vertex is incident to edge and a self-loop
  • The vertices are assumed to be in the order given by VertexList[g] and the edges are assumed to be in the order given by EdgeList[g].
  • The incidence matrix for a graph will have an × matrix, where is the number of vertices and is the number of edges, counting multiplicity.

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

The incidence matrix of an undirected graph:

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

The incidence matrix of a directed graph:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »