Scalable Community Detection with the Louvain Algorithm
Navid Sedighpour
Dr. Alireza Bagheri
Advanced Algorithm Presentation
July 2016
Main Reference
2/ 36
What we will see...
• Introduction
• Background
• Parallel Louvain Algorithm
• Experimental Results
• Conclusions
3/ 36
Introduction
4/ 36
Introduction
 Community Detection is an important problem today.
 Community detection spans many research areas:
 Health Care
 Social Networks
 Systems Biology
 Power Grid
 Community Detection algorithms attempt to identify:
 Modules
 Their hierarchical organization
 There is no rigorous mathematical definition of community structure.
 Modularity is the most used best known function to quantify community structure
in graph.
5/ 36
Introduction
 Techniques used for modularity maximization:
 Greedy: applies different approaches to merge vertices into communities for
higher modularity.
 Simulated Annealing: adopts a probabilistic procedure for global optimization
on modularity.
 External Optimization: heuristic search procedure
 Spectral Optimization: uses the eigenvalues and eigenvectors of a special
matrix for modularity optimization.
 All these methods lead to poor result when they applied to large graphs with many
communities.
 Achieving strong scalability together with high-quality community detection is still
an open problem.
 Unfortunately, most of community detection algorithms are sequential.
6/ 36
The Louvain Algorithm
 Is a greedy algorithm
 Weighted graphs
 This algorithm has been widely utilized in many application domains because of:
 Its rapid convergence properties
 High modularity
 Hierarchal partitioning
7/ 36
First Step: First Level Partitions
1. puts all vertices of a graph in distinct communities, one per vertex.
2. For each vertex i, the algorithm performs two calculations:
1. Compute the modularity gain (∆Q) when putting vertex i in the community of
any neighbor j.
2. Pick the neighbor j that yields the largest gain in ∆Q .
3. This loop continues until no movement yields a gain.
8/ 36
Other Steps: hierarchal structure
 Partitions of the first step become super-vertices and the algorithm reconstructs
the graph.
 Two super-vertices are connected if there is at least one edge between vertices
of the corresponding partitions.
 The weight of the edge between the two super-vertices is the sum of the weights
from all edges between their corresponding partitions at the lower level.
 These two steps repeats until the communities become stable.
9/ 36
Contributions
 Parallelization
 Novel implementation strategy to store and process dynamic graphs
 Extensive experimental evolution
10/ 36
Background
11/ 36
Problem Definition
• A weighted directed graph G = (V; E):
• V — set of vertices
• E — set of edges
• when u, v ∈ V , an edge e(u, v) ∈ E has weight 𝑤 𝑢,𝑣
• The goal of community detection (in this paper) is to partition graph G into a set C
of disjoint communities 𝑐𝑖:
• ∪ 𝑐𝑖 = V ; ∀𝑐𝑖 ∈ C
• 𝑐𝑖 ∩ 𝑐𝑗 = ∅ ; ∀𝑐𝑖; 𝑐𝑗 ∈ C
12/ 36
Problem Definition
13/ 36
Modularity Gain
• Modularity optimization is an NP-Complete problem,
therefore the Louvain algorithm maximizes the modularity
gain, which is :
• W(u): the sum of the weights of the edges incident to
vertex u
• 𝑤 𝑢→𝑐 : the sum of the weights of the edges from vertex u
to vertices in community c :
14/ 36
Sequential Louvain Algorithm
15/ 36
Parallel Louvain Algorithm
16/ 36
Hash-Based Data Organization
• We use two distinct hash tables:
• In_Table: to store the incoming edges of each vertex, that is not changed during the
inner loop and keeps track of the original graph structure.
• Out_Table: for the outgoing edges, which is changed during each iteration
17/ 36
Hash-Based Data Organization
18/ 36
Hash-Based Data Organization
• Both hash-tables are hashed on edges
• The input key (x) is a function of a tuple (t1,t2):
•
(<< is bitwise left shift operator and | is bitwise OR operator)
• For In_Table, the tuple contains the source vertex u and the destination vertex i (i is
the vertex 0 or 2) of the edge being hashed ((u,i), ∀e(u, i) ∈ E).
• the bucket is a triple ((u,i), 𝑤 𝑢,𝑖), which includes the weight of the corresponding edges (𝑤 𝑢,𝑖)
• For Out Table, the tuple contains the source vertex i and the destination vertex v’s
community c for the corresponding edge ((i,c), ∀v∈c,e(i,v)∈E).
• The bucket in the Out Table is a triple ((i,c), 𝑤𝑖→𝑐), where 𝑤𝑖→𝑐 refers to the sum of weights
of all the edges from the vertex i to a specific community c because all these edges are
hashed to the same bucket in the Out Table
19/ 36
Hash-Based Data Organization
• In this paper, we have utilized Fibonacci hash:
• Hash Function:
• M is the size of the hash table
• W is 264 - 1
• φ is the golden ratio
20/ 36
A Novel Convergence Heuristic
 LFR is designed to generate graphs to test community detection algorithms and
