I have a number of empirical networks that tend to show bipolarization patterns, meaning that there are precisely two communities. In some networks, the two communities are very clearly separated (like the one shown below) while there is a structure that can be hardly distinguished from a core-periphery structure, multiple communities, or random graphs in other cases. I would like to quantify the extent to which the network falls into precisely two communities. The networks have weighted edges and are undirected. So far, my thoughts have revolved around the following things:
The use of Newman's modularity maximization through spectral partitioning as described in this paper, where one would stop after the first division into two groups and then use the modularity score as a quality criterion. However, I have not found an implementation that would allow me to specify the number of groups or to stop after the first cut.
Compute Euclidean distance matrix of nodes and apply k-means clustering (or any other clustering technique that lets me pre-specify the number of communities). Then measure the modularity of this solution.
But I am not sure these solutions would give me what I want because the comparison I want to make in terms of quality of the partitioning should be with precisely two groups. I also don't know whether there are implementations of (1) (preferably in R, but Java or C++ might do). Thanks for any ideas you may have.