An algebraic analysis of the graph modularity