mimic the properties of real-world, large-scale complex graphs, through tunable
parameters.
 There is an inverse exponential relationship between the movement of the vertices
and the number of iterations in the inner loop.
 Dynamical threshold : identifies the fraction of the vertices that need to be
updated during each iteration of the inner loop.
 The threshold decreases exponentially with the number of iterations.
𝜺
21/ 36
Regression analysis for the LFR benchmark
 Y: Power-low distribution
 β: Community size
 μ : the fraction of edges between vertices belonging to
different communities
 K: average degree of the graph
 X-axis: inner loop
 Y-axis: ε
22/ 36
Modularity gain threshold
• We translate ε to the modularity gain threshold Δǭ by sorting the Δ𝑄 𝑢 (u ∈ V) for
all the vertices and selecting the top ε vertices to update the community
membership.
• Once Δǭ is known, the vertices can update the community information in parallel.
23/ 36
Parallel Louvain Algorithm
24/ 36
Parallel Louvain Algorithm
 The algorithm starts by initializing all the data structures.
 At the very beginning, the In-Table contains all the in-edges information of the
vertices owned by each node/process and the Out-Table is empty.
 The algorithm starts with STATE-PROPAGATION(), which globally propagates the
community state information.
 Once all the messages have been delivered and hashed in place, Out Table is
initialized.
 REFINE() corresponds to the inner loop of the sequential algorithm and orchestrates
the vertex migration to different communities, based on the modularity gain.
 GRAPH-RECONSTRUCTION()): reconstruct the graph and prepare for the next
round.
 The algorithm halts when there is no further modularity improvement.
25/ 36
Community State Propagation
• All processes sequentially scan their In-Table and send messages to the destination
processes that own the corresponding vertices (v in the algorithm)
• The processes also receive messages from others and insert/update hashed edges
to the Out-Table
26/ 36
Refine
27/ 36
Refine
• It starts with initializing ĉ 𝑢and m 𝑢
• The Out-Table contains all the neighbors’ communities and the accumulated weights
to the communities from the vertices owned by that process.
• Each process starts scanning the hashed edges (u,c’) and then calculates the
modularity gain of putting vertex u to community c’ and updates the corresponding ˆ
ĉ 𝑢and m 𝑢if needed. After all the Out-Tables have been examined, each vertex has
the information on the best community to join.
• Then, updates the community information and the corresponding Σtot based on Δǭ ,
and computes the new modularity.
• The procedure terminates when no further vertex movement can increase the
modularity.
28/ 36
Graph Reconstruction
29/ 36
Graph Reconstruction
• The weights of the edges between the new vertices are given by the sum of the
weight of the edges between vertices in the corresponding two communities.
• Edges between vertices of the same community lead to self-loops in the new graph.
• Line 4,5 scan the Out-Table and send the aggregated edges information to the
owner process of the vertex (community)
• Upon receiving the messages, lines 7–11 finally prepare the In-Table as the input
graph for the next round of execution.
30/ 36
Experimental Results
31/ 36
Modularity
• X-axis: outer loop iteration
• Y-axis: modularity
• The basic parallel version
converges very slowly with a very
low modularity score.
• The parallel version with the
proposed heuristic is on par with
the original sequential algorithm
and, surprisingly, in one case, UK-
2005, obtains slightly higher
modularity.
32/ 36
Speedup
• 49.8x speedup obtained with UK-2005 on 64 nodes, is 5.6 times faster than the
result reported in previous paper, which examines a random sampling generated sub-
network with 31% edges of the original UK-2005 graph.
33/ 36
Execution Breakdown
34/ 36
Scalability
• The parallel algorithm achieves good scalability. The processing rate is proportional
to the number of nodes.
35/ 36
Conclusions
• We have introduced a parallel version of the Louvain algorithm
• we have introduced a novel hash-based strategy to efficiently store and process
dynamic graphs
• Our parallel algorithm preserves the same convergence, modularity and community
properties as the original sequential Louvain algorithm
• We have performed an extensive performance evaluation on a wide variety of real-
world social graphs and synthetic graphs
36/ 36
Scalable Community Detection with the Louvain Algorithm
Navid Sedighpour
Dr. Alireza Bagheri
Advanced Algorithm Presentation
July 2016
Thank You

