A community in a network is a group of vertices such that there is a higher density of edges within the group than between them.
Given a graph g={V, E}, let the vertex set V be partitioned into k subsets V=Vi such that each subset belongs to one community. The community modularity Q of this partition is defined as
Q= (eii - aii2)
where eii is the percentage of number of edges that has both ends in community Vi, and ai is the percentage of edges that start from community Vi. In other words,
eii = |{(u, v)|uVi, vVi, (u, v)E}|/|E|
and
ai = |{(u, v)|uVi, (u, v)E}|/|E|.
The community modularity Q is a number less than or equal to 1. A large positive value indicates that the vertex partition gives significant community structure.