# 标签传播算法

标签传播是一种图算法：它为每个节点分配一个标签，并反复将每个节点的标签替换为其邻居中最常见的那个标签，从而使连接稠密的群体收敛到同一个共享标签上。它主要用于两种场景：网络中的近线性时间社区检测，以及半监督分类——标签从少量已标注样本传播到未标注样本。它的吸引力在于速度和简洁：不需要目标函数，不需要预先指定社区数量，实践中只需少量迭代。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup><sup> • </sup><sup>[2](http://reports-archive.adm.cs.cmu.edu/anon/cald/abstracts/02-107.html)</sup>

| 关键事实 | 内容 |
|---|---|
| 社区检测版本 | Raghavan、Albert 与 Kumara，Physical Review E，2007<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup> |
| 半监督版本 | Zhu 与 Ghahramani，CMU-CALD-02-107，2002年6月<sup>[2](http://reports-archive.adm.cs.cmu.edu/anon/cald/abstracts/02-107.html)</sup> |
| 复杂度 | 初始化 \( O(n) \)，每次迭代 \( O(m) \)，k 次迭代总体 \( O(k(m+n)) \)<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup><sup> • </sup><sup>[3](https://dl.acm.org/doi/10.1145/3564593)</sup> |
| LFR 基准准确度 | 在混合参数 \( \mu = 0.3 \) 以内可完美检测；\( \mu = 0.5 \) 时失效<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup> |
| 已知失效模式 | 巨型（怪物）簇、内部不连通的社区、非确定性<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup><sup> • </sup><sup>[5](https://www.sciencedirect.com/science/article/abs/pii/S0167739X25002912)</sup> |
| 已报告的大规模运行 | Metaclust50 网络，2.82 亿节点、420 亿条边，4096 个处理器上耗时 654 秒<sup>[6](https://dl.acm.org/doi/10.1007/978-3-031-78541-2_1)</sup> |

## 工作原理

在社区检测形式中，每个节点初始时持有自己的标签。每一步，一个节点对每个候选标签 c 统计有多少邻居携带该标签，使用[克罗内克δ](https://www.edgepedia.org/zh/kronecker-delta)：\( n_{c} = \sum_{j \in V} A_{ij}\,\delta(c_{j}, c) \)，其中 \( A_{ij} \) 是邻接矩阵元素。然后该节点从出现最频繁的标签集合中选择一个标签。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup> 连接稠密的群体会就某一个标签达成共识，因为群体内部的节点看到该标签的频率远高于任何外部标签；连接稀疏的边界区域不会强制形成共识，因此标签边界会稳定在群体之间。该方法不优化任何显式的质量度量；社区的数量和大小只在结束时才显现。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup>

半监督变体工作在软标签上，即类别的概率分布，沿着由数据构建的加权图进行传播。类别边界通过权重大的边推进，并稳定在权重小的边之间的空隙中。<sup>[7](https://aclanthology.org/P06-1017.pdf)</sup> Zhu、Ghahramani 与 Lafferty 将此建模为图上的[高斯随机场](https://www.edgepedia.org/zh/gaussian-random-field)，一种最近邻方法，其中最近的已标注样本通过图上的随机游走来计算。<sup>[8](https://cdn.aaai.org/ICML/2003/ICML03-118.pdf)</sup> scikit-learn 的实现从亲和矩阵构建图，默认的 RBF 核给出全连接图，KNN 核给出稀疏图，并迭代传播标签分布直至收敛。<sup>[9](https://github.com/scikit-learn/scikit-learn/blob/f3182980c/sklearn/semi_supervised/_label_propagation.py)</sup>

## 操作步骤

实践者按如下方式运行社区检测版本。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup><sup> • </sup><sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup>

1. 为每个节点初始化一个唯一标签，例如 \( c_{i} = i \)。
2. 遍历节点，将每个节点的标签设为其邻居中最频繁的标签，平局时均匀随机打破。
3. 重复直到满足停止准则：若节点 i 的标签为 \( C_{m} \)，则对所有 j 有 \( d_{i}^{C_{m}} \geq d_{i}^{C_{j}} \)，即每个节点在其社区内的邻居数不少于在任何其他单个社区内的邻居数。这接近但弱于强社区要求——内部邻居严格多于外部。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup>

更新顺序很重要。同步更新（所有节点同时更新）在近二分网络上可能振荡，因此首选异步更新——按随机顺序逐个处理节点。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup> 并行实现通常在更新标签数低于阈值 \( \theta \) 时停止<sup>[3](https://dl.acm.org/doi/10.1145/3564593)</sup>，GPU 实现在至少 \( 1 - \tau \) 的顶点保持标签不变时停止，其中 \( \tau \) 是容差参数。<sup>[10](https://dl.acm.org/doi/10.1145/3806645.3807602)</sup>

半监督循环通过 \( Y^{t+1} = T \cdot Y^{t} \) 传播软标签，其中 T 是行归一化的转移矩阵，然后在每次迭代中将已标注行钳回其初始值 \( Y_{0}^{L} \)；已标注数据充当源，将标签推过未标注数据。<sup>[7](https://aclanthology.org/P06-1017.pdf)</sup> 存在两种钳制方式：硬钳制，永不允许初始分配改变；软钳制，允许它们每次迭代按比例 \( \alpha \) 改变。在 scikit-learn 中，LabelPropagation 将未标注项置零并重新归一化行（硬钳制），而 LabelSpreading 使用更新 \( Y^{t+1} = \alpha S \cdot Y^{t} + (1 - \alpha) Y_{0} \)，其中 \( S \) 是归一化亲和算子，\( Y_{0} \) 是初始标签矩阵，钳制因子 \( \alpha \in (0,1) \)，亲和矩阵基于归一化图拉普拉斯。<sup>[9](https://github.com/scikit-learn/scikit-learn/blob/f3182980c/sklearn/semi_supervised/_label_propagation.py)</sup><sup> • </sup><sup>[11](https://scikit-learn.org/stable/modules/generated/sklearn.semi_supervised.LabelSpreading.html)</sup> 当标签分布的绝对变化之和低于 tol 时检查收敛，并设有最大迭代次数上限。<sup>[9](https://github.com/scikit-learn/scikit-learn/blob/f3182980c/sklearn/semi_supervised/_label_propagation.py)</sup>

## 起源

社区检测版本由 Usha Nandini Raghavan、Réka Albert 与 Soundar Kumara 在《[近线性时间算法用于检测大规模网络中的社区结构](https://www.edgepedia.org/zh/physical-review-e)》（Physical Review E，2007）中报告。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup> 半监督版本由 Xiongjie Zhu 与 [Zoubin Ghahramani](https://www.edgepedia.org/zh/zoubin-ghahramani) 在卡内基梅隆技术报告《利用标签传播从已标注和未标注数据中学习》（CMU-CALD-02-107，2002年6月）中提出，该工作沿未标注数据定义的高密度区域在数据集中传播标签，并给出闭式解。<sup>[2](http://reports-archive.adm.cs.cmu.edu/anon/cald/abstracts/02-107.html)</sup> 后续相关的表述是 Xiaojin Zhu、Zoubin Ghahramani 与 John Lafferty 2003 年的高斯场与调和函数论文，将传播重新表述为高斯随机场中的推断。<sup>[8](https://cdn.aaai.org/ICML/2003/ICML03-118.pdf)</sup> 在网络方面，停止准则与 Radicchi 等人 2004 年的强社区定义相似但不完全相同。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup> 后来的稳定化变体 LabelRank 由 Jierui Xie 与 Boleslaw K. Szymanski 于 2013 年描述。<sup>[12](https://doi.org/10.48550/arxiv.1303.0868)</sup>

## 变体

若干变体族针对 LPA 的随机性和单标签限制提出了解决方案。

**重叠社区。** COPRA 允许每个顶点属于至多 v 个社区，其中 v 是参数，并且还处理加权和二分网络。<sup>[13](https://iopscience.iop.org/article/10.1088/1367-2630/12/10/103018/pdf)</sup> SLPA 同样允许每个节点有多个标签；但两者都未解决 LPA 的随机性问题，因此不同运行可能产生不同的社区。<sup>[14](https://arxiv.org/html/1303.0868)</sup> LILPA 在多标签设置中加入节点权重，报告了准确度提升。<sup>[15](https://www.sciencedirect.com/science/article/abs/pii/S0925231220310778)</sup>

**稳定性与约束。** 保留策略仅在当前标签非最大时才更新节点标签，增加稳定性并有助于防止巨型簇。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup> 跳数衰减与链路优先的平局打破、模块度约束的传播，以及模块度改进的已检测社区合并，都被用于驯服平局情形并提高质量。<sup>[16](https://www.nature.com/articles/srep45836)</sup> 有一条工作线将 LPA 重新表述为等价的优化问题，并指出提高目标值与改善社区质量之间的差距是该方法的主要缺点；该形式的一个变体直接最大化模块度（衡量网络划分成社区好坏的分数）。<sup>[17](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.026129)</sup> 半同步模型——介于完全并行和完全顺序更新之间——已被证明总能收敛到稳定标签。<sup>[18](https://www.inderscience.com/info/inarticle.php?artid=45103)</sup> 平衡标签传播将自身限制为真正的划分，用于大规模图划分。<sup>[19](https://jugander.github.io/papers/wsdm13-blp.pdf)</sup> 在机器学习中，线性邻域传播通过具有足够平滑性的线性邻域传播标签，并扩展到样本外数据。<sup>[20](https://psycnet.apa.org/doi/10.1145/1143844.1143968)</sup>

**速度。** 快速变体 FLPA 处理一个队列，其中包含邻域最近发生变化的节点，运行速度可达原始 LPA 的 700 倍，同时保持标签最大性保证。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup>

## 应用

标签传播用于任何需要快速划分大图的场景。一个分布式内存混合并行 LPA 在 Metaclust50 网络（2.82 亿节点、420 亿条边）上用 4096 个处理器在 654 秒内检测出社区。<sup>[6](https://dl.acm.org/doi/10.1007/978-3-031-78541-2_1)</sup> 在 GPU 上，采用异步更新的 ν-LPA 在 [NVIDIA A100](https://www.edgepedia.org/zh/nvidia-a100) 上优于 FLPA、NetworKit LPA、Gunrock LPA 和 cuGraph Louvain，模块度高于 FLPA 但低于 NetworKit LPA 和 cuGraph Louvain。<sup>[21](https://doi.org/10.48550/arxiv.2411.11468)</sup> 内存高效的 GPU 实现（νMG-LPA 和 νBM-LPA）针对同一场景，基于前沿的方向优化框架（DOLPA）同时处理社区检测和连通分量。<sup>[10](https://dl.acm.org/doi/10.1145/3806645.3807602)</sup><sup> • </sup><sup>[3](https://dl.acm.org/doi/10.1145/3564593)</sup> 混合设计将传播与高阶结构结合：H-LPMC 将稳定标签传播与模体感知的加权传播配对，将三角形共现编码为边权重以减少不稳定性和随机性。<sup>[22](https://link.springer.com/article/10.1007/s10115-025-02557-5)</sup> LILPA 已应用于核心药物发现。<sup>[15](https://www.sciencedirect.com/science/article/abs/pii/S0925231220310778)</sup>

## 局限与替代方案

**复杂度。** 初始化花费 \( O(n) \)，每次迭代的时间开销为 \( O(m) \)，其中 m 为边数；迭代次数理论上未知，但实践中只需少量，因此 k 次迭代、m 条边、n 个顶点的运行时接近 \( O(k(m+n)) \)。<sup>[1](https://doi.org/10.1103/physreve.76.036106)</sup><sup> • </sup><sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup><sup> • </sup><sup>[3](https://dl.acm.org/doi/10.1145/3564593)</sup>

**失效模式。** 因为合并相邻簇不会改变标签最大性，簇的任意组合仍然满足停止准则，所以 LPA 可能产生巨型（怪物）簇；其结果是一个隐式质量函数的局部极小值，该函数的最优解将所有节点放在一个社区中。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup> 在社区结构较弱的网络中，它可能返回单个平凡社区。<sup>[16](https://www.nature.com/articles/srep45836)</sup> 随机更新顺序和平局打破使其具有非确定性，不同运行返回不同的检测结果。<sup>[16](https://www.nature.com/articles/srep45836)</sup> 现有实现还会产生内部不连通的社区，NetworKit LPA 中比率高达 14.5%；基于 BFS 的变体事后拆分此类社区。<sup>[5](https://www.sciencedirect.com/science/article/abs/pii/S0167739X25002912)</sup>

**基准测试。** 在具有 100 个植入组的 LFR 基准图上，LPA 和 FLPA 在混合参数 \( \mu = 0.3 \) 以内完美检测植入划分，在 \( \mu = 0.4 \) 时退化，在 \( \mu = 0.5 \) 时完全失效。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup> 保留策略变体在随机块模型上需要平均度高于 15 才能恢复植入划分，而 LPA、FLPA 和 Leiden 算法在低得多的度下即可成功。<sup>[4](https://www.nature.com/articles/s41598-023-29610-z)</sup>

**方法选择。** LPA 比 Louvain 更快、更具可扩展性且更容易并行化，因为它不需要重复的优化步骤，尽管它通常达到较低的模块度。<sup>[5](https://www.sciencedirect.com/science/article/abs/pii/S0167739X25002912)</sup> 它也被描述为比 InfoMap 和基于谱的方法更简单、更快速。<sup>[6](https://dl.acm.org/doi/10.1007/978-3-031-78541-2_1)</sup> Louvain 是一种贪心模块度优化启发式方法，具有近线性复杂度，继承了模块度的分辨率限制，且不保证全局最优，因此权衡在于 LPA 的简单传播规则与 Louvain 为更高模块度进行的启发式搜索，两种方法都不保证全局最优划分。<sup>[23](https://google.iopscience.iop.org/article/10.1088/1742-5468/ad6139)</sup> 对于分类，在全连接图上使用硬钳制时选择 LabelPropagation，当噪声标签应被允许移动时选择 LabelSpreading，通过软钳制因子 \( \alpha \) 和基于拉普拉斯的亲和矩阵。<sup>[9](https://github.com/scikit-learn/scikit-learn/blob/f3182980c/sklearn/semi_supervised/_label_propagation.py)</sup><sup> • </sup><sup>[11](https://scikit-learn.org/stable/modules/generated/sklearn.semi_supervised.LabelSpreading.html)</sup>

## References

1. [Usha Nandini Raghavan, Réka Albert, Soundar Kumara (2007). Near linear time algorithm to detect community structures in large-scale networks. Physical Review E.](https://doi.org/10.1103/physreve.76.036106)
2. [CMU CALD Technical Report 02-107 abstract (Zhu & Ghahramani, June 2002)](http://reports-archive.adm.cs.cmu.edu/anon/cald/abstracts/02-107.html)
3. [Direction-optimizing Label Propagation Framework for Structure Detection in Graphs (ACM JEA, 2023)](https://dl.acm.org/doi/10.1145/3564593)
4. [Large network community detection by fast label propagation (Scientific Reports, 2023)](https://www.nature.com/articles/s41598-023-29610-z)
5. [GVE-LPA and GSL-LPA: High-speed and internally-connected label propagation on multicore systems (Future Generation Computer Systems, 2025)](https://www.sciencedirect.com/science/article/abs/pii/S0167739X25002912)
6. [Scalable High-Performance Community Detection Using Label Propagation in Massive Networks (2025)](https://dl.acm.org/doi/10.1007/978-3-031-78541-2_1)
7. [Semi-supervised Relation Extraction with Label Propagation (Chen et al., COLING/ACL 2006)](https://aclanthology.org/P06-1017.pdf)
8. [Semi-Supervised Learning Using Gaussian Fields and Harmonic Functions (Zhu, Ghahramani & Lafferty, ICML 2003)](https://cdn.aaai.org/ICML/2003/ICML03-118.pdf)
9. [sklearn/semi_supervised/_label_propagation.py](https://github.com/scikit-learn/scikit-learn/blob/f3182980c/sklearn/semi_supervised/_label_propagation.py)
10. [νMG-LPA and νBM-LPA: Memory Efficient GPU-based Label Propagation Algorithms for Community Detection (HPDC 2026)](https://dl.acm.org/doi/10.1145/3806645.3807602)
11. [LabelSpreading, scikit-learn documentation](https://scikit-learn.org/stable/modules/generated/sklearn.semi_supervised.LabelSpreading.html)
12. [Xie, Jierui, Szymanski, Boleslaw K. (2013). LabelRank: A Stabilized Label Propagation Algorithm for Community Detection in Networks. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1303.0868)
13. [Finding overlapping communities in networks by label propagation (COPRA, New Journal of Physics 2010)](https://iopscience.iop.org/article/10.1088/1367-2630/12/10/103018/pdf)
14. [LabelRank: A Stabilized Label Propagation Algorithm for Community Detection in Networks (arXiv, 2013)](https://arxiv.org/html/1303.0868)
15. [LILPA: A label importance based label propagation algorithm for community detection with application to core drug discovery (Neurocomputing, 2020)](https://www.sciencedirect.com/science/article/abs/pii/S0925231220310778)
16. [A semi-synchronous label propagation algorithm with constraints for community detection in complex networks (Scientific Reports, 2017)](https://www.nature.com/articles/srep45836)
17. [Detecting network communities by propagating labels under constraints (Liu & Murata, PRE 2009)](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.026129)
18. [Label propagation algorithm: a semi-synchronous approach (IJSNM 2012)](https://www.inderscience.com/info/inarticle.php?artid=45103)
19. [Balanced Label Propagation for Partitioning Massive Graphs (WSDM 2013)](https://jugander.github.io/papers/wsdm13-blp.pdf)
20. [Label propagation through linear neighborhoods (ICML 2006)](https://psycnet.apa.org/doi/10.1145/1143844.1143968)
21. [ν-LPA: Fast GPU-based Label Propagation Algorithm (LPA) for Community Detection](https://doi.org/10.48550/arxiv.2411.11468)
22. [Hybrid label propagation based on motifs and similarity measures for community detection (Knowledge and Information Systems, 2025)](https://link.springer.com/article/10.1007/s10115-025-02557-5)
23. [Fast unfolding of communities in large networks: 15 years later (Journal of Statistical Mechanics, 2024)](https://google.iopscience.iop.org/article/10.1088/1742-5468/ad6139)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 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/label-propagation-algorithm

English original: https://www.edgepedia.org/label-propagation-algorithm
