Module 4
Module 4
3. Hierarchical communities: We can merge two or more flat or overlapping communities to form a
hierarchical community. A hierarchical community can be linked to other hierarchical, overlapping, or
flat communities. An example of the hierarchical community structure is that communities at the city
level can be merged to form a community at the state level that can further be merged to form country
level communities. A toy example of a hierarchical community is shown in Figure 5.3.
4. Local communities: Local communities show a community structure from a local perspective
without focusing on global structure. For example, consider the citation network formed by research
groups inside a university. One may be able to find a local community in this network. But when
considering it as a part of a more extensive global citation network, this community structure might
not fit the requirements of a community anymore. A toy example of a local community is shown in
Figure 5.4.
There are two problems with this approach, which are as follows:
1. Finding cliques from a network is NP-complete. Even though there exists an approximate algorithm
to find the clique, this is still computationally expensive as social networks are large.
2. Generally, large cliques are not present in social networks. There exist a few nodes that are not
connected to all the other members in the subgraph. Consider a classroom group on Facebook where
most of the students are connected, but there are still some students who are not connected to all the
other classmates.
Reachability of Members
As the constraints on cliques are too strict, this section presents a few measures in which the
constraints are relaxed.
1. K-cliques: It is the maximal subset of vertices V such that for any two nodes belonging to this subset,
the shortest distance between them is less than or equal to K . Here, a 1-clique is similar to a normal
clique as the distance between any two nodes is equal to one. 2-clique is a maximal complete subgraph
in which the distance between any two nodes is less than or equal to 2. In social network analysis, this
is also known as a friend of a friend. The increasing value of K further relaxes the criterion of the clique.
The problem with K-clique is that despite the node is not present in a K-clique, it can contribute to
finding the shortest distance. For example, consider Figure 5.7 again where node 4 is not a part of the
2-clique, but stil, it was considered when finding the shortest distance between nodes 3 and 5.
2. K-clan: It is a stricter version of K-clique in which only the nodes present in the set under inspection
are used to create the subgraph in which the distance between any two nodes should be less than or
equal to K . Figure 5.7 is not a 2-clan but nodes {2, 3, 4, 5, 6} in Figure 5.8 form a 2-clan. Due to the
maximality principle of K-clan, nodes 3, 4, 5 cannot be considered as K clan as there exist two more
nodes 2, 6 whose inclusion into the set still preserves the K distance principle of K-clan.
3. K-club: K-club is a K-clan with the relaxed maximality condition. Due to this, {2, 3, 4}, {3, 4, 5}, {4, 5,
6}, {5, 6, 2}, {6, 2, 3} in Figure 5.8 can all also be considered as 2-club. As K-clan is a stricter version of
K-club and K-clique, every K-clan is a K-club and K-clique. The problem with these methods is that for
a large value of K, these algorithms are still computationally expensive, and deciding an appropriate
value of K is a challenging task.
Node Degree
Another way to relax the constraints on the clique is by finding the measures related to the degree of
a node. These are divided into two major types:
1. K-plex: A subset of nodes of a network V forms a K-plex if every node in this network has a degree
greater than or equal to |V| − K . In other words, every member is connected to at least other |V| − K
members. For a value of K = 1 , K-plex is the same as a clique in the network as every node in a clique
has a degree of |V| − 1 . For a low value of K (2 or 3), K-plex can find small cohesive subgroups in the
network. And these subgroups follow the low diameter and high connectivity properties of a clique. K-
plex directly solves the problem of K-cliques and K-clubs by limiting the number of non-neighbours
inside the community.
2. K-core: K-core is a maximal subgraph, such that each node has a minimum degree of K . K +1 core
subgraph can be created from the current subgraph by recursively removing nodes of degree K . This
should be repeated until there is no node of degree K in the current subgraph. In the case of a social
network, it is observed that a particular person leaves a group if less than a certain number of her
friends are in that group.
5.4.2 Modularity and Community Detection
1. The node-centric community detection methods discussed earlier do not work well when the
network becomes very large.
2. Therefore, new and more scalable strategies are required to detect communities in such extensive
networks.
3. One widely used approach is modularity maximisation, proposed by Newman (2006).
4. This method identifies communities by analysing the similarities and differences in how nodes are
connected in the network.
5. By maximizing modularity, the method can effectively separate the network into meaningful
communities.
Modularity
• The word modularity comes from “module,” which means a small, self-contained unit used to
build larger structures.
• In networks, modularity is a network-centric measure used to check how good or meaningful
a community structure is.
• The idea of modularity is based on comparing the actual number of edges inside a subgraph
(community) with the expected number of edges.
• The expected number of edges is calculated using a null model, where nodes are assumed to
connect randomly to each other.
• While doing this random connection, the null model still keeps some structural features the
same—especially the degree distribution of nodes.
• If a community has far more edges than expected under random connection, it indicates a
strong and well-defined community, giving higher modularity.
For two given nodes i and j , the difference between the actual number of edges and the expected
number of edges can be written as,
1. Before moving forward, it is important to understand what Equation 5.3 means. To maximise
modularity, we must assign nodes into communities so that each node is as densely connected as
possible to other nodes within the same community.
2. To see when the summation in the modularity formula becomes large, we first look at when an
individual term in the summation becomes large.
3. An individual term increases when the two nodes being considered have lower degrees, because
the product of their degrees deg(i)deg ( j) becomes smaller compared to the total number of edges in
the network.
4. This means modularity becomes higher when most of a node’s actual connections fall inside its own
community, instead of going to nodes outside the community.
5. The modularity value of a network can be positive, negative, or zero. A positive value indicates the
presence of a strong community structure.
6. For unweighted and undirected networks, modularity lies in the range [-1/2, 1].
7. Usually, community detection aims to find a grouping of nodes that maximises the modularity value,
because higher modularity represents better community structure.
Calculating the expected number of edges between nodes
1. To calculate the expected number of edges between two nodes, we first imagine creating a random
network (G'(V, E')) from the original network (G(V, E)).
2. In this random network, the set of nodes remains the same as in (G).
3. The number of edges also stays the same, i.e., (|E| = |E'|), but the edges are randomly rewired, just
like the process used for random networks discussed in Chapter 3.
4. Even though the edges are rewired, the degree distribution remains unchanged. This means each
node keeps the same number of connections, but those connections go to random nodes.
5. Because of this, (G') acts as the null model or random counterpart of the original network (G).
6. Now, consider two nodes (v) and (w) in this random network, with degrees deg(v) and deg(w).
7. The expected number of edges between these two nodes in the random network is:
deg(v)*deg(w)/ 2|E|
This expected value is used in the modularity formula to compare random connectivity with actual
connectivity.
The maximum modularity value of all the partitions in the network is the maximum approximation of
the modularity value obtained from the algorithm. To determine the best merger, one should calculate
the difference between previous and current modularity values and add to that cluster with the
maximum difference. The time complexity is O(|E|) for joining edges in the network, where |E| is the
number of edges in the network. The total time complexity is O((m + n)n) which includes the updation
of the adjacency matrix.
Louvain Method for Community Detection
Louvain was introduced by Blondel et al. (2008) to approximate modularity maximisation in a greedy
manner. Louvain algorithm entirely unfolds the hierarchical structure of the community. The algorithm
is divided into two stages in each iteration. It assumes the weighted network to identify communities.
The stages are described as folows and visualised in Figure 5.15.
1. First stage: Modularity maximisation
The following steps are used in the first stage of the algorithm.
1. Assign each node to a singleton community; therefore, we have total n = |V| communities in
the initial state. Select any one node as a seed node (multiple nodes can also be chosen).
2. Now add each node u to node v ’s community if the change in the modularity value increases
with this assignment.
3. Similarly, keep adding each node to that community which upon addition has maximum
modularity gain.
4. Merging operation stops when there is no gain in the modularity value. The output of this
stage would be a node-community assignment.
2. Second stage: Node aggregation
In this stage, first, we build the super-network whose nodes are the communities that are available in
the first stage. The following steps are used for making a super-network and finding final communities.
1. For making a super-network, the edges between nodes are defined as the sum of weights of
edges between the two communities.
2. The links between the nodes of the same community are aggregated as the self-loops of the
nodes of the super-network, and the sum of their weights is the weight of the self-loop edge.
In the next iteration, repeat the two stages until the local maxima of the modularity value is reached.
The nodes of the final super-network are the final communities of the given network. Selecting good
seed nodes helps to converge the algorithm faster.
The time complexity of this algorithm is O(nlogn) which is faster than the fast greedy algorithm.
Problems with Modularity Maximisation
1. Modularity maximisation has several limitations, and the most serious one is the resolution limit
(Fortunato & Barthélemy 2007; Kumpula et al. 2007).
2. Due to this resolution limit, small but well-connected communities often get merged with larger
communities, even when the merged group is not very dense.
3. These small communities are internally strong, but because they are only loosely connected to the
rest of the network, modularity cannot separate them properly.
4. Modularity maximisation also fails to detect well-separated communities that have dense internal
connections but only one edge connecting them to the rest of the network.
5. Research shows that even if two such communities are connected by just a single edge, if their size
is below a threshold, modularity maximisation will still merge them into one community.
6. Another major issue is degeneracy of solutions, meaning that the algorithm may produce many
different community structures that all have the same (maximum) modularity value.
7. Because of this degeneracy, the same network can end up with multiple different solutions, making
the final community structure ambiguous or unstable.
5.4.3 Information-theoretic Approaches
1. Information-theoretic approaches detect communities by using compression techniques to
find the best way of partitioning a network.
2. These methods do not rely on traditional ideas like cohesion (tight groups) or separation
(few links between groups).
3. Instead, they treat communities as patterns or regularities in the network and try to
represent the network using the least amount of information.
4. The goal is to compress the network description so that it uses less information than the full
adjacency matrix, while still keeping important structural details.
5. The best compression is achieved by maximising compactness (more efficient
representation) and minimising information loss.
6. This helps create a simpler and more meaningful representation of the network.
7. The quality of the representation is evaluated using measures like mutual information and
minimum description length (MDL).
8. Based on these ideas, two widely used algorithms of this type are described in the following
section.
Infomod
1. Infomod, proposed by Rosvall and Bergstrom (2007), uses mutual information to find the best way
to represent a network (X) using a simpler candidate representation (Y).
2. Since the goal is to discover the best community structure, the method evaluates all possible
community assignments and chooses the one that gives the highest mutual information.
3. The initial representation of the original network (X) is usually its adjacency matrix, or any similar
full representation of the network.
4. The aim is to build a simpler representation (Y) that still preserves as much information as possible
from the original network.
5. To do this, the algorithm finds an optimal community assignment (\hat{a}) for all nodes such that
the mutual information between (X) and (Y) is maximised.
6. The community structure that results in the maximum mutual information is selected as the best
representation of the network.
1. Since it is impossible to check all possible community combinations, Infomod uses simulated
annealing to search for the community structure that maximises mutual information.
2. Another challenge is that we often do not know the number of communities in advance.
3. To address this, Infomod uses the Minimum Description Length (MDL) principle, which helps
determine both:
• the optimal number of communities, and
• the best simplified description (Y) of the network.
4. MDL ensures that the final community structure is the one that gives the shortest and most
informative description of the network.
Infomap
1. Infomap, proposed by Rosvall et al. (2009), is a method used to detect community structure
specifically in weighted and directed networks, based on the idea that a good map compresses
information and uses minimal bandwidth.
2. The method simulates random walks to track how information flows in the network, and nodes
where information flows quickly are grouped together as communities.
3. Using Huffman coding’s two-level structure, Infomap generates efficient codes that first describe
nodes within a community (first-level) and then describe communities within the network (second-
level).
4. This two-level design helps represent information using the least amount of data by reducing inter-
community links.
5. As random walkers spend most of their time within communities rather than between them, the
second-level codes describe the walker’s path, while first-level codes capture node-specific
information.
6. Infomap can also be combined with Minimum Description Length (MDL) principles and simulated
annealing to determine the optimal encoding of communities and nodes.
Problems with Information-theoretic Approaches
Information-theoretic approaches for community detection are not flawless. The following are some
of the limitations of the approaches in this category:
1. Stimulated annealing used in information-theoretic approaches suffers from poor searching of
global maxima.
2. The efficiency of clustering decreases when the structure is not apparent.
3. These approaches can lead to the formation of certain outlier communities.
4. These approaches also suffer from the resolution limit problem.
5. Such methods exhibit view problem, which establishes an upper limit on the size of the
community.
5.4.4 Permanence and Community Detection
• Modularity maximisation has issues such as resolution limit and degeneracy of solutions.
• It focuses only on internal node connections and ignores the effect of external connections.
• It is a global metric and depends on the entire network structure.
• For large, dynamic networks, running modularity maximisation from scratch is difficult.
• A method is needed that uses only local neighbourhood information instead of the full
network.
• Local metrics help detect communities efficiently in evolving networks.
• To address this, Chakraborty et al. (2014) proposed the permanence metric.
• Permanence is a local metric that works on neighbourhood-level information.
• It is highly efficient for community detection.
• Further improvements were made in Chakraborty et al. (2016).
Permanence
• Permanence is a vertex-centric metric that evaluates each node individually.
• It measures how strongly neighbouring communities “pull” a particular vertex.
• It considers both internal connections of a node and the maximum external connections to
any one neighbouring community.
• A node’s placement is influenced not just by how many links it has inside its community but
how strongly another community pulls it.
• If vertex u belongs to community A and vertex v belongs to community B, and there is an edge
between them, then A and B are neighbouring communities.
The underlying hypotheses of permanence are as follow:
Hypothesis 1: The number of internal connections of node v should be greater than the number of
external connections of node v with any external community.
Hypothesis 2: In a community, all the vertices should be highly inter-connected to each other.
Combining these two ideas, the formula of permanence for vertex v is given as,
Permanence Maximisation for Community Detection
• MaxPerm is a community detection method based on maximising permanence.
• It was proposed by Chakraborty et al. (2014) as a vertex-centric alternative to modularity.
• The algorithm follows a greedy strategy to produce partitions with high permanence.
• Small communities are merged only when the overall permanence value increases.
• The workflow is similar to the Louvain method used for modularity optimisation.
• MaxPerm operates in two stages, assuming the network is weighted for more accurate
community detection.
The stages are described in detail as follow:
First stage: Permanence maximisation.
The following steps are used in the first stage of the algorithm.
1. Assign each node to a single community; so for n number of nodes, there are n singleton
communities. Select any node as a seed node (multiple seeds can be selected).
2. Add each node u to node v ’s community if the change in permanence value increases.
3. Similarly, add each node to that community which has a maximum change in permanence
value after adding the node.
4. Merging stops when the maximum permanence gain is attained.
5. Now the final network is developed with a number of communities ranging from 1 to n.
Second stage: Node aggregation.
In this stage, first build the super-network whose nodes are the communities that are available in the
final network of the first stage.
The following steps are used for making a super-network and finding final communities.
1. For making a super network, the edges between nodes are defined as the sum of weights of
edges between two communities.
2. The links between the nodes of the same community are considered to form self-loops for the
nodes of a super-network, and the sum of their weights is the weight of the self-loop. 3.
3. Now apply the same steps of stage 1 and make the final network by combining nodes of a
super-network only if there is a positive permanence gain.
Problems with Permanence Maximisation
• Permanence maximisation was shown (Chakraborty et al., 2016) to reduce resolution limit and
solution degeneracy.
• The method works well unless a vertex is pulled by multiple overlapping neighbouring
communities.
• In such cases, permanence struggles with small threshold values of the resolution limit.
• This leads to small communities merging with large ones, similar to modularity issues.
• For real-world networks, permanence-based optimisation often results in many small-sized
communities.
5.5 OVERLAPPING COMMUNITY DETECTION
5.5.1 Clique Percolation
• Clique percolation (Palla et al., 2005) is the first method designed for overlapping community
detection.
• It is based on finding all k-cliques (complete subgraphs of size k) in the network.
• Two k-cliques are merged if they share k − 1 common nodes.
• Larger overlapping communities are formed by repeatedly merging cliques that share these k
− 1 nodes.
• The merging process stops when no further cliques can be merged.
• The method can be extended to weighted networks (CPMw) and directed networks (CPMd).
Example 5.7
Problems with Clique Percolation Methods
1. There is no fixed value of K , and it is not easy to find a correct value of K . The value of K
should not be too small or too large – if the value is too small, then the whole network
becomes one big community; if it is too large, then it becomes hard to find the cliques.
2. Even though there are efficient implementations for the clique percolation method for
networks with over a million nodes, finding a clique in a network is still computationally
expensive.
3. This method is more like pattern matching applied to the network as it tends to find localised
structures in the network.
5.5.2 Link Partition
• Link partitioning detects communities by clustering edges instead of nodes.
• A node can naturally belong to multiple communities if its connecting edges fall into different
clusters.
• Edge similarity (e.g., Jaccard coefficient) is used to group similar edges together.
• Communities are formed from these edge clusters, allowing overlapping node memberships.
1. Create a link network and apply a node partitioning algorithm or disjoint community detection
algorithm to find the community.
2. Use similarity measures on the edges to find the communities directly by creating the dendrogram.
• A generative model called the affiliation graphical model (AGM) is used to generate a network
(G).
• The network is parameterised as (G(V, C, M, P_c)).
• (V) represents the set of nodes in the network.
• (C) represents the set of communities.
• (M) denotes the association between nodes and communities.
• (P_c) is the parameter or probability value associated with each community (c).
• The final network contains the same set of nodes as (V).
• The goal of the model is to determine the edges between these nodes.
• Using AGM, we can find the probability of edges between two nodes as,
• (M_x) and (M_y) represent the communities that nodes (x) and (y) belong to.
• This generative model can detect both disjoint and overlapping communities.
• BigClam uses a similar affiliation-based model with an added concept of membership strength.
• Each node–community relationship has a strength value (F_{xA}).
• These strengths are organised into an affiliation matrix (F).
• Each row of (F) corresponds to a node, and each column corresponds to a community.
• Hence, using this modified definition, we can define the probability of two edges in one
community as,
• Using Equation 5.11, we define the overal probability of an edge between two nodes over al the
communities as,
where η is the learning parameter. Even though taking gradient is a linear time algorithm,
BigClam scales well with the size of the network and is fast compared to other community
detection algorithms.
5.5.4 Dynamics
• Real-world networks are dynamic and keep changing over time.
• We need algorithms that can work directly on only the updated portions of the network.
• Label propagation is a semi-supervised machine learning approach.
• It uses the labels of already-labeled nodes to predict labels for unlabeled nodes.
• It is more efficient than earlier methods.
• It requires less prior information about the network structure.
General Algorithmic Steps
[Link] unique community labels for a l the nodes in the network, i.e., and each node is in its own
community.
[Link] iteration: Update labels for all the nodes in the networks. Node’s label is updated as the label
with the highest frequency in its neighbours’ current labels. In case of any discrepancy, randomly break
the tie.
[Link] iteration: If the label of the nodes in the previous iteration is same as that for the node in the
current iteration, then stop; otherwise, repeat the last step.
Label propagation is divided into two types based on the time at which the labels for nodes are
updated:
1. Asynchronous mode: Labels are updated at the end of the inner iteration.
2. Synchronous mode: Unlike the asynchronous mode within the inner iteration, labels of nodes are
updated one by one sequentially; in this mode, labels are updated together at the end of the outer
iteration.
This method can be extended to subgraphs and nodes having multiple labels too.
This method can be applied to directed and weighted networks as well.
Problems with Label Propagation
1. For the large networks, it is not possible to find the number of outer iterations required to
get the correct answer.
2. This method is not stable as it involves a random process to break the tie. Hence, you might
end up with vastly different solutions in different runs, depending on the network structure.
3. It produces no unique solution but a sequence of many solutions. But the numbers of
solutions can be narrowed down by getting a preliminary label for some nodes.
5.5.5 GenPerm: Generalised Permanence
• GenPerm is an extended version of permanence for both overlapping and non-overlapping
communities.
• Proposed by Chakraborty et al. (2016).
• It measures how much each node contributes to the formation of each community it belongs
to.
• Although designed for overlapping communities, it performs better than MaxPerm for non-
overlapping ones as well.
• GenPerm evaluates the contribution of every vertex to all overlapping communities it is
associated with.
• Before applying the algorithm, some basic terminology related to the network and vertices (u)
and (v) must be understood.
1. Shared edge: The edge ⟨u,v⟩ is a shared edge if it lies in more than one community, i.e., ∃i,j such
that if Ci,Cj are communities, then u,v ∈ Ci ∧u,v ∈ Cj . In Figure 5.26, edge ⟨v,C⟩ is a shared edge as
both v and C lie in the overlap of the two communities.
2. Non-shared edge: The edge ⟨u,v⟩ is a non-shared edge if it lies entirely in a single community, i.e.,
∃!i,j such that if Ci,Cj are communities, then u,v ∈ Ci ∧u,v ∈ Cj . In simple words, at least one edge of
vertices must lie in a single community only. In Figure 5.26, the edge ⟨v,F⟩ is a non-shared edge as even
though v lies in both communities, F lies in a single community.
GenPerm introduces two key concepts for each vertex v in community c .
1. Generalising pull: One can think of generalising pul as the internal pul from its community. It is the
sum of non-shared edges and the sum of shared borders, normalised by the total number of
communities in which they are shared. The normalisation is required so that each edge only
contributes an equal amount of pul to every community that it is a part of.
CS problem is related to CD problem, but they are also different in the following ways:
1. In CD, we find al the communities inside a network; in CS, we only see the community related
to the query vertex. This is extremely useful in the case of social networks where billions of
nodes are present. This is because, in such cases, CD is costly, time-consuming and often not
necessary.
2. In CD, we use global parameters to find communities in the network; in CS, the query
parameter given by the user is used to find the communities in the network. This gives more
personalised communities to the user, which in turn helps them to interpret the community
structure easily.
3. CD algorithms are generally time-consuming and non-scalable for large networks. Therefore,
they cannot be used for online tasks. However, this is not the case for CS algorithms as they
are meant to work for online study. The reason for being fast is that these algorithms are not
applied to the entire network. Instead, they are used to the subgraph, which makes these
algorithms more efficient.
4. It is hard to use indexes and dynamic networks with CD; however, it is easy to do so with CS
algorithms. As CD algorithms use global criteria, they are not sensitive to the node and edge
updates. CS algorithms work well on continuously evolving networks.
5.8 EVALUATION OF COMMUNITY DETECTION METHODS
• After detecting communities, the next step is to evaluate the quality of the detected
communities.
• Evaluation is easier when a ground-truth community structure is available.
• A CD algorithm is considered good if its output closely matches the ground-truth communities.
• Several metrics and methods exist to measure how well a detected community structure aligns
with the true structure.
• The following section explains different quality evaluation techniques for community
detection algorithms.
5.8.1 Ground-truth Based Evaluation
Evaluation for Disjoint Communities
Rand index. There are some basic metrics that are essential for evaluating the performance of CD
methods (or that matter, any prediction framework). In the usual scenarios, these metrics indicate the
nature of a “decision” taken by an algorithm. In the case of CD, this “decision” is with regards to a pair
of nodes. Hence, we define the following terms:
• True positive ( TP ): A pair of nodes are in the same community in the predicted and the
ground-truth community structures.
• True negative ( TN ): A pair of nodes are not in the same community in the predicted and
ground-truth community structures.
• False positive ( FP ): A pair of nodes are in different communities in the ground-truth
community structure but in the same community in the predicted community structure.
• False negative ( FN ): A pair of nodes are in the same community in the ground-truth
community structure but in different communities in the predicted community structure.
Evaluation for Overlapping Communities
Omega index. For a given network G(V,E) , let C={c1,c2,c3,…,cK} be the ground-truth community
labels and Ω={ω1,ω2,ω3,…,ωJ} be the set of predicted community labels.
Let N be the total number of nodes in the network. For this, we consider |ωij| and |cij| as the number
of communities shared by nodes i and j in the predicted communities and ground-truth communities,
respectively. Then omega index is given as,
Overlapping normalised mutual information (ONMI). This is an extended version of mutual
information for the overlapping communities.
Let Y be the ground truth community assignment, and X be the detected community assignment. The
conditional probability of X given Y can be written as (this specifies lack of information for Y given that
we know X ),