浅节点和深节点

发布于 2024-12-22 06:46:03 字数 69 浏览 1 评论 0原文

我发现在一些教程中,广度优先搜索

浅节点在更深节点之前扩展。

我真的很困惑它们每个的含义是什么?

I found that in some tutorial the breadth first search

the shallow nodes are expanded before deeper nodes.

I am really confused what is the meaning of each of them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏了南城 2024-12-29 06:46:03

术语“浅”和“深”来自于可视化图形,起始节点位于顶部:节点的“深度”是您需要遍历的边数,以便从起始节点到达该节点。关于 BFS 的说法告诉您,在与起始节点之间有较少边的节点先于与起始节点相隔较多边的节点被发现。

Terms "shallow" and "deep" come from visualizing your graph with the starting node at the top: the "depth" of a node is the number of edges that you need to traverse in order to get to that node from the starting node. The statement about BFS tells you that nodes with fewer edges between them and the starting node are discovered before nodes separated from the start by more edges.

花心好男孩 2024-12-29 06:46:03

这意味着,如果您计算从起始节点到图中每个单独节点 v 的最短路径的长度 L(v),其中 BFS 节点具有较低的 L(v) 始终在具有较高 L(v) 的节点之前处理。

更简单的解释:BFS 总是启动并处理与起始节点直接相邻的所有节点。然后处理起始节点的直接邻居的所有直接邻居(不包括已经处理的节点),依此类推。

最后要处理的节点是距起始节点距离最长的节点。

This means that if you compute the length L(v) of the shortest path from starting node to each individual node v in your graph, with BFS nodes with lower L(v) are always processed before nodes with higher L(v).

Simpler explanation: BFS always starts and processes all nodes that are direct neighbours of starting node. Then it processes all direct neighbours of direct neighbours of starting nodes (excluding the ones already processed) and so on.

The last nodes to be processed are the ones with the longest distance from starting node.

海风掠过北极光 2024-12-29 06:46:03

简单来说就是根节点被扩展,然后我们得到它们的子节点,然后我们将子节点放在BFS中开放队列的后端。

Simply means root node is expanded and then we get their child nodes and then we put the child node in rear end of open queue in BFS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文