|
199 | 199 | "\n", |
200 | 200 | "The directed modularity formula is:\n", |
201 | 201 | "\n", |
202 | | - "$$Q_{dir} = \\frac{1}{m} \\sum_{i,j} \\left[ A_{ij} - \\gamma \\frac{k_{i}^{out} k_{j}^{in}}{m} \\right] \\delta(c_i, c_j)$$\n", |
| 202 | + "$$Q = \\frac{1}{m} \\sum_{i,j} \\left[ A_{ij} - \\gamma \\frac{k_i^\\text{out} k_j^\\text{in}}{m} \\right] \\delta(c_i, c_j)$$\n", |
203 | 203 | "\n", |
204 | 204 | "Where:\n", |
205 | 205 | "* $m$: Total number of directed edges in the graph.\n", |
|
213 | 213 | "* **Flipping a single edge:** Reversing a single edge (e.g., from A → B to B → A) will change the modularity score. This is because the out-degree of A and the in-degree of B would change, altering the null model's calculation and, consequently, the overall score.\n", |
214 | 214 | "* **Flipping all edges:** If you reverse the direction of **every single edge** in the network, the modularity score will **remain the same**. This is due to a symmetry property of the formula. The set of in-degrees becomes the new set of out-degrees, and vice versa. When the formula is applied to this completely reversed network, the total modularity score is unchanged. This is a fascinating property of directed modularity.\n", |
215 | 215 | "\n", |
| 216 | + "# From directed to undirected formula\n", |
| 217 | + "Start with the directed formula:\n", |
| 218 | + "\n", |
| 219 | + "$$Q = \\frac{1}{m} \\sum_{i,j} \\left[ A_{ij} - \\gamma \\frac{k_i^\\text{out} k_j^\\text{in}}{m} \\right] \\delta(c_i, c_j)$$\n", |
| 220 | + "\n", |
| 221 | + "Substitute $(k_i^\\text{out} = k_i)$ and $(k_j^\\text{in} = k_j)$:\n", |
| 222 | + "\n", |
| 223 | + "$$Q = \\frac{1}{m} \\sum_{i,j} \\left[ A_{ij} - \\gamma \\frac{k_i k_j}{m} \\right] \\delta(c_i, c_j)$$\n", |
| 224 | + "\n", |
| 225 | + "However, this sum is **over ordered pairs** \\((i,j)\\), so each undirected edge is **counted twice**. \n", |
| 226 | + "To avoid double counting, we divide by $2$:\n", |
| 227 | + "\n", |
| 228 | + "\n", |
| 229 | + "$$Q = \\frac{1}{2m} \\sum_{i,j} \\left[ A_{ij} - \\gamma \\frac{k_i k_j}{2m} \\right] \\delta(c_i, c_j)$$\n", |
| 230 | + "\n", |
| 231 | + "This matches the undirected formula exactly.\n", |
| 232 | + "\n", |
216 | 233 | "\n", |
217 | 234 | "\n", |
218 | 235 | "# Why the resolution parameter is important\n", |
|
253 | 270 | "\n", |
254 | 271 | "In this formulation, the null model assumes **uniform edge probability**, so communities are favored if their **internal density** is higher than the global density.\n" |
255 | 272 | ] |
| 273 | + }, |
| 274 | + { |
| 275 | + "cell_type": "code", |
| 276 | + "execution_count": null, |
| 277 | + "id": "1b9c3fa0-05b7-461f-acf8-8348f344a2d9", |
| 278 | + "metadata": {}, |
| 279 | + "outputs": [], |
| 280 | + "source": [] |
256 | 281 | } |
257 | 282 | ], |
258 | 283 | "metadata": { |
|
0 commit comments