BFS 是 breadth-first search(广度优先搜索)的缩写:一种图/树遍历算法,按“离起点的层级(距离)从近到远”逐层访问节点,常用于求无权图的最短路径、分层遍历等。(也可能在不同语境中有其他含义,但最常见的是算法里的 BFS。)
/ˌbiː ɛf ˈɛs/
We used BFS to find the shortest path in the maze.
我们用广度优先搜索在迷宫中找到了最短路径。
In an unweighted graph, BFS explores nodes level by level and guarantees the shortest distance from the start node.
在无权图中,BFS 会按层逐步探索节点,并保证从起点到各节点的最短距离。
BFS 来自英文短语 Breadth-First Search 的首字母缩写:breadth 表示“广度/横向”,强调先把同一“层”的节点扩展完;first 表示“优先”;search 表示“搜索/遍历”。该术语在计算机科学的图算法与数据结构教学中非常常见。