Wrote incidence matrix tool