# 网络聚类

网络聚类，又称社区发现，是一种图分析方法，它把网络的节点划分为若干组（簇或社区），使组内连接稠密、组间连接稀疏。约 50 年间提出的算法数以千计，可归入四大类：基于割的方法、基于模块度的方法、基于推断的方法和基于学习的方法。<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup> 输入是一个图，可选带权或有向；输出通常是一个扁平划分或一个划分层级。例如，Louvain 方法会展开出完整的层级社区结构。<sup>[2](https://doi.org/10.1088/1742-5468/2008/10/p10008)</sup>

| 关键事实 | 数值 |
|---|---|
| 典型输出 | 一个节点划分；Louvain 还返回完整的社区层级<sup>[2](https://doi.org/10.1088/1742-5468/2008/10/p10008)</sup> |
| 标准质量函数 | 模块度，把簇内边与其在随机模型下的期望相比较<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup> |
| 计算状态 | 模块度优化是 NP 难的，因此所有广泛使用的算法都是启发式的<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup> |
| 已演示的规模 | 1.18 亿个节点、逾 10 亿条连边，在 152 分钟内完成聚类（Louvain，2008）<sup>[2](https://doi.org/10.1088/1742-5468/2008/10/p10008)</sup> |
| 模块度的已知缺陷 | 最大模块度划分所含的社区数不能超过 \( 2E \)<sup>[3](https://www.cambridge.org/core/elements/descriptive-vs-inferential-community-detection-in-networks/7A5360B356DDC65A89662688C3602CBF)</sup> |
| 基准准确度 | 在混合参数 \( \mu \approx 1/2 \) 以下的 LFR 案例中，Infomap 100% 恢复了植入划分<sup>[4](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.056117)</sup> |
| Leiden 的保证 | 每一次迭代后，所有簇都连通且良好分离<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup> |

## 工作原理

每种聚类算法都需要一个质量函数来给划分打分。使用最广的是模块度，它衡量各簇内部节点的连接比随机模型下的期望稠密多少：<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup>

\[ M(C_{1}, \ldots, C_{k}) = \frac{1}{2m} \sum_{\ell} \sum_{i,j \in C_{\ell}} \left( A_{ij} - p_{ij} \right), \]

其中 \( A_{ij} \) 是邻接矩阵元素，\( m \) 是边数，\( p_{ij} \) 是零模型下的期望连边概率。纽曼（Newman）和吉文（Girvan）于 2004 年提出这一度量，作为选择网络应划分为多少个社区的客观指标。<sup>[6](https://doi.org/10.1103/physreve.69.026113)</sup> 另一种选择是常数 Potts 模型（Constant Potts Model, CPM），

其中 \( E(C,C) \) 是簇内边数，\( k_{C} \) 是簇 \( C \) 的总度数；与模块度不同，CPM 不受分辨率极限之困。<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup> 第三类方法最小化映射方程，它度量图上随机游走的最短描述长度。<sup>[4](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.056117)</sup><sup> • </sup><sup>[21](https://mapequation.org/infomap-python-docs/examples/options-guide.html)</sup> 由于模块度优化是 NP 难的，所有流行算法都是[启发式](https://www.edgepedia.org/zh/heuristic)的：贪心凝聚、谱方法、极值优化和模拟退火都用过。<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup>

## 具体做法

**边介数（吉文–纽曼）。** 这种分裂式方法先计算每条边的介数（顶点对之间沿该边的最短路径条数），删除介数最高的边，再对受影响的边重新计算介数，如此反复直到没有边剩下；省略重算这一步会导致社区发现出错。其运行时间为 \( O(m^{2}n) \)，在稀疏图上是 \( O(n^{3}) \)，因而对超大图不实用。<sup>[7](https://doi.org/10.1073/pnas.122653799)</sup>

**Louvain（贪心模块度）。** 该方法交替进行两个阶段：局部移动，即每个节点加入能带来最大模块度增益的相邻社区；聚合，即在所发现的社区之上重建网络；这两个阶段逐轮反复进行，直到不再有增益。把孤立节点 \( i \) 移入社区 \( C \) 的增益为

\[ \Delta Q = \frac{k_{i,in}}{m} - \gamma \frac{\Sigma_{tot} \cdot k_{i}}{2m^{2}}, \]

其中 \( k_{i,in} \) 是 \( i \) 连入 \( C \) 的边的权重，\( k_{i} \) 是 \( i \) 的加权度，\( \Sigma_{tot} \) 是 \( C \) 中所有关联权重之和，\( \gamma \) 是分辨率参数；对有向图，增益变为 \( \Delta Q = k_{i,in}/m - \gamma (k_{i}^{out} \cdot \Sigma_{tot}^{in} + k_{i}^{in} \cdot \Sigma_{tot}^{out})/m^{2} \)。<sup>[8](https://networkx.org/documentation/stable/_modules/networkx/algorithms/community/louvain.html)</sup>

**莱顿（Leiden）。** [莱顿算法](https://www.edgepedia.org/zh/leiden-algorithm)分三个阶段工作：节点局部移动、划分精化，以及基于精化后的划分对网络进行聚合——聚合网络以未精化的划分作为初始划分。在其快速局部移动中，只访问邻域发生改变的节点，而 Louvain 则不断访问所有节点。<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup>

**谱模块度。** 纽曼在 2006 年证明，模块度可以用模块度矩阵的特征向量来表达，由此得到的谱算法比当时与之竞争的方法结果质量更高、运行时间更短。<sup>[9](https://doi.org/10.1073/pnas.0601602103)</sup>

**Infomap 与标签传播。** Infomap 压缩对随机游走的描述；标签传播迭代地把每个节点的邻居中出现最多的标签赋给它，它等价于一个 Potts 模型，迭代 \( L \) 次的时间复杂度为 \( O(L|E|) \)。<sup>[4](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.056117)</sup>

## 起源

吉文和纽曼于 2002 年在《[美国国家科学院院刊](https://www.edgepedia.org/zh/proceedings-of-the-national-academy-of-sciences)》（Proceedings of the National Academy of Sciences）上发表了边介数分裂算法。<sup>[7](https://doi.org/10.1073/pnas.122653799)</sup> 2004 年，纽曼和吉文接着提出了模块度度量以及一套评估边删除方法的框架。<sup>[6](https://doi.org/10.1103/physreve.69.026113)</sup> 同年，快速贪心模块度算法问世，由纽曼独著发表于《[物理评论 E](https://www.edgepedia.org/zh/physical-review-e)》（Physical Review E），尽管后来一些综述把它算作纽曼与吉文共同的成果。<sup>[10](https://doi.org/10.1103/physreve.69.066133)</sup> 同样在 2004 年，拉迪基（Radicchi）、卡斯特拉诺（Castellano）、切科尼（Cecconi）、洛雷托（Loreto）和帕里西（Parisi）提出了一种局部算法，其定量化的社区定义在更低的计算成本下达到了与现有方法相当的可靠性；2005 年，杜赫（Duch）和阿雷纳斯（Arenas）发表了用极值优化求解模块度优化的方法。<sup>[11](https://doi.org/10.1073/pnas.0400054101)</sup><sup> • </sup><sup>[12](https://doi.org/10.1103/physreve.72.027104)</sup> 谱模块度矩阵算法随后于 2006 年问世。<sup>[9](https://doi.org/10.1073/pnas.0601602103)</sup>

Louvain 方法由布隆代尔（Blondel）、纪尧姆（Guillaume）、朗比奥特（Lambiotte）和勒费弗尔（Lefebvre）于 2008 年 3 月 4 日发布到 arXiv，基于勒费弗尔的硕士论文；在被《自然》（Nature）和《美国国家科学院院刊》拒稿后，于 2008 年 10 月在《统计力学：理论与实验》（JSTAT）上发表；它曾一度以作者姓氏首字母命名为 BGLL。<sup>[13](https://iopscience.iop.org/article/10.1088/1742-5468/ad6139)</sup> 沃尔特曼（Waltman）和范埃克（van Eck）的智能局部移动算法是莱顿算法的重要前身，出现于 2013 年。<sup>[14](https://doi.org/10.1140/epjb/e2013-40829-0)</sup> 常数 Potts 模型见于特拉格（Traag）、范多伦（Van Dooren）和涅斯捷罗夫（Nesterov）2011 年发表于《物理评论 E》的论文，<sup>[15](https://doi.org/10.1103/physreve.84.016114)</sup> 特拉格、沃尔特曼和范埃克于 2019 年在《[科学报告](https://www.edgepedia.org/zh/scientific-reports)》（Scientific Reports）上发表了莱顿算法。<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup>

## 变体

**Louvain 与莱顿之比较。** Louvain 是一种贪心的两阶段启发式算法，在基准测试中复杂度接近线性，但它继承了模块度的分辨率极限，且不保证全局最优。<sup>[13](https://iopscience.iop.org/article/10.1088/1742-5468/ad6139)</sup> 在实证测试中，Louvain 的社区多达 25% 连通性很差，多达 16% 是不连通的；莱顿在每次迭代后都保证社区连通且良好分离，迭代运行则收敛到这样的划分：所有社区的所有子集都被局部最优地指派。在实证网络上，莱顿比 Louvain 快至多 20 倍；在最大、最难的基准网络上快 10 到 100 倍，同时还能发现更好的划分。<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup> Louvain 的论文在一个 200 万客户的比利时移动电话网络、以及一个 1.18 亿节点、逾 10 亿条连边的网页图上展示了其速度，后者的社区识别耗时 152 分钟；模拟表明，在典型数据和稀疏数据上其复杂度是线性的。<sup>[2](https://doi.org/10.1088/1742-5468/2008/10/p10008)</sup>

**质量函数的变体。** Louvain 框架已被改造用来优化其他质量函数，包括映射方程和马尔可夫稳定性；映射方程有其自身的视野极限，会导致不理想的过度划分。<sup>[13](https://iopscience.iop.org/article/10.1088/1742-5468/ad6139)</sup> CPM 在同一套算法机制内充当模块度的无分辨率极限替代品。<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup> 一个随机游走阶段可以精化 Louvain 第一阶段得到的簇，复杂度与 Louvain 相当，而效率更优。<sup>[16](https://ideas.repec.org/a/spr/jcomop/v50y2025i2d10.1007_s10878-025-01337-9.html)</sup>

**如何取舍。** 在一项针对 1000 到 1000000 个节点的图的比较中，标签传播对网络规模相对不敏感，但对混合参数 \( \mu \) 敏感：对于界定清晰的簇，标签传播表现良好；而对于界定不那么清晰的簇，Louvain 和 Infomap 更胜一筹。<sup>[17](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0159161)</sup> 在 LFR 基准（它把吉文–纽曼植入基准推广到幂律度分布与社区规模分布）上，Infomap 和龙霍夫德–努西诺夫（Ronhovde–Nussinov）方法在 \( \mu_{t} \sim 1/2 \) 以下 100% 的案例中恢复了植入划分，而基于模块度的方法表现不佳，且系统越大、社区越小就越差。<sup>[4](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.056117)</sup>

## 应用

已发表的演示集中于网络科学数据集，而非对各个领域的系统调查。有记载的例子包括一个合著网络和一个此前社区结构不甚清楚的食物网，<sup>[7](https://doi.org/10.1073/pnas.122653799)</sup> 一个 200 万客户的比利时移动电话网络，<sup>[2](https://doi.org/10.1088/1742-5468/2008/10/p10008)</sup> 以及一个对当时的方法来说过于庞大、局部算法却能处理的科学合著网络。<sup>[11](https://doi.org/10.1073/pnas.0400054101)</sup>

## 局限与替代方案

**分辨率极限。** 模块度偏向大簇：在最大模块度划分中，每个簇都满足 \( d_{a} \ge \sqrt{2m} \)，<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup> 并且模块度最大化在一个连通网络中找不到超过 \( 2E \) 个社区。在一个植入了 30 个社区的随机块模型网络上，模块度最大化只找到 18 个，而推断方法恢复了真实结构。<sup>[3](https://www.cambridge.org/core/elements/descriptive-vs-inferential-community-detection-in-networks/7A5360B356DDC65A89662688C3602CBF)</sup> 一个具体的例子：对一个由 24 个各含 5 个节点的团组成的环，把相邻团合并的划分得分为 \( Q_{2} = 0.8712 \)，而真实团划分的得分为 \( Q_{1} = 0.8674 \)，因此合并更受偏爱。这种效应主要出现在大型无权网络中，而多数其他目标函数（包括 Potts 模型和似然函数）也表现出相关局限。<sup>[18](https://www.cscamm.umd.edu/programs/ntd10/presentations/Clauset.pdf)</sup>

**过拟合与简并。** 即便网络是从模块度自身的零模型中采样而来，模块度最大化也能找到高分划分，而调整分辨率参数一般并不奏效；带层级先验的推断方法避免了这一点，所能找到的最大分组数按 \( O(N/\log N) \) 的量级增长，且不会过拟合。<sup>[3](https://www.cambridge.org/core/elements/descriptive-vs-inferential-community-detection-in-networks/7A5360B356DDC65A89662688C3602CBF)</sup> 高模块度划分的数量组合式地增长，介于 \( 2^{k-1} \) 与第 \( k \) 个[贝尔数](https://www.edgepedia.org/zh/bell-number)之间，因此许多近乎等价的划分彼此竞争。<sup>[18](https://www.cscamm.umd.edu/programs/ntd10/presentations/Clauset.pdf)</sup> Louvain 在毫无簇结构的随机零模型图上也会找到相对较高的模块度值，所以单凭高模块度分数并不能证明结构有意义。<sup>[1](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)</sup>

**不连通的社区与次优性。** 无论对 CPM 还是模块度，Louvain 算法都会产生内部不连通或连通性很差的社区。<sup>[5](https://doi.org/10.1038/s41598-019-41695-z)</sup> 莱顿消除了这一缺陷；良连通簇（Well-Connected Clusters, WCC）和连通性修正器（Connectivity Modifier, CM）算法则对任意输入的聚类结果做后处理，通过递归最小割二分强加一个用户定义的边连通性标准。<sup>[19](https://link.springer.com/article/10.1007/s41109-026-00818-y)</sup> 启发式方法的质量存在可测量的天花板：在 80 个真实网络与随机网络上，模块度最大化启发式平均只为 19.4% 的图返回了最优划分，其中 Combo 成功率为 55%，莱顿为 36.2%，Louvain 为 18.7%。<sup>[20](https://link.springer.com/chapter/10.1007/978-3-031-36027-5_48)</sup> 作为模块度启发式方法的替代，CPM 和推断（基于似然的）方法直接针对分辨率极限与过拟合问题。<sup>[3](https://www.cambridge.org/core/elements/descriptive-vs-inferential-community-detection-in-networks/7A5360B356DDC65A89662688C3602CBF)</sup><sup> • </sup><sup>[15](https://doi.org/10.1103/physreve.84.016114)</sup>

## References

1. [Network clustering tutorial (SIGMETRICS 2024)](https://www.sigmetrics.org/sigmetrics2024/tutorials/Tutorial_Network_Clustering.pdf)
2. [Vincent D Blondel and colleagues (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics Theory and Experiment.](https://doi.org/10.1088/1742-5468/2008/10/p10008)
3. [Descriptive vs. Inferential Community Detection in Networks (Peixoto, Cambridge Elements)](https://www.cambridge.org/core/elements/descriptive-vs-inferential-community-detection-in-networks/7A5360B356DDC65A89662688C3602CBF)
4. [Community detection algorithms: A comparative analysis (Lancichinetti & Fortunato, Phys. Rev. E 80, 056117, 2009)](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.056117)
5. [V. A. Traag, L. Waltman, N. J. van Eck (2019). From Louvain to Leiden: guaranteeing well-connected communities. Scientific Reports.](https://doi.org/10.1038/s41598-019-41695-z)
6. [M. E. J. Newman, M. Girvan (2004). Finding and evaluating community structure in networks. Physical Review E.](https://doi.org/10.1103/physreve.69.026113)
7. [M. Girvan, M. E. J. Newman (2002). Community structure in social and biological networks. Proceedings of the National Academy of Sciences.](https://doi.org/10.1073/pnas.122653799)
8. [networkx.algorithms.community.louvain, NetworkX 3.6.1 documentation](https://networkx.org/documentation/stable/_modules/networkx/algorithms/community/louvain.html)
9. [M. E. J. Newman (2006). Modularity and community structure in networks. Proceedings of the National Academy of Sciences.](https://doi.org/10.1073/pnas.0601602103)
10. [M. E. J. Newman (2004). Fast algorithm for detecting community structure in networks. Physical Review E.](https://doi.org/10.1103/physreve.69.066133)
11. [Filippo Radicchi and colleagues (2004). Defining and identifying communities in networks. Proceedings of the National Academy of Sciences.](https://doi.org/10.1073/pnas.0400054101)
12. [Jordi Duch, Alex Arenas (2005). Community detection in complex networks using extremal optimization. Physical Review E.](https://doi.org/10.1103/physreve.72.027104)
13. [Fast unfolding of communities in large networks: 15 years later (J. Stat. Mech., 2024)](https://iopscience.iop.org/article/10.1088/1742-5468/ad6139)
14. [Ludo Waltman, Nees Jan van Eck (2013). A smart local moving algorithm for large-scale modularity-based community detection. The European Physical Journal B.](https://doi.org/10.1140/epjb/e2013-40829-0)
15. [V. A. Traag, P. Van Dooren, Y. Nesterov (2011). Narrow scope for resolution-limit-free community detection. Physical Review E.](https://doi.org/10.1103/physreve.84.016114)
16. [An improvement on the Louvain algorithm using random walks (Do & Phan, J Combinatorial Optimization, 2025)](https://ideas.repec.org/a/spr/jcomop/v50y2025i2d10.1007_s10878-025-01337-9.html)
17. [Analysis of Network Clustering Algorithms and Cluster Quality Metrics at Scale (PLOS One)](https://journals.plos.org/plosone/article?id=10.1371%2Fjournal.pone.0159161)
18. [The Trouble with Community Detection (Aaron Clauset, slides, 2010)](https://www.cscamm.umd.edu/programs/ntd10/presentations/Clauset.pdf)
19. [Well-connected community detection at extreme scale: shared- and distributed-memory parallel algorithms (Applied Network Science, 2026)](https://link.springer.com/article/10.1007/s41109-026-00818-y)
20. [Heuristic Modularity Maximization Algorithms for Community Detection Rarely Return an Optimal Partition or Anything Similar (Springer, 2023)](https://link.springer.com/chapter/10.1007/978-3-031-36027-5_48)
21. [Infomap options guide](https://mapequation.org/infomap-python-docs/examples/options-guide.html)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods › Graph and network algorithms › Network analysis and centrality

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/network-clustering

English original: https://www.edgepedia.org/network-clustering
