afternone / CommunityDetection.jl

Community Detection in Julia
Other
20 stars 3 forks source link

CommunityDetection

Build Status

INTRODUCTION

Community detection in Julia. This package inspired by louvain-igraph. It relies on Graphs.jl for it to function. Besides the relative flexibility of the implementation, it also scales well, and can be run on graphs of millions of nodes (as long as they can fit in memory).

The core function is optimize_partition which finds the optimal partition using the louvain algorithm for a number of different methods. The methods currently implemented are:

This package also implement label propagation algorithm and neighbor strength driven label propagation algorithm.

INSTALLATION

julia> Pkg.clone("git://github.com/afternone/CommunityDetection.jl.git")

USAGE

To start, make sure to import the packages:

using CommunityDetection
using GraphPlot # for testing graph

We'll create a simple graph for testing purposes:

g = graphfamous("karate")

For simply finding a partition use:

# construct modularity partition
mp = mpartition(g)
optimize_partition!(mp)

In case you want to use a weighted graph

edge_weights = ones(num_edge(g))
mp = mpartition(g, edge_weights)
optimize_partition!(mp)

Please note that not all methods are necessarily capable of handling weighted graphs.

Notice that mp now contains the membership of nodes

mp.membership

You can also find partition using infomap algorithm

# construct flow partition
fp = flow_partition(g)
optimize_partition!(fp)

Some other examples

# Significance method
mp = mpartition(g)
optimize_partition!(mp, method = :Significance)

# label propagation
membership1 = lpa(g)

# neighbor strength driven label propagation
membership2 = nsdlpa(g)

# calculate modularity
modularity(g, membership1)

# calculate NMI of two partition
nmi(membership1, membership2)

# calculate VOI of two partition
voi(membership1, membership2)

REFERENCES

Please cite the references appropriately in case they are used.

  1. Blondel, V. D., Guillaume, J.-L., Lambiotte, R. & Lefebvre, E. Fast unfolding of communities in large networks. J. Stat. Mech. 2008, P10008 (2008).
  2. Newman, M. & Girvan, M. Finding and evaluating community structure in networks. Physical Review E 69, 026113 (2004).
  3. Reichardt, J. & Bornholdt, S. Partitioning and modularity of graphs with arbitrary degree distribution. Physical Review E 76, 015102 (2007).
  4. Traag, V. A., Van Dooren, P. & Nesterov, Y. Narrow scope for resolution-limit-free community detection. Physical Review E 84, 016114 (2011).
  5. Traag, V. A., Krings, G. & Van Dooren, P. Significant scales in community structure. Scientific Reports 3, 2930 (2013).
  6. Aldecoa, R. & Marín, I. Surprise maximization reveals the community structure of complex networks. Scientific reports 3, 1060 (2013).
  7. Traag, V.A., Aldecoa, R. & Delvenne, J.-C. Detecting communities using Asymptotical Surprise. Forthcoming (2015).
  8. Mucha, P. J., Richardson, T., Macon, K., Porter, M. A. & Onnela, J.-P. Community structure in time-dependent, multiscale, and multiplex networks. Science 328, 876–8 (2010).