This code accompanies the paper "Non-assortative relationships between groups of nodes are common in complex networks", by Cathy Liu, Tristram J. Alexander, and Eduardo G. Altmann, PNAS Nexus (2023).
The analysis is performed in two steps:
-
Given a network (in folder Data/), use one of the 5 community-detection methods (SBM, Louvain, Spectral, Infomap, or DNGR, see below) to partition the nodes in groups (stored in the folder Output/).
-
Given a network partition (in folder Output/), classify the relationship between groups/communities in one of the four types: Assortative, Disassortative, Core-Periphery, or Source-Basin.
The Tutorial.ipynb notebook shows how to compute the partitions (step 1) and analyze pre-computed partitions of 52 networks and 5 methods (step 2).
Method | Reference | Requirement |
---|---|---|
SBM |
Bayesian stochastic blockmodeling | graph-tool |
Louvain |
Fast unfolding of communities in large networks | python-louvain |
Spectral |
Revisiting the Bethe-Hessian: Improved CommunityDetection in Sparse Heterogeneous Graphs | codes |
Infomap |
Maps of random walks on complex networks reveal community structure | infomap |
DNGR |
Deep neural networks for learning graph representations | DNGR-Keras under python3.6 |
- The notebooks show examples of data analysis:
- Tutorial.ipynb: exemplifies the complete data analysis in one network.
- DataSurvey.ipynb: full data analysis pipeline used in the paper (52 networks), including: i) choose datasets in 5 domains from repository Netzschleuder; ii) classify structure type for each network iii) produce summary figures (Fig. 4 in paper) 4) and analyse two case studies.
- src: python files used to produce our result.
-
GenModel.py contains 5 community detection methods with each method running in a seperate file: SBM.py,Louvain, clustering_more.py, Infomap.py and DNGR.py
-
summary_stats.py includes the interaction classification functions;
-
Robustness.py includes the boostrapping method to comptue the robustness of the classifications;
-
Null.py includes the density null model;
-
Converter.py and preprocess.py include helper functions to convert networks between networkx and graph_tool
-
summary_stats_all.py is used in DataSurvey.ipynb with more summary functions
-
Data: this folder contains the datasets used in our case study, including the 52 cases downloaded from Netzschleuder. Additional datasets can be stored and analyzed from here.
-
Outputs: This folder contains community partition results by 5 methods in 52 networks in 5 domains (Online&Social, Economic, Biological, Technological, Informational).