This code is for the detection of bimodular structures in networks, such as core-periphery and bipartite ones, with the bimodular surprise measure.
Bimodular surprise provides a measure to detect significant bimodular partitions in binary, directed and undirected networks. It is based on the interplay of edge-densities within the clusters and between the clusters. To this end a hypergeometric distribution function is used in similar fashion to surprise for traditional community detection on networks.
The details and performance of this method can be found in this open-access paper.
The code for the bimodular surprise calculation and the heuristic for detection is provided in a jupyter notebook
(for now) running on Python 3.5
. This notebook contains all explanations about the method, the functions and working examples to show how to use the code.
The provided jupyter notebook
is written to be self-explanatory and self-contained. Once the provided functions in the notebook are loaded, running the detection algorithm on a network is as simple as:
- Loading a network/graph, either as the corresponding adjacency matrix in
numpy.array
format or as aNetworkX.Graph
G_karate = nx.karate_club_graph()
- Running the detection heuristic
revealed_partition, significance = run_surprise(G=G_karate, is_directed=False)
- The revealed partition can be visualized with (node color indicates the two revealed partitions)
nx.draw(G=G_karate, node_color=revealed_partition)
Please see the jupyter notebook for more details. The extention of this method to weighted networks is in progress.
MIT © Jeroen van Lidth de Jeude - IMT School For Advanced Studies Lucca
"Detectong Core-periphery Structures by Surprise" Jeroen van Lidth de Jeude, Tiziano Squartini, Guido Caldarelli, 12 October 2018