mirror of
https://github.com/boostorg/graph.git
synced 2026-01-29 19:42:11 +00:00
Lots of new algorithms and cleanups of old ones
[SVN r27579]
This commit is contained in:
@@ -21,7 +21,7 @@ namespace boost { namespace graph { namespace python {
|
||||
|
||||
template<typename Graph>
|
||||
void
|
||||
breadth_first_search_qvs
|
||||
breadth_first_search
|
||||
(const Graph& g,
|
||||
typename Graph::Vertex s,
|
||||
python_queue<typename Graph::Vertex>& Q,
|
||||
@@ -63,23 +63,74 @@ breadth_first_search_qvs
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void
|
||||
breadth_first_visit
|
||||
(const Graph& g,
|
||||
typename Graph::Vertex s,
|
||||
python_queue<typename Graph::Vertex>& Q,
|
||||
const bfs_visitor<Graph>& visitor,
|
||||
const vector_property_map<default_color_type,
|
||||
typename Graph::VertexIndexMap>& color)
|
||||
{
|
||||
typedef typename python_queue<typename Graph::Vertex>::default_queue
|
||||
default_queue_type;
|
||||
|
||||
bool has_default_buffer = dynamic_cast<default_queue_type*>(&Q);
|
||||
bool has_default_visitor =
|
||||
dynamic_cast<typename bfs_visitor<Graph>::default_arg const*>(&visitor);
|
||||
|
||||
if (has_default_buffer) {
|
||||
if (has_default_visitor) {
|
||||
boost::breadth_first_visit(g, s, color_map(color));
|
||||
} else {
|
||||
boost::breadth_first_visit
|
||||
(g, s,
|
||||
color_map(color).
|
||||
visitor(typename bfs_visitor<Graph>::ref(visitor)));
|
||||
}
|
||||
} else {
|
||||
if (has_default_visitor) {
|
||||
boost::breadth_first_visit(g, s,
|
||||
buffer(Q).
|
||||
color_map(color));
|
||||
} else {
|
||||
boost::breadth_first_visit
|
||||
(g, s, Q, typename bfs_visitor<Graph>::ref(visitor), color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void export_breadth_first_search()
|
||||
{
|
||||
using boost::python::arg;
|
||||
using boost::python::def;
|
||||
|
||||
def("breadth_first_search", &breadth_first_search_qvs<Graph>,
|
||||
def("breadth_first_search", &breadth_first_search<Graph>,
|
||||
(arg("graph"), "root_vertex",
|
||||
arg("buffer") = python_queue<Graph::Vertex>::default_queue(),
|
||||
arg("visitor") = bfs_visitor<Graph>::default_arg(),
|
||||
arg("color_map") =
|
||||
(vector_property_map<default_color_type, Graph::VertexIndexMap>*)0));
|
||||
|
||||
def("breadth_first_search", &breadth_first_search_qvs<Digraph>,
|
||||
def("breadth_first_visit", &breadth_first_visit<Graph>,
|
||||
(arg("graph"), "root_vertex",
|
||||
arg("buffer") = python_queue<Graph::Vertex>::default_queue(),
|
||||
arg("visitor") = bfs_visitor<Graph>::default_arg(),
|
||||
arg("color_map")));
|
||||
|
||||
def("breadth_first_search", &breadth_first_search<Digraph>,
|
||||
(arg("graph"), "root_vertex",
|
||||
arg("buffer") = python_queue<Digraph::Vertex>::default_queue(),
|
||||
arg("visitor") = bfs_visitor<Digraph>::default_arg(),
|
||||
arg("color_map") =
|
||||
(vector_property_map<default_color_type, Digraph::VertexIndexMap>*)0));
|
||||
|
||||
def("breadth_first_visit", &breadth_first_visit<Digraph>,
|
||||
(arg("graph"), "root_vertex",
|
||||
arg("buffer") = python_queue<Digraph::Vertex>::default_queue(),
|
||||
arg("visitor") = bfs_visitor<Digraph>::default_arg(),
|
||||
arg("color_map")));
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
|
||||
Reference in New Issue
Block a user