graph-v2 icon indicating copy to clipboard operation
graph-v2 copied to clipboard

Change the cancellation interface

Open akrzemi1 opened this issue 6 months ago • 0 comments

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;
}

akrzemi1 avatar Jun 18 '25 21:06 akrzemi1