gpt4 book ai didi

boost-graph - 使用自定义访问者时,如何使用Boost Graph Library停止广度优先搜索?

转载 作者:行者123 更新时间:2023-12-03 17:08:46 25 4
gpt4 key购买 nike

假设我找到了符合条件的节点,则需要停止搜索。

最佳答案

解决方案是抛出您已知类型的异常-然后在调用方捕获它。从FAQ:

How do I perform an early exit from an algorithm such as BFS?

Create a visitor that throws an exception when you want to cut off the search, then put your call to breadth_first_search inside of an appropriate try/catch block. This strikes many programmers as a misuse of exceptions, however, much thought was put into the decision to have exceptions has the preferred way to exit early. See boost email discussions for more details.

关于boost-graph - 使用自定义访问者时,如何使用Boost Graph Library停止广度优先搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1500709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com