The Weighted Stochastic Block Model

This page is a companion for our papers on the Weighted Stochastic Block Model (WSBM), written by Christopher Aicher, Abigail Z. Jacobs, and Aaron Clauset. The page hosts an implementation of our Bayesian variational algorithm for inferring the latent block structure. Our goal is for the methods to be widely accessible to the community.

Journal References
Christopher Aicher, Abigail Z. Jacobs, and Aaron Clauset.
"Learning Latent Block Structure in Weighted Networks."
Journal of Complex Networks 3(2), 221-248 (2015).

Christopher Aicher, Abigail Z. Jacobs, and Aaron Clauset.
"Adapting the Stochastic Block Model to Edge-Weighted Networks."
ICML Workshop on Structured Learning (2013).

Download the code
The full code package contains the core package along with all additional files. The code was written for Matlab, with optional MEX functions that can be installed for additional scalability. Type 'help ' at the Matlab prompt for more information about a particular function.
Full package (Matlab, by Christopher Aicher)

Core Package
The implementation of the Bayesian variational algorithm consists of the following files.

wsbm.m - The main function for inferring community structure.

setup_distr.m - A helper function for selecting exponential family distributions to use in the wsbm.m model. This function is required function for wsbm.m to work properly.

Adj2Edg.m and Edg2Adj.m - Helper functions for converting between adjacency matrices and edge lists. These functions are required for wsbm.m to work properly.

/private - A folder containing MATLAB and MEX files that are used privately by wsbm.m. This is a required folder for wsbm.m to work properly.

InstallMEXFiles.m - A script file detailing how to install optional (but highly recommended) MEX functions (in the private folder) for wsbm.m to use.

Additional tools
There are several additional tools included in the full package, which provide some demo scripts to help users learn the software, some visualization scripts for displaying the posterior vertex-label probabilities and matrices, and for generating synthetic networks.

plotMu.m - Visualizing the Posterior Vertex-Label Probabilities
This function visualizes the posterior label probabilities each vertex.

plotWSBM.m - Visualizing Adjacency Matrices
This function visualizes the block structure of the network using the labels inferred.

generateEdges.m - Generate Synthetic Networks
This function generates synthetic networks. For advanced users and requires the helper functions of wsbm.m.

varInfo.m - Calculates variation of information between two collections of vertex labels.

nmi.m - Calculates the normalized mutual information between two collections of vertex labels.

wsbmLooper.m - A helper function that wraps fitting and testing multiple models (recommended for advanced users).

crossValidEdg.m - Data Partition Function. This function splits an edge list into a training and test set for cross validation.

Demonstration scripts
The following script files provide examples of how to use the package.

WSBMDemo.m - Demonstrates examples of how to use wsbm.m

WSBMOptionsDemo.m - Demonstrates examples of how to change default wsbm.m options.

WSBMAdvancedDemo.m - Demonstrates examples of how to perform model selection and cross valdiation with wsbm.m.

DegreeCorrectedDemo.m - Demonstrates examples of how to use degree correction in wsbm.m.

BIWSBMDemo.m - Demonstrates examples of how to use biwsbm.m for bipartite networks.

A note Matlab compatibility
The Matlab functions were designed to be compatible with Matlab v7.13 (2011). They are not necessarily compatible with older versions of Matlab. Also see InstallMEXFiles.m for details on how to install optional (but highly recommended) MEX functions for wsbm.m to use.

A note about bugs and alternative implementations
The code provided here is provided as-is, with no warranty, with no guarantees of technical support or maintenance, etc. If you experience problems while using the code, please let Christopher know via email. We are happy to host (or link to) implementations of any of these functions in other programming languages, in the interest of facilitating their more widespread use. However, we cannot provide any technical support for that code.
Finally, if you use our code in an academic publication, it would be courteous of you to thank Christopher Aicher in your acknowledgements for providing you with implementations of the methods.

Download the NFL2009 data
The data for the NFL2009 weighted network, including the weighted edge list, a set of vertex attributes (including community labels) and a readme file containing the appropriate journal reference and data licensing information.
NFL2009 Network (zip)

Updates
19 May 2014: version 1.2 posted; minor bug-fixes and additional demos
2 May 2014: posted NFL2009 data set
3 April 2014: version 1.1 posted; documentation and helper function updated, and added varInfo, nmi, and wsbmLooper functions
9 January 2014: version 1.0 posted