Community Detection in Social Networks
Community Detection in Social Networks
MODULE 4
COMMUNITY STRUCTURE IN NETWORKS
1. Link Prediction
• Helps find future or missing connections between nodes in a network.
• Knowing which community, a node belongs to improves prediction accuracy (since
nodes in the same community are more likely to connect).
2. Recommender Systems
• Groups like-minded users who have similar tastes or interests.
• Even without your past data, companies can recommend items by looking at others in
your community who like similar products.
3. Information Diffusion
• Helps understand how fast information spreads in a network.
• Information (or misinformation) spreads faster within communities because of strong
internal connections.
• Useful for controlling fake news or planning targeted political campaigns.
4. Marketing
• Helps companies target specific groups for advertising.
• Instead of showing ads to everyone, they can focus on a few members of a dense
community—information spreads naturally within it.
• This saves money and resources.
1
SOCIAL NETWORK ANALYSIS(BAD714D)
6. Anomaly Detection
• Finds abnormal or unexpected behavior in networks.
• Communities show “normal” behavior patterns—anything that deviates can be flagged
as an anomaly or outlier.
• Example: spotting fake users or unusual buying patterns in e-commerce.
TYPES OF COMMUNITIES
1. Disjoint Communities (Flat Communities)
• Each node belongs to only one community.
• Communities do not overlap.
• Nodes in different communities can still be connected by a few links (called
“bridges”).
• Example: A person working full-time for only one company.
• Note: Disjoint ≠ disconnected — disjoint communities may still have links between
them.
2
SOCIAL NETWORK ANALYSIS(BAD714D)
2. Overlapping Communities
• A node can be a member of multiple communities at once.
• Two communities can even share edges or members.
• This type is more realistic, as people often belong to many groups (e.g., family,
workplace, and hobby groups).
• Example: A person in multiple WhatsApp or Facebook groups.
• Note: Harder to detect because one node can have many possible community
combinations.
3. Hierarchical Communities
• Communities are arranged in layers or levels — small ones combine into larger ones.
• Each higher-level community can include smaller ones.
3
SOCIAL NETWORK ANALYSIS(BAD714D)
• Example:
o City-level community → part of a State-level community → part of a Country-
level community.
• Useful for: studying networks that have a multi-level or nested structure (like
organizations or biological systems).
4. Local Communities
• Focuses on the local structure (small part of the network) rather than the entire global
network.
• Shows how a small group of nodes are connected from their own perspective.
• Example: A research group in a university’s citation network — looks like a
community locally, but not necessarily in the global scientific network.
• Useful for: studying specific sub-networks or personalized communities.
4
SOCIAL NETWORK ANALYSIS(BAD714D)
• A clique is a subgraph where every node is directly connected to every other node.
• A maximal clique is one that cannot be extended by adding another node.
• Diameter of a clique = 1 (because all nodes are directly linked).
Example:
If A, B, C, D, E all know each other — that’s a clique.
Problems:
1. Finding all cliques is NP-complete (very hard for large networks).
2. Real networks rarely form perfect cliques — not everyone knows everyone else.
5
SOCIAL NETWORK ANALYSIS(BAD714D)
Reachability-Based Methods
K-Clique
K-Clan
6
SOCIAL NETWORK ANALYSIS(BAD714D)
K-Club
Degree-Based Methods
These methods look at how many connections (degree) each node has.
K-Plex
• A subset where each node is connected to at least (|V| – K) others in the group.
• Allows up to K non-neighbors inside a community.
• For K = 1 → normal clique.
• For small K (2 or 3), finds tight but realistic subgroups.
Example:
In a 6-node group, a 4-plex means each node connects with at least 2 others.
Problem:
Finding the maximal K-plex is still NP-complete.
7
SOCIAL NETWORK ANALYSIS(BAD714D)
K-Core
Checking a given network for a K-core or K-plex is computationally easy, but finding the
maximal K-core or K-plex is still an NP-complete problem.
Modularity
Modularity (Q) measures how well a network is divided into communities — groups of
nodes that are densely connected internally but sparsely connected to other groups.
It does this by comparing:
• Actual edges between nodes, vs.
• Expected edges if the network were random (but kept the same degree distribution).
In this model, the expected number of edges between two nodes 𝑣and 𝑤is:
𝑑𝑒𝑔(𝑣) × 𝑑𝑒𝑔(𝑤)
2∣𝐸∣
1 𝑑𝑒𝑔(𝑖)𝑑𝑒𝑔(𝑗)
𝑄= ∑(𝑎𝑖𝑗 − ) 𝛿(𝐶𝑜𝑚𝑚(𝑖), 𝐶𝑜𝑚𝑚(𝑗))
2∣𝐸∣ 2∣𝐸∣
𝑖,𝑗
Where:
• 𝛿(𝐶𝑜𝑚𝑚(𝑖), 𝐶𝑜𝑚𝑚(𝑗)) = 1if nodes 𝑖and 𝑗are in the same community, otherwise 0.
Alternatively, it can be expressed as:
∣𝐶𝑜𝑚𝑚∣
𝑚𝑛 𝑘𝑛 2
𝑄= ∑[ −( ) ]
∣𝐸∣ 2∣𝐸∣
𝑛=1
9
SOCIAL NETWORK ANALYSIS(BAD714D)
10
SOCIAL NETWORK ANALYSIS(BAD714D)
• The Fast Greedy algorithm is one of the earliest and most widely used methods for
modularity maximization.
• It is agglomerative and hierarchical, meaning it starts with every node as its own
community and gradually merges communities to increase the overall modularity 𝑄.
The steps of the algorithm are mentioned below:
Time complexity:
• Edge joining: O(|E|)
• Overall (including updates): O((m + n)n)
12
SOCIAL NETWORK ANALYSIS(BAD714D)
Information-Theoretic Approaches
• Use compression techniques to find the best partition of a network.
• Do not rely on traditional cohesion and separation ideas.
• Communities are treated as regular patterns in the network.
• Aim: represent the network with minimum information, ideally less than that
required for its adjacency matrix.
13
SOCIAL NETWORK ANALYSIS(BAD714D)
Notations:
• 𝑛𝑖 : size of community i
Optimization Challenge:
• Iterating over all possible community combinations is infeasible.
• Hence, Simulated Annealing is used to find the community structure that maximizes
mutual information.
14
SOCIAL NETWORK ANALYSIS(BAD714D)
15
SOCIAL NETWORK ANALYSIS(BAD714D)
Underlying Hypotheses
1. Internal connections of a node should be greater than its external connections to
any single neighboring community.
2. Nodes within a community should be highly interconnected.
𝐼(𝑣) 1
𝑃𝑒𝑟𝑚(𝑣) = [ × ] − [1 − 𝑐𝑖𝑛 (𝑣)]
𝐸𝑚𝑎𝑥 (𝑣) 𝑑𝑒𝑔(𝑣)
Where:
• 𝑑𝑒𝑔(𝑣): Degree of v
Network Permanence
∑𝑣∈𝑉 𝑃𝑒𝑟𝑚(𝑣)
𝑃𝑒𝑟𝑚(𝐺) =
∣𝑉∣
16
SOCIAL NETWORK ANALYSIS(BAD714D)
17
SOCIAL NETWORK ANALYSIS(BAD714D)
18
SOCIAL NETWORK ANALYSIS(BAD714D)
19
SOCIAL NETWORK ANALYSIS(BAD714D)
Concept
Where:
• 𝑁𝑖 : neighbors of node i
• 𝑁𝑗 : neighbors of node j
Extensions
20
SOCIAL NETWORK ANALYSIS(BAD714D)
21
SOCIAL NETWORK ANALYSIS(BAD714D)
Two-Step Process
o 𝑉: Nodes
o 𝐶: Communities
o 𝑀: Node–community memberships
𝑃(𝑥, 𝑦) = 1 − ∏ (1 − 𝑃𝑐 )
𝑐∈𝑀𝑥 ∩𝑀𝑦
• Each node has a membership strength with each community, denoted as 𝐹𝑥𝐴 .
𝑃𝐴 (𝑥, 𝑦) = 1 − 𝑒 −𝐹𝑥𝐴𝐹𝑦𝐴
22
SOCIAL NETWORK ANALYSIS(BAD714D)
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.
23
SOCIAL NETWORK ANALYSIS(BAD714D)
1. Initialization:
o Assign each node a unique community label (each node starts in its own
community).
2. Inner Iteration (Label Update):
o Each node updates its label to the most frequent label among its neighbours.
o If there’s a tie, break it randomly.
3. Outer Iteration (Convergence Check):
o If labels remain unchanged from the previous iteration, stop.
o Otherwise, repeat the inner iteration.
1. Asynchronous Mode:
o All labels are updated after each full iteration.
2. Synchronous Mode:
o Labels are updated sequentially, one node at a time.
Extensions
24
SOCIAL NETWORK ANALYSIS(BAD714D)
o Subgraphs
o Nodes with multiple labels (overlapping communities)
o Directed and weighted networks
1. Unpredictable convergence — hard to determine how many iterations are needed for
large networks.
2. Instability — random tie-breaking can produce different results across runs.
3. Non-unique solutions — produces multiple possible community structures.
4. However, pre-labeling some nodes can help stabilize results and narrow down valid
solutions.
25
SOCIAL NETWORK ANALYSIS(BAD714D)
Overview
Key Concepts
o Mathematically:
∃𝑖, 𝑗such that 𝑢, 𝑣 ∈ 𝐶𝑖 and 𝑢, 𝑣 ∈ 𝐶𝑗
2. Non-shared Edge
26
SOCIAL NETWORK ANALYSIS(BAD714D)
• It’s the sum of non-shared and shared edges, normalised by the number of
communities that share each edge:
1
𝐼𝑐 (𝑣) = ∑
𝑥𝑒
𝑒∈Γ𝑐𝑣
where
4. Generalising Connectedness
where
𝑐
𝑐𝑖𝑛 (𝑣)= local clustering coefficient of 𝑣within community 𝑐
5. GenPerm Formula
27
SOCIAL NETWORK ANALYSIS(BAD714D)
Algorithm Steps
1. Initialisation
• Each edge in the network starts as a single community.
• Because edges may belong to multiple communities, overlaps are possible.
2. Update Step
28
SOCIAL NETWORK ANALYSIS(BAD714D)
3. Convergence
• Repeat until:
o The GenPerm value does not increase further for any vertex, or
o The maximum number of iterations is reached.
Advantages
• Used when global network information is incomplete — only a few edges around a
vertex are known.
• It identifies communities based on local structure rather than the entire network.
Idea
• Measures how well a local subgraph (C) is connected internally compared to its
boundary connections.
• Helps find local communities without needing the complete network structure.
Key Definitions
• C: Known subgraph (the local community).
• U: Set of vertices outside C but connected to at least one node in C.
• W: Boundary vertices in C having at least one neighbour in U.
• A: Known adjacency matrix of the network.
29
SOCIAL NETWORK ANALYSIS(BAD714D)
where
30
SOCIAL NETWORK ANALYSIS(BAD714D)
2. Neighbours of 𝑣0 form U.
3. Iteratively add the vertex from U to C that gives the maximum increase in Qlocal.
4. Update C and U with new neighbours.
5. Stop when C reaches a predefined size or grows large enough.
Subgraph Modularity
• Subgraph Modularity (SM) improves upon Local Modularity by considering
vertex degrees instead of fixing subgraph size.
• It measures how densely connected a local subgraph (C) is relative to its
surroundings.
Adjacency Definition
1, if vertices 𝑖 and 𝑗 are connected, and 𝑖 ∈ 𝐶 ∨ 𝑗 ∈ 𝐶
𝑆𝑖𝑗 = {
0, otherwise
Degrees
2. Out-degree (Out(C)) → number of edges between C and the rest of the network
31
SOCIAL NETWORK ANALYSIS(BAD714D)
32
SOCIAL NETWORK ANALYSIS(BAD714D)
Common CS Methods
1. K-core:
Maximal subgraph where each node has at least degree k.
2. K-clique:
Set of k vertices, each connected to every other vertex.
3. K-truss:
Maximal subgraph where each edge belongs to at least (k − 2) triangles.
4. K-ECC (K-edge connected component):
Subgraph that remains connected even after removing (k − 1) edges.
Purity Metric
• Given:
o 𝐺(𝑉, 𝐸): Network
33
SOCIAL NETWORK ANALYSIS(BAD714D)
• Range:
0 ≤ 𝑃𝑢𝑟𝑖𝑡𝑦 ≤ 1
• Interpretation:
o 1 (maximum): Detected communities perfectly match ground-truth.
o 0: No resemblance between detected and actual communities.
• Limitation:
o Purity = 1 can also occur when each node forms its own community (singleton
communities), which is misleading.
34
SOCIAL NETWORK ANALYSIS(BAD714D)
Term Meaning
True Positive Node pair is in the same community in both predicted and ground-truth
(TP) structures.
True Negative Node pair is in different communities in both predicted and ground-truth
(TN) structures.
False Positive Node pair is in different communities in ground-truth but same community
(FP) in predicted structure.
False Negative Node pair is in same community in ground-truth but different communities
(FN) in predicted structure.
Formula
𝑇𝑃 + 𝑇𝑁
𝑅𝐼 =
𝑇𝑃 + 𝑇𝑁 + 𝐹𝑃 + 𝐹𝑁
Interpretation
• Range: 0 ≤ 𝑅𝐼 ≤ 1
• RI = 1: Perfect agreement between detected and true communities.
• RI = 0: No agreement (completely incorrect detection).
Problem with RI
35
SOCIAL NETWORK ANALYSIS(BAD714D)
Where:
Range:
• −1 ≤ 𝐴𝑅𝐼 ≤ 1
Range:
• 0 ≤ 𝐼(Ω, 𝐶) ≤ 1
36
SOCIAL NETWORK ANALYSIS(BAD714D)
𝐼(Ω, 𝐶)
𝑁𝑀𝐼(Ω, 𝐶) =
1
2 [𝐻(Ω) + 𝐻(𝐶)]
∣𝜔𝑗 ∣ ∣𝜔𝑗 ∣
where entropy 𝐻(Ω) = − ∑𝑗 log
𝑁 𝑁
1. Omega Index
where:
• Interpretation:
o Ranges from 0 to 1
o 1 → perfect agreement
o 0 → no similarity
37
SOCIAL NETWORK ANALYSIS(BAD714D)
3. F1-Score
where:
• Matching criterion:
• Interpretation:
o Higher F1 → better community detection accuracy
o Can also be used to test equivalence between two overlapping community
structures
38