
Cromwell Enage a écrit :
Why not just request that the corresponding documentation be amended to reflect the fact that both depth_first_search and topological_sort require non-empty graphs? It's a simple matter of adding (0 < num_vertices(g)) as a precondition. I'd rather not pay for extra runtime checks if my graphs are already guaranteed to contain vertices.
Does it have to require a specific test ? When iterating over a container from begin() to end(), I don't have to introduce some special cases to handle an empty container. It might be possible to do the same for topological_sort. Anyway, if you believe such a test could really have any visible impact on performances, maybe two versions of the algorithms would be another option, just like std::vector<T>::at and std::vector<T>::operator[]. -- Loïc