Reputation: 1100
Using the standard on a directed graph,
std::vector<size_type> dtime(N);
std::vector<size_type> ftime(N);
size_type t = 0;
dfs_time_visitor<size_type*> vis(&dtime[0], &ftime[0], t);
depth_first_search(graph, visitor(vis));
appears to always start the dfs from node 0.
How does one tell the algorithm to start from a known "root node"?
Upvotes: 3
Views: 2505
Reputation:
Here you can find a list of all the overloads for depth_first_search
. The one you need is the "named parameter version". The parameter you need to use is "root_vertex" and your invocation of depth_first_search
would simply be:
depth_first_search(graph, visitor(vis).root_vertex(root_vertex_descriptor));
Upvotes: 9