stdgraph / P1709

P1709: C++ Graph Library Proposal
7 stars 0 forks source link

Small bugs in 3.3.1.2 (Breadth-First Search, Single Source) #68

Open akrzemi1 opened 10 months ago

akrzemi1 commented 10 months ago

In P1709r5, in 3.3.1.2 (Breadth-First Search, Single Source):

One. The declaration of the function uses name seed for the start-point vertex, whereas the English description uses name source.

Two: preconditions say:

distances/predecessors will be initialized with init_breadth_first_search.

The usage of the future tense makes it sound as if these were guarantees/postconditions. I recommend rephrasing it to:

the value of distances is the resut of the call to init_breadth_first_search(distances).

Three: It lists 0 <= source < num_vertices(graph) as a precondition and at the same time guarantees that it throws an excepiton upon this condiiton. This is an error: you either need to say that it is a precondition, and you guarantee nothing (because the implementation should be allowed to put an assert there to stop the program, or produce a core dump, or launch a debugger), or you say that bad source is allowed, and then you guarantee that you throw an error and not try to do things like detecting bugs.

Granted that the Standard has places where we say something is a precondition and then we throw, but these are bugs that we now try to avoid.

Four: function breadth_first_search is absent from graph-v2. graph-v2 only has BFS views.