![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
Boost Graph Library: Undirected Depth-First SearchBoost , ,
|
DFS(G) for each vertex u in V vcolor[u] := WHITE p[u] := u end for for each edge e in E ecolor[u] := WHITE end for time := 0 if there is a starting vertex s call DFS-VISIT(G, s) for each vertex u in V if vcolor[u] = WHITE call DFS-VISIT(G, u) end for return (p,d_time,f_time) |
- - initialize vertex u - - - - - - - start vertex s - - start vertex u - - - - discover vertex u - examine edge (u,v) - - (u,v) is a tree edge - - (u,v) is a back edge - - finish edge (u,v) - finish vertex u - |
boost/graph/undirected_dfs.hpp
An undirected graph. The graph type must be a model of Incidence Graph, Vertex List Graph, and Edge List Graph.
Python: The parameter is named graph.
A visitor object that is invoked inside the algorithm at the event-points specified by the DFS Visitor concept. The visitor object is passed by value [1].UTIL/OUT: vertex_color_map(VertexColorMap vertex_color)
Default: dfs_visitor<null_visitor>
Python: The parameter should be an object that derives from the DFSVisitor type of the graph.
This is used by the algorithm to keep track of its progress through the graph. The type VertexColorMap must be a model of Read/Write Property Map and its key type must be the graph's vertex descriptor type and the value type of the color map must model ColorValue.UTIL: edge_color_map(EdgeColorMap edge_color)
Default: an iterator_property_map created from a std::vector of default_color_type of size num_vertices(g) and using the i_map for the index map.
Python: The color map must be a vertex_color_map for the graph.
This is used by the algorithm to keep track of which edges have been visited. The type EdgeColorMap must be a model of Read/Write Property Map and its key type must be the graph's edge descriptor type and the value type of the color map must model ColorValue.IN: root_vertex(typename graph_traits<VertexListGraph>::vertex_descriptor start)
Default: none.
Python: The color map must be an edge_color_map for the graph.
This specifies the vertex that the depth-first search should originate from. The type is the type of a vertex descriptor for the given graph.IN: vertex_index_map(VertexIndexMap i_map)
Default: *vertices(g).first
This maps each vertex to an integer in the range [0, num_vertices(g)). This parameter is only necessary when the default color property map is used. The type VertexIndexMap must be a model of Readable Property Map. The value type of the map must be an integer type. The vertex descriptor type of the graph needs to be usable as the key type of the map.
Default: get(vertex_index, g) Note: if you use this default, make sure your graph has an internal vertex_index property. For example, adjacency_list with VertexList=listS does not have an internal vertex_index property.
Python: Unsupported parameter.
The time complexity is O(E + V).
An example is in examples/undirected_dfs.cpp.
[1]
Since the visitor parameter is passed by value, if your visitor
contains state then any changes to the state during the algorithm
will be made to a copy of the visitor object, not the visitor object
passed in. Therefore you may want the visitor to hold this state by
pointer or reference.
Copyright © 2000-2001 | Джереми Сик, Университет Индианыjsiek@osl.iu.edu] Ли-Куан Ли, Университет Индианыllee@cs.indiana.edu] Эндрю Лумсдейн, Университет Индианыlums@osl.iu.edu |
Статья Boost Graph Library: Undirected Depth-First Search раздела может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: ::
реклама |