# 完全连接聚类

完全连接聚类是一种凝聚层次聚类方法，它将两个聚类之间的距离定义为一个聚类中任意成员与另一个聚类中任意成员之间的最大距离，并合并该值最小的一对聚类。由于每次合并都使结果聚类的直径最小化，该方法产生紧凑的、小直径的群组，而非单连接倾向于形成的那种长链状聚类；自约翰逊（Johnson）1967年的论文以来，它一直是传统凝聚层次聚类普遍公认的默认准则。<sup>[1](https://doi.org/10.1007/bf02289588)</sup><sup> • </sup><sup>[2](https://www.psychometricsociety.org/sites/main/files/file-attachments/johnson_citation_classic_ultrametric.pdf?1582948569=)</sup>

| 关键事实 | 详情 |
|---|---|
| 合并规则 | 聚类间距离为 \( d_{\max}(A,B) := \max_{a \in A} \max_{b \in B} d(a,b) \)；合并该值最小的一对<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup> |
| 等价视角 | 每次合并选择并集直径最小的聚类对<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup> |
| Lance–Williams系数 | \( \alpha_{1} = \alpha_{2} = 1/2 \)，\( \beta = 0 \)，\( \gamma = +1/2 \)，对任意输入距离均有效<sup>[4](https://dm.cs.tu-dortmund.de/en/mlbits/cluster-hac-intro/)</sup> |
| 运行时间 | 朴素实现 \( \Theta(n^{3}) \)；使用排序距离表为 \( O(n^{2} \log n) \)；使用最近邻链的精确算法为 \( O(n^{2}) \)，而CLINK是一种 \( O(n^{2}) \) 的依赖于顺序的算法，不保证重现精确的完全连接层次结构<sup>[5](https://nlp.stanford.edu/IR-book/completelink.html)</sup><sup> • </sup><sup>[6](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)</sup> |
| 输出 | 一个层次聚类，可据此绘制树状图并进行切割；SciPy将其表示为 \( (n-1) \times 4 \) 的连接矩阵（合并对、合并距离、聚类大小）<sup>[6](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)</sup> |
| 已知弱点 | 对离群点的敏感性，离群点可能将原本直观的聚类拆分开来<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup> |
| 标准软件 | R、MATLAB、Mathematica和SciPy<sup>[7](https://ar5iv.labs.arxiv.org/html/1109.2378)</sup> |

## 工作原理

该方法属于顺序的、凝聚的、层次的、非重叠的（SAHN）家族：它从单元素聚类开始，反复连接最近的两个聚类，直到只剩一个聚类，并记录每一步的合并高度。<sup>[7](https://ar5iv.labs.arxiv.org/html/1109.2378)</sup> 完全连接的特殊之处在于聚类不相似度。单连接使用最小成对距离，而完全连接使用最大距离，等价地即最小相似度，因此只有当两个聚类中每个成员都彼此接近时，这两个聚类才被视为接近。<sup>[4](https://dm.cs.tu-dortmund.de/en/mlbits/cluster-hac-intro/)</sup><sup> • </sup><sup>[8](https://elki-project.github.io/releases/release0.7.5/javadoc/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/linkage/CompleteLinkage.html)</sup>

这一规则有图论上的刻画。在给定的相似度阈值下，单连接聚类是相似图的连通分量，而完全连接聚类是其极大团，这正是名称的由来：每个成员都必须与所有其他成员相连。<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup> 约翰逊证明了这类层次聚类方案对应于超度量距离——即对任意三元组满足 \( u_{ij} \le \max(u_{ik}, u_{kj}) \) 的距离度量——并且他的最小方法和最大方法在输入的单调变换下不变，仅依赖于不相似度的秩次。<sup>[1](https://doi.org/10.1007/bf02289588)</sup><sup> • </sup><sup>[2](https://www.psychometricsociety.org/sites/main/files/file-attachments/johnson_citation_classic_ultrametric.pdf?1582948569=)</sup>

合并是非局部的：每次合并创建一个新聚类，其成员和直径综合了被合并的那一对聚类的成员和直径，而下一次合并从当前各聚类的成对完全连接距离中选择，因此聚类的整体结构可以影响每一次合并决策。这既产生了对紧凑聚类的偏好，也是该方法对离群点敏感性的根源。<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup>

## 操作方式

实践者计算一个 \( n \times n \) 的不相似度矩阵，然后反复找到最大成对距离最小的聚类对，将其合并，并记录合并距离。经过 \( n - 1 \) 次合并后，结果是一棵树状图，必须在某个高度切割才能得到扁平聚类；目前没有公认的切割点选择方法。<sup>[9](https://online.stat.psu.edu/stat555/node/86/)</sup> 合并聚类 \( A \) 和 \( B \) 之后，与其他每个聚类 \( C \) 的距离可以通过Lance–Williams递推公式从已存储的值更新，<sup>[4](https://dm.cs.tu-dortmund.de/en/mlbits/cluster-hac-intro/)</sup>

\[ d(A \cup B, C) = \alpha_{1} \, d(A,C) + \alpha_{2} \, d(B,C) + \beta \, d(A,B) + \gamma \, |d(A,C) - d(B,C)|, \]

对于完全连接，系数取 \( \alpha_{1} = 1/2 \)、\( \alpha_{2} = 1/2 \)、\( \beta = 0 \)、\( \gamma = +1/2 \)，对任意输入距离均有效。代入后得到 \( d(A \cup B, C) = \max(d(A,C), d(B,C)) \)，即例如ELKI中使用的递归形式。<sup>[4](https://dm.cs.tu-dortmund.de/en/mlbits/cluster-hac-intro/)</sup><sup> • </sup><sup>[8](https://elki-project.github.io/releases/release0.7.5/javadoc/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/linkage/CompleteLinkage.html)</sup> 该通用更新方案由G. N. Lance和W. T. Williams于1967年发表。<sup>[10](https://doi.org/10.1093/comjnl/9.4.373)</sup>

朴素实现的代价为 \( \Theta(n^{3}) \)。对每个点的距离表进行排序并在每次合并时以 \( O(n) \) 更新，最坏情况为 \( O(n^{2} \log n) \)。<sup>[5](https://nlp.stanford.edu/IR-book/completelink.html)</sup> 最近邻链算法沿着相互最近的聚类链进行，适用于单连接、完全连接、平均连接、加权连接和Ward方法，达到 \( O(n^{2}) \)，也是SciPy对完全连接所使用的方法。<sup>[7](https://ar5iv.labs.arxiv.org/html/1109.2378)</sup><sup> • </sup><sup>[6](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)</sup> 任何正确的凝聚算法都需要 \( \Omega(n^{2}) \) 时间，因为输出依赖于每一个输入不相似度。<sup>[7](https://ar5iv.labs.arxiv.org/html/1109.2378)</sup>

## 起源

斯蒂芬·C.约翰逊（Stephen C. Johnson）1967年发表于《心理计量学》（Psychometrika）的论文《层次聚类方案》提出了最大方法和最小方法，以及层次聚类的超度量刻画。<sup>[1](https://doi.org/10.1007/bf02289588)</sup> 约翰逊本人指出，这两种方法本质上类似于Sneath（1957）和Sørensen（1948）的早期方法，分别称为单连接聚类和完全连接聚类。<sup>[1](https://doi.org/10.1007/bf02289588)</sup><sup> • </sup><sup>[10](https://doi.org/10.1093/comjnl/9.4.373)</sup><sup> • </sup><sup>[8](https://elki-project.github.io/releases/release0.7.5/javadoc/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/linkage/CompleteLinkage.html)</sup> 层次聚类方案从基于连接的分组中抽象出来，相关的层次连接分析可用于类型的分离。<sup>[1](https://doi.org/10.1007/bf02289588)</sup><sup> • </sup><sup>[11](https://doi.org/10.1177/001316446002000106)</sup> 一篇引用评论指出，在约翰逊的论文之后，完全连接准则成为凝聚聚类普遍公认的默认方法，因为单连接倾向于产生松散而细长的聚类。<sup>[2](https://www.psychometricsociety.org/sites/main/files/file-attachments/johnson_citation_classic_ultrametric.pdf?1582948569=)</sup>

## 变体

主要的算法变体以精确性换取速度。D. Defays的CLINK算法受R. Sibson针对单连接的SLINK算法启发，在 \( O(n^{2}) \) 时间内计算完全连接聚类，但它强烈依赖于顺序，且往往找到比精确二次算法更差的解。<sup>[12](https://doi.org/10.1093/comjnl/20.4.364)</sup><sup> • </sup><sup>[13](https://doi.org/10.1093/comjnl/16.1.30)</sup><sup> • </sup><sup>[8](https://elki-project.github.io/releases/release0.7.5/javadoc/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/linkage/CompleteLinkage.html)</sup> W. H. E. Day和H. Edelsbrunner给出了包括完全连接在内的凝聚方法的高效算法，F. Murtagh的综述涵盖了二次时间方法。<sup>[14](https://doi.org/10.1007/bf01890115)</sup><sup> • </sup><sup>[15](https://doi.org/10.1093/comjnl/26.4.354)</sup> 一旦树状图存在，其叶子的线性顺序可以被优化，使相邻叶子大多相似，这是Ziv Bar-Joseph、David K. Gifford和Tommi S. Jaakkola引入的后处理步骤。<sup>[16](https://doi.org/10.1093/bioinformatics/17.suppl_1.s22)</sup>

## 应用

已记录的用途包括自动恶意软件检测、说话人归属以及核糖体数据库项目（其中完全连接是处理流程的一个组成部分）。<sup>[17](https://www.roeglin.org/publications/ESA15b.pdf)</sup> 在基因表达分析中，基于相关距离的完全连接倾向于创建紧凑的聚类之聚类，而单连接一次添加一个点，形成长条状聚类。<sup>[9](https://online.stat.psu.edu/stat555/node/86/)</sup>

包括完全连接在内的七种常见连接方法在R、MATLAB、Mathematica和SciPy中均有实现。<sup>[7](https://ar5iv.labs.arxiv.org/html/1109.2378)</sup> SciPy将其暴露为 `method='complete'`（也称为最远点算法），接受来自 `pdist` 的压缩距离矩阵或观测数组，返回一个可与 `fcluster` 和 `dendrogram` 配合使用的 \( (n-1) \times 4 \) 连接矩阵。<sup>[6](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)</sup><sup> • </sup><sup>[18](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.complete.html)</sup>

## 局限与替代方案

取代单连接链式效应的失败模式是对离群点的敏感性：完全连接过度关注不符合全局结构的点，一个离群点就能将原本直观的聚类拆分开来。<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup> 一项针对每种配置400个数据集的比较研究发现，除单连接外所有方法大多无法检测离群点。<sup>[19](https://arxiv.org/pdf/2005.07995)</sup> 由于该准则是非局部的，该方法也缺乏使单连接快速的最小生成树捷径，而完全连接不存在这样的捷径。<sup>[7](https://ar5iv.labs.arxiv.org/html/1109.2378)</sup>

与其他连接方法的比较：单连接会产生链式效应但能处理非球形形状；平均连接是完全连接的离群点敏感性与单连接的链式效应之间的折中；完全连接和中位数连接往往表现相似，平均连接和质心连接也是如此。<sup>[3](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)</sup><sup> • </sup><sup>[19](https://arxiv.org/pdf/2005.07995)</sup> 在scikit-learn的二维玩具基准上，平均连接和完全连接在清晰分离的球形聚类上表现良好，但在其他情况下结果参差不齐，而Ward被描述为对噪声数据最有效的方法；同一来源警告这种直觉可能不适用于极高维情形。<sup>[20](https://scikit-learn.org/stable/auto_examples/cluster/plot_linkage_comparison.html)</sup> 该对Ward的评价与那项400数据集的研究相冲突——在后者中Ward表现最差，在82%的数据集中导致检测到虚假聚类——因此完全连接与Ward之间的选择并未由已发表的比较所定论。<sup>[19](https://arxiv.org/pdf/2005.07995)</sup>

理论保证量化了最坏情况。在一般度量空间中，完全连接计算的每个 \( k \)-聚类的半径可能比最优值差 \( O(k) \) 倍，直径差 \( O(k^{1.59}) \) 倍；存在匹配的 \( \Omega(k) \) 下界，这对Sanjoy Dasgupta和Philip M. Long提出的一个问题给出了否定回答，他们2004年的论文曾给出 \( \Omega(\log k) \) 的下界。<sup>[21](https://link.springer.com/article/10.1007/s10994-023-06486-8)</sup><sup> • </sup><sup>[22](https://doi.org/10.1016/j.jcss.2004.10.006)</sup>

## References

1. [Stephen C. Johnson (1967). Hierarchical Clustering Schemes. Psychometrika.](https://doi.org/10.1007/bf02289588)
2. [Citation Classic commentary on Johnson (1967), Psychometric Society](https://www.psychometricsociety.org/sites/main/files/file-attachments/johnson_citation_classic_ultrametric.pdf?1582948569=)
3. [Single-link and complete-link clustering (Manning, Raghavan & Schütze, Introduction to Information Retrieval)](https://nlp.stanford.edu/IR-book/html/htmledition/single-link-and-complete-link-clustering-1.html)
4. [Hierarchical Agglomerative Clustering – Lecture Notes (TU Dortmund, E. Schubert)](https://dm.cs.tu-dortmund.de/en/mlbits/cluster-hac-intro/)
5. [Single-Link, Complete-Link & Average-Link Clustering (Stanford NLP IR book companion page)](https://nlp.stanford.edu/IR-book/completelink.html)
6. [scipy.cluster.hierarchy.linkage, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)
7. [Modern hierarchical, agglomerative clustering algorithms (Müllner, arXiv:1109.2378)](https://ar5iv.labs.arxiv.org/html/1109.2378)
8. [ELKI CompleteLinkage class documentation](https://elki-project.github.io/releases/release0.7.5/javadoc/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/linkage/CompleteLinkage.html)
9. [STAT 555 10.2 Example: Agglomerative Hierarchical Clustering (Penn State)](https://online.stat.psu.edu/stat555/node/86/)
10. [G. N. Lance, W. T. Williams (1967). A General Theory of Classificatory Sorting Strategies: 1. Hierarchical Systems. The Computer Journal.](https://doi.org/10.1093/comjnl/9.4.373)
11. [Louis L. McQuitty (1960). Hierarchical Linkage Analysis for the Isolation of Types. Educational and Psychological Measurement.](https://doi.org/10.1177/001316446002000106)
12. [D. Defays (1977). An efficient algorithm for a complete link method. The Computer Journal.](https://doi.org/10.1093/comjnl/20.4.364)
13. [R. Sibson (1973). SLINK: An optimally efficient algorithm for the single-link cluster method. The Computer Journal.](https://doi.org/10.1093/comjnl/16.1.30)
14. [William H. E. Day, Herbert Edelsbrunner (1984). Efficient algorithms for agglomerative hierarchical clustering methods. Journal of Classification.](https://doi.org/10.1007/bf01890115)
15. [F. Murtagh (1983). A Survey of Recent Advances in Hierarchical Clustering Algorithms. The Computer Journal.](https://doi.org/10.1093/comjnl/26.4.354)
16. [Ziv Bar-Joseph, David K. Gifford, Tommi S. Jaakkola (2001). Fast optimal leaf ordering for hierarchical clustering. Bioinformatics.](https://doi.org/10.1093/bioinformatics/17.suppl_1.s22)
17. [Improved Analysis of Complete-Linkage Clustering (Großwendt & Röglin, ESA 2015)](https://www.roeglin.org/publications/ESA15b.pdf)
18. [scipy.cluster.hierarchy.complete, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.complete.html)
19. [Revisiting Agglomerative Clustering (arXiv 2005.07995)](https://arxiv.org/pdf/2005.07995)
20. [Comparing different hierarchical linkage methods on toy datasets, scikit-learn documentation](https://scikit-learn.org/stable/auto_examples/cluster/plot_linkage_comparison.html)
21. [Upper and lower bounds for complete linkage in general metric spaces (Machine Learning, Springer, 2023)](https://link.springer.com/article/10.1007/s10994-023-06486-8)
22. [Sanjoy Dasgupta, Philip M. Long (2004). Performance guarantees for hierarchical clustering. Journal of Computer and System Sciences.](https://doi.org/10.1016/j.jcss.2004.10.006)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Multivariate association and dimension reduction › Titles A to Me

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/complete-linkage-clustering

English original: https://www.edgepedia.org/complete-linkage-clustering
