Skip to content

Commit 277c40b

Browse files
committed
add: resolution limit and modularity formula update
1 parent cc82050 commit 277c40b

File tree

2 files changed

+803
-655
lines changed

2 files changed

+803
-655
lines changed

doc/source/community_detection_guide/notebooks/modularity.ipynb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
"\n",
1010
"Modularity is a quantitative metric used to evaluate the strength of a network's division into modules (or communities). It measures how well the network is partitioned by comparing the density of edges within communities to the expected density of such edges in a randomized network that preserves the original degree distribution. The formula for modularity is given below.\n",
1111
"\n",
12-
"$$Q = \\frac{1}{2m} \\sum_{i,j} \\left[ A_{ij} - \\frac{k_i k_j}{2m} \\right] \\delta(c_i, c_j)$$\n",
12+
"$$Q = \\frac{1}{2m} \\sum_{i,j} \\left[ A_{ij} - \\gamma \\frac{k_i k_j}{2m} \\right] \\delta(c_i, c_j)$$\n",
1313
"\n",
1414
"Where:\n",
1515
"* $m$: Total number of edges in the graph (sum of all edge weights for a weighted graph).\n",
1616
"* $A_{ij}$: Element of the adjacency matrix, representing the weight of the edge between node $i$ and node $j$ (0 if no edge).\n",
1717
"* $k_i$: Degree of node $i$ (sum of weights of edges connected to node $i$).\n",
1818
"* $k_j$: Degree of node $j$.\n",
19+
"* $\\gamma$ is the resolution parameter. The default value is 1.0.\n",
1920
"* $\\delta(c_i, c_j)$: Kronecker delta function, which is 1 if node $i$ and node $j$ belong to the same community ($c_i = c_j$), and 0 otherwise.\n",
2021
"\n",
2122
"### Example graph\n",
@@ -190,7 +191,18 @@
190191
"id": "f3981bc5-f6bf-4b41-a168-cae9c17ec764",
191192
"metadata": {},
192193
"source": [
193-
"*Note:* Based on our previous analysis, the \"good\" partitioning yields a significantly higher modularity score. It is important to note, however, that a high modularity score is not always a definitive indicator of a better community partitioning, as was previously demonstrated with the Grid Graph [here](test_significance_of_community.ipynb)."
194+
"*Note:* Based on our previous analysis, the \"good\" partitioning yields a significantly higher modularity score. It is important to note, however, that a high modularity score is not always a definitive indicator of a better community partitioning, as was previously demonstrated with the Grid Graph [here](test_significance_of_community.ipynb).\n",
195+
"\n",
196+
"### Why the Resolution Parameter is Important\n",
197+
"\n",
198+
"The resolution parameter addresses a fundamental limitation of the original modularity measure, known as the **\"resolution limit\"**. This is the tendency of the original formula (where $\\gamma=1$) to fail at detecting small communities, especially in large graphs. It often merges smaller, distinct communities into a single larger one to maximize the modularity score.\n",
199+
"\n",
200+
"By adjusting the value of $\\gamma$, you can control the granularity of the community detection:\n",
201+
"\n",
202+
"* **$\\gamma > 1$**: Increasing the resolution parameter penalizes connections more heavily. This encourages the algorithm to find **fewer and larger communities**, as it becomes harder for smaller, highly connected groups to form their own separate communities.\n",
203+
"* **$\\gamma < 1$**: Decreasing the resolution parameter reduces the penalty. This allows the algorithm to find **more and smaller communities**, as it becomes easier for closely-knit groups to be identified as their own communities.\n",
204+
"\n",
205+
"In essence, the resolution parameter provides a flexible way to explore the community structure of a network at different scales, moving beyond the limitations of a single, fixed-scale partition."
194206
]
195207
}
196208
],

doc/source/community_detection_guide/notebooks/resolution.ipynb

Lines changed: 789 additions & 653 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)