graph-v2
graph-v2 copied to clipboard
Change the cancellation interface
Currently, the users of breadth_first_search view need to type the following in order to break from the view iteration:
for (auto v : bfs)
{
if (cond)
bfs.cancel(graph::cancel_search::cancel_branch);
}
This seems unnecessarily long, and rather than exposing a two-state enum in the interface, the view could offer two functions instead:
for (auto v : bfs)
{
if (cond1)
bfs.break_branch();
if (cond2)
bfs.break_all();
}
And in fact you may not need the second one (break_all) because (a) it is never used, and (b) a more familiar alternative exists:
for (auto v : bfs)
{
if (cond2)
break;
}