Newman's modularity clustering is a common way to get at this idea. He writes
A good division of a network into communities is not merely one in which there are few edges between communities; it is one in which there are fewer than expected edges between communities. If the number of edges between two groups is only what one would expect on the basis of random chance, then few thoughtful observers would claim this constitutes evidence of meaningful community structure. On the other hand, if the number of edges between groups is significantly less than we expect by chance, or equivalent if the number within groups is significantly more, then it is reasonable to conclude that something interesting is going on.
This idea, that true community structure in a network corresponds to a statistically surprising arrangement of edges, can be quantified by using the measure known as modularity (17). The modularity is, up to a multiplicative constant, the number of edges falling within groups minus the expected number in an equivalent network with edges placed at random. (A precise mathematical formulation is given below.)
M. E. J. Newman, "Modularity and community structure in networks", PNAS
Note that Newman's article proposes a strategy of recursively partitioning a network. This can be slow for very large networks with many modular clusters. Instead, the Louvian algorihtm is a faster way to get at modularity; see "Fast unfolding of communities in large networks" by Vincent D. Blondel, Jean-Loup Guillaume, Renaud Lambiotte, Etienne Lefebvre