Scalable community detection with the louvain algorithm

  • 1.
    Scalable Community Detectionwith the Louvain Algorithm Navid Sedighpour Dr. Alireza Bagheri Advanced Algorithm Presentation July 2016
  • 2.
  • 3.
    What we willsee... • Introduction • Background • Parallel Louvain Algorithm • Experimental Results • Conclusions 3/ 36
  • 4.
  • 5.
    Introduction  Community Detectionis an important problem today.  Community detection spans many research areas:  Health Care  Social Networks  Systems Biology  Power Grid  Community Detection algorithms attempt to identify:  Modules  Their hierarchical organization  There is no rigorous mathematical definition of community structure.  Modularity is the most used best known function to quantify community structure in graph. 5/ 36
  • 6.
    Introduction  Techniques usedfor modularity maximization:  Greedy: applies different approaches to merge vertices into communities for higher modularity.  Simulated Annealing: adopts a probabilistic procedure for global optimization on modularity.  External Optimization: heuristic search procedure  Spectral Optimization: uses the eigenvalues and eigenvectors of a special matrix for modularity optimization.  All these methods lead to poor result when they applied to large graphs with many communities.  Achieving strong scalability together with high-quality community detection is still an open problem.  Unfortunately, most of community detection algorithms are sequential. 6/ 36
  • 7.
    The Louvain Algorithm Is a greedy algorithm  Weighted graphs  This algorithm has been widely utilized in many application domains because of:  Its rapid convergence properties  High modularity  Hierarchal partitioning 7/ 36
  • 8.
    First Step: FirstLevel Partitions 1. puts all vertices of a graph in distinct communities, one per vertex. 2. For each vertex i, the algorithm performs two calculations: 1. Compute the modularity gain (∆Q) when putting vertex i in the community of any neighbor j. 2. Pick the neighbor j that yields the largest gain in ∆Q . 3. This loop continues until no movement yields a gain. 8/ 36
  • 9.
    Other Steps: hierarchalstructure  Partitions of the first step become super-vertices and the algorithm reconstructs the graph.  Two super-vertices are connected if there is at least one edge between vertices of the corresponding partitions.  The weight of the edge between the two super-vertices is the sum of the weights from all edges between their corresponding partitions at the lower level.  These two steps repeats until the communities become stable. 9/ 36
  • 10.
    Contributions  Parallelization  Novelimplementation strategy to store and process dynamic graphs  Extensive experimental evolution 10/ 36
  • 11.
  • 12.
    Problem Definition • Aweighted directed graph G = (V; E): • V — set of vertices • E — set of edges • when u, v ∈ V , an edge e(u, v) ∈ E has weight 𝑤 𝑢,𝑣 • The goal of community detection (in this paper) is to partition graph G into a set C of disjoint communities 𝑐𝑖: • ∪ 𝑐𝑖 = V ; ∀𝑐𝑖 ∈ C • 𝑐𝑖 ∩ 𝑐𝑗 = ∅ ; ∀𝑐𝑖; 𝑐𝑗 ∈ C 12/ 36
  • 13.
  • 14.
    Modularity Gain • Modularityoptimization is an NP-Complete problem, therefore the Louvain algorithm maximizes the modularity gain, which is : • W(u): the sum of the weights of the edges incident to vertex u • 𝑤 𝑢→𝑐 : the sum of the weights of the edges from vertex u to vertices in community c : 14/ 36
  • 15.
  • 16.
  • 17.
    Hash-Based Data Organization •We use two distinct hash tables: • In_Table: to store the incoming edges of each vertex, that is not changed during the inner loop and keeps track of the original graph structure. • Out_Table: for the outgoing edges, which is changed during each iteration 17/ 36
  • 18.
  • 19.
    Hash-Based Data Organization •Both hash-tables are hashed on edges • The input key (x) is a function of a tuple (t1,t2): • (<< is bitwise left shift operator and | is bitwise OR operator) • For In_Table, the tuple contains the source vertex u and the destination vertex i (i is the vertex 0 or 2) of the edge being hashed ((u,i), ∀e(u, i) ∈ E). • the bucket is a triple ((u,i), 𝑤 𝑢,𝑖), which includes the weight of the corresponding edges (𝑤 𝑢,𝑖) • For Out Table, the tuple contains the source vertex i and the destination vertex v’s community c for the corresponding edge ((i,c), ∀v∈c,e(i,v)∈E). • The bucket in the Out Table is a triple ((i,c), 𝑤𝑖→𝑐), where 𝑤𝑖→𝑐 refers to the sum of weights of all the edges from the vertex i to a specific community c because all these edges are hashed to the same bucket in the Out Table 19/ 36
  • 20.
    Hash-Based Data Organization •In this paper, we have utilized Fibonacci hash: • Hash Function: • M is the size of the hash table • W is 264 - 1 • φ is the golden ratio 20/ 36
  • 21.
    A Novel ConvergenceHeuristic  LFR is designed to generate graphs to test community detection algorithms and mimic the properties of real-world, large-scale complex graphs, through tunable parameters.  There is an inverse exponential relationship between the movement of the vertices and the number of iterations in the inner loop.  Dynamical threshold : identifies the fraction of the vertices that need to be updated during each iteration of the inner loop.  The threshold decreases exponentially with the number of iterations. 𝜺 21/ 36
  • 22.
    Regression analysis forthe LFR benchmark  Y: Power-low distribution  β: Community size  μ : the fraction of edges between vertices belonging to different communities  K: average degree of the graph  X-axis: inner loop  Y-axis: ε 22/ 36
  • 23.
    Modularity gain threshold •We translate ε to the modularity gain threshold Δǭ by sorting the Δ𝑄 𝑢 (u ∈ V) for all the vertices and selecting the top ε vertices to update the community membership. • Once Δǭ is known, the vertices can update the community information in parallel. 23/ 36
  • 24.
  • 25.
    Parallel Louvain Algorithm The algorithm starts by initializing all the data structures.  At the very beginning, the In-Table contains all the in-edges information of the vertices owned by each node/process and the Out-Table is empty.  The algorithm starts with STATE-PROPAGATION(), which globally propagates the community state information.  Once all the messages have been delivered and hashed in place, Out Table is initialized.  REFINE() corresponds to the inner loop of the sequential algorithm and orchestrates the vertex migration to different communities, based on the modularity gain.  GRAPH-RECONSTRUCTION()): reconstruct the graph and prepare for the next round.  The algorithm halts when there is no further modularity improvement. 25/ 36
  • 26.
    Community State Propagation •All processes sequentially scan their In-Table and send messages to the destination processes that own the corresponding vertices (v in the algorithm) • The processes also receive messages from others and insert/update hashed edges to the Out-Table 26/ 36
  • 27.
  • 28.
    Refine • It startswith initializing ĉ 𝑢and m 𝑢 • The Out-Table contains all the neighbors’ communities and the accumulated weights to the communities from the vertices owned by that process. • Each process starts scanning the hashed edges (u,c’) and then calculates the modularity gain of putting vertex u to community c’ and updates the corresponding ˆ ĉ 𝑢and m 𝑢if needed. After all the Out-Tables have been examined, each vertex has the information on the best community to join. • Then, updates the community information and the corresponding Σtot based on Δǭ , and computes the new modularity. • The procedure terminates when no further vertex movement can increase the modularity. 28/ 36
  • 29.
  • 30.
    Graph Reconstruction • Theweights of the edges between the new vertices are given by the sum of the weight of the edges between vertices in the corresponding two communities. • Edges between vertices of the same community lead to self-loops in the new graph. • Line 4,5 scan the Out-Table and send the aggregated edges information to the owner process of the vertex (community) • Upon receiving the messages, lines 7–11 finally prepare the In-Table as the input graph for the next round of execution. 30/ 36
  • 31.
  • 32.
    Modularity • X-axis: outerloop iteration • Y-axis: modularity • The basic parallel version converges very slowly with a very low modularity score. • The parallel version with the proposed heuristic is on par with the original sequential algorithm and, surprisingly, in one case, UK- 2005, obtains slightly higher modularity. 32/ 36
  • 33.
    Speedup • 49.8x speedupobtained with UK-2005 on 64 nodes, is 5.6 times faster than the result reported in previous paper, which examines a random sampling generated sub- network with 31% edges of the original UK-2005 graph. 33/ 36
  • 34.
  • 35.
    Scalability • The parallelalgorithm achieves good scalability. The processing rate is proportional to the number of nodes. 35/ 36
  • 36.
    Conclusions • We haveintroduced a parallel version of the Louvain algorithm • we have introduced a novel hash-based strategy to efficiently store and process dynamic graphs • Our parallel algorithm preserves the same convergence, modularity and community properties as the original sequential Louvain algorithm • We have performed an extensive performance evaluation on a wide variety of real- world social graphs and synthetic graphs 36/ 36
  • 37.
    Scalable Community Detectionwith the Louvain Algorithm Navid Sedighpour Dr. Alireza Bagheri Advanced Algorithm Presentation July 2016 Thank You