Digital connectedness: An algebraic approach

Let E be the incidence matrix of a graph G having m nodes; then the number of connected components of G is equal to m - r, where r is the rank of E. In particular, if G represents an adjacency relation between points in a digital picture (or higher-dimensional array), this shows that the connected components of points can be counted by computing the rank of E. Two proofs of this result are given, one based on results from algebraic topology and the other based on a self-contained graph-theoretic argument. The former proof can be generalized to yield a method of counting holes.