# 张-罗伯茨算法

张-罗伯茨算法是一种针对单向环形进程网络的领导者选举算法。在该算法中，每个进程只转发比自身标识符更大的标识符，直到最大的标识符回到其持有者手中，该持有者便宣布自己为领导者。多伦多大学的张欧内斯特（Ernest Chang）与滑铁卢大学的罗伯茨·罗斯玛丽（Rosemary Roberts）于1979年5月在《ACM通讯》上发表了该算法，作为对勒朗（Le Lann）1977年算法的一项改进。<sup>[1](https://cir.nii.ac.jp/crid/1362544418944852992)</sup><sup> • </sup><sup>[2](https://www.digiface.org/wp-content/uploads/2022/11/distributed-systems.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 设定 | 进程排列成一个单向（逻辑）环，每个进程拥有一个唯一的、全序的标识符；异步系统，假定无故障<sup>[3](https://ftp.utcluj.ro/pub/users/civan/CPD/3.RESURSE/6.Book_2012_Distributed%20systems%20_Couloris.pdf)</sup> |
| 规则 | 进程仅当收到的标识符大于自身标识符时才予以转发；否则将消息吞没<sup>[2](https://www.digiface.org/wp-content/uploads/2022/11/distributed-systems.pdf)</sup> |
| 胜出者 | 拥有最大标识符的进程，当其自身标识符绕环一周返回时，它便认出自己<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> |
| 最坏情况 | O(n²)条消息，当标识符按降序排列时<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> |
| 最好情况 | O(n)条消息，当标识符按升序排列时；有文献给出3n−1条消息<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup><sup> • </sup><sup>[5](https://subroute-flame.vercel.app/topics/leader-election/ring)</sup> |
| 平均情况 | 在标识符随机排列下为O(n log n)条消息<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> |
| 所需知识 | 任何进程都无需知道环中进程的总数<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> |
| 发表信息 | 《ACM通讯》22(5)，281–283页，1979年5月，DOI 10.1145/359104.359108<sup>[1](https://cir.nii.ac.jp/crid/1362544418944852992)</sup> |

## 工作原理

每个进程拥有一个来自全序集合的唯一标识符，消息沿环单向传递。一个或多个进程可以自发地启动选举，将携带自身标识符的选举消息发送给邻居。进程收到标识符j时，将其与自身标识符比较：若j更大，则转发该消息；若j等于自身标识符，则宣布自己为领导者并传播一条领导者消息；若j更小且该进程尚未参与选举，则用自己的标识符替换之并发送出去，同时将自己标记为参与者。已经参与选举的进程若收到更小的标识符，则直接将消息吞没。<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup><sup> • </sup><sup>[3](https://ftp.utcluj.ro/pub/users/civan/CPD/3.RESURSE/6.Book_2012_Distributed%20systems%20_Couloris.pdf)</sup>

这一过滤规则意味着只有最大的标识符能够存活并绕环一整圈。每一个较小的标识符最终都会被某个拥有更大标识符的进程吞没，因此持有最大标识符的进程是唯一看到自己标识符返回的进程，也只有它宣布领导权。当领导者的公告传遍整个环并返回时，所有进程便都知道了结果。<sup>[2](https://www.digiface.org/wp-content/uploads/2022/11/distributed-systems.pdf)</sup><sup> • </sup><sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup>

并发启动由同一规则处理：若两个进程同时开始选举，随着消息的传播，较大的标识符会吞没较小的标识符，最终只产生一个领导者。<sup>[5](https://subroute-flame.vercel.app/topics/leader-election/ring)</sup>

## 消息复杂度

代价取决于标识符在环上的排列顺序。在最坏情况下，标识符1到N沿消息传递方向按降序排列，进程j发出的消息在被标识符更大的进程吞没之前要经过j跳，因此选举消息总数为N(N+1)/2，即O(N²)，外加N条领导者消息。<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> 在最好情况下，标识符按升序排列，仅需O(N)条选举消息。<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> 平均而言，在随机排列下，该算法需要O(N log N)条消息。<sup>[4](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)</sup> 2006年发表于《理论计算机科学》的一项概率分析表明，总消息代价与随机递归树中的总路径长度以及递增二叉树中的总左路径长度密切相关。<sup>[6](https://www.sciencedirect.com/science/article/pii/S0304397506005561)</sup>

## 起源与LCR家族

勒朗于1977年提出了已知最早的针对单向环的领导者选举算法：每个标识符都要绕环一整圈，持有最大标识符的进程在其标识符返回时宣布自己为领导者。该算法需要n步和n²条消息。张与罗伯茨于1979年通过选择性消息消亡对其加以改进：进程仅当收到的标识符较大时才予以转发，原论文称这将平均消息传递次数从n²量级降至n log n量级。<sup>[7](https://www.emis.de/journals/AUSM/C5-1/math51-5.pdf)</sup><sup> • </sup><sup>[1](https://cir.nii.ac.jp/crid/1362544418944852992)</sup>

由此得到的算法通常称为张-罗伯茨算法；当三位作者的贡献被共同承认时，也称勒朗-张-罗伯茨（LCR）算法。<sup>[2](https://www.digiface.org/wp-content/uploads/2022/11/distributed-systems.pdf)</sup><sup> • </sup><sup>[7](https://www.emis.de/journals/AUSM/C5-1/math51-5.pdf)</sup> 伯恩斯（Burns）与富兰克林（Franklin）后来提出了对它的改进。<sup>[8](https://www.researchgate.net/publication/359685387_Eventual_Leader_Elections_in_Dynamic_Networks)</sup>

## 后续算法与比较

赫希伯格-辛克莱（Hirschberg–Sinclair）算法在双向环上通过让每个进程每轮探查一个规模翻倍的邻域，即使最坏情况下也能将消息复杂度降至O(n log n)；其运行时间比LCR差一个常数因子，但仍为O(n)。<sup>[2](https://www.digiface.org/wp-content/uploads/2022/11/distributed-systems.pdf)</sup> 后续工作将环形领导者选举的消息复杂度降至O(n log n)，这一界对异步环是紧的，而在同步环中O(n)条消息即已足够。<sup>[9](https://link.springer.com/article/10.1007/s00446-025-00491-x)</sup>

该算法假设系统无故障；它所解决的根本选举问题——在分布式系统中选出一个协调者——与霸道算法以及任意网络中的选举一起，仍然是分布式协调教科书中的标准课题。<sup>[3](https://ftp.utcluj.ro/pub/users/civan/CPD/3.RESURSE/6.Book_2012_Distributed%20systems%20_Couloris.pdf)</sup><sup> • </sup><sup>[10](https://www.oreilly.com/library/view/distributed-systems-2nd/9781466552975/K15248_S005.xhtml)</sup>

## 验证与应用

由于该算法简短且行为微妙，它已成为形式化方法的基准：研究者们对单向环上的该算法及勒朗变体进行了规约与验证，研究了它们对不可靠通信和机器故障的鲁棒性，并在PVS证明助手中对张-罗伯茨算法的证明进行了机器检验。<sup>[11](https://www.sciencedirect.com/science/article/pii/S0167642396000342)</sup><sup> • </sup><sup>[12](https://www.researchgate.net/publication/221027186_Assertion-Based_Proof_Checking_of_Chang-Roberts_Leader_Election_in_PVS)</sup> 这类环形选举曾是20世纪80年代令牌环网络的实际选择，至今仍出现在物理或逻辑拓扑本身即为环形的场合，包括IBM令牌环、FDDI、某些对等覆盖网络，以及作为更大容错协议内部的组件。<sup>[5](https://subroute-flame.vercel.app/topics/leader-election/ring)</sup>

## References

1. [E. Chang, R. Roberts (1979). An improved algorithm for decentralized extrema-finding in circular configurations of processes. Communications of the ACM 22(5), 281–283.](https://cir.nii.ac.jp/crid/1362544418944852992)
2. [Notes on Theory of Distributed Systems (Le Lann–Chang–Roberts algorithm), J. Aspnes.](https://www.digiface.org/wp-content/uploads/2022/11/distributed-systems.pdf)
3. [G. Coulouris et al., Distributed Systems: Concepts and Design, ring-based election algorithm.](https://ftp.utcluj.ro/pub/users/civan/CPD/3.RESURSE/6.Book_2012_Distributed%20systems%20_Couloris.pdf)
4. [V. K. Garg, Distributed Systems, Chapter 13: Leader Election.](https://users.ece.utexas.edu/~garg/dist/jbkv2/chapter13-election.pdf)
5. [Ring (Chang–Roberts) Leader Election, Subroute.](https://subroute-flame.vercel.app/topics/leader-election/ring)
6. [W.-M. Chen (2006). Cost distribution of the Chang–Roberts leader election algorithm and related problems. Theoretical Computer Science 369, 442–447.](https://www.sciencedirect.com/science/article/pii/S0304397506005561)
7. [Leader election algorithms in unidirectional rings, Acta Universitatis Sapientiae, Mathematica 5(1), 2013.](https://www.emis.de/journals/AUSM/C5-1/math51-5.pdf)
8. [Eventual Leader Elections in Dynamic Networks (noting Burns and Franklin improvements).](https://www.researchgate.net/publication/359685387_Eventual_Leader_Elections_in_Dynamic_Networks)
9. [Content-oblivious leader election on rings, Distributed Computing (2025).](https://link.springer.com/article/10.1007/s00446-025-00491-x)
10. [Distributed Systems, 2nd Edition, Chapter 11: Coordination Algorithms.](https://www.oreilly.com/library/view/distributed-systems-2nd/9781466552975/K15248_S005.xhtml)
11. [Specification and verification of various distributed leader election algorithms for unidirectional ring networks, Science of Computer Programming.](https://www.sciencedirect.com/science/article/pii/S0167642396000342)
12. [Assertion-Based Proof Checking of Chang-Roberts Leader Election in PVS.](https://www.researchgate.net/publication/221027186_Assertion-Based_Proof_Checking_of_Chang-Roberts_Leader_Election_in_PVS)

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

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Graph theory › Computational graph problems and algorithms › Parallel and distributed graph algorithms

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/chang-and-roberts-algorithm

English original: https://www.edgepedia.org/chang-and-roberts-algorithm
