If e ij represents the number of edges between clusters i and j, C represents an entire cluster set of nodes, and m represents total number of edges in the graph, modularity for the graph is given by Q:
In other words, modularity Q can be calculated as: