sparsity function

Compute the sparsity of a graph