k i is the degree of vertex i, so 2m is the expected number of edges between i and j in a random graph.
modularity is highest when nodes in a cluster are highly interconnected, but sparsely connected to nodes in different clusters.