Computing Cliques and Cavities in Networks