Macaulay2 » Documentation
Packages » EdgeIdeals :: incidenceMatrix
next | previous | forward | backward | up | index | toc

incidenceMatrix -- returns the incidence matrix of a hypergraph

Synopsis

Description

This function returns the incidence matrix of the given hypergraph H. The rows of the matrix are indexed by the variables of the hypergraph, and the columns are indexed by the edges. The (i,j)^{th} entry in the matrix is 1 if vertex i is contained in edge j, and is 0 otherwise. The order of the rows and columns are determined by the internal order of the vertices and edges. See edges and vertices(HyperGraph).

i1 : S = QQ[a..f];
i2 : g = hyperGraph {a*b*c*d,c*e,e*f}

o2 = HyperGraph{"edges" => {{a, b, c, d}, {c, e}, {e, f}}}
                "ring" => S
                "vertices" => {a, b, c, d, e, f}

o2 : HyperGraph
i3 : incidenceMatrix g

o3 = | 1 0 0 |
     | 1 0 0 |
     | 1 1 0 |
     | 1 0 0 |
     | 0 1 1 |
     | 0 0 1 |

              6       3
o3 : Matrix ZZ  <-- ZZ
i4 : T = QQ[f,e,d,c,b,a];
i5 : h = hyperGraph {a*b*c*d,c*e,e*f}

o5 = HyperGraph{"edges" => {{f, e}, {e, c}, {d, c, b, a}}}
                "ring" => T
                "vertices" => {f, e, d, c, b, a}

o5 : HyperGraph
i6 : incidenceMatrix h -- although the same graph, matrix is different since variables have different ordering

o6 = | 1 0 0 |
     | 1 1 0 |
     | 0 0 1 |
     | 0 1 1 |
     | 0 0 1 |
     | 0 0 1 |

              6       3
o6 : Matrix ZZ  <-- ZZ

See also

Ways to use incidenceMatrix :

For the programmer

The object incidenceMatrix is a method function.