// Copyright 2005 The Trustees of Indiana University. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Authors: Douglas Gregor // Andrew Lumsdaine #include #include "graph.hpp" #include "digraph.hpp" #include #include "dijkstra_visitor.hpp" namespace boost { namespace graph { namespace python { template void prim_minimum_spanning_tree (Graph& g, typename Graph::Vertex s, const vector_property_map* in_predecessor, const vector_property_map* in_distance, const vector_property_map* in_weight, const dijkstra_visitor& visitor) { typedef vector_property_map PredecessorMap; typedef vector_property_map DistanceMap; typedef vector_property_map WeightMap; PredecessorMap predecessor = in_predecessor? *in_predecessor : PredecessorMap(g.num_vertices(), g.get_vertex_index_map()); DistanceMap distance = in_distance? *in_distance : DistanceMap(g.num_vertices(), g.get_vertex_index_map()); WeightMap weight = in_weight? *in_weight : g.template get_edge_map("weight"); typedef typename dijkstra_visitor::default_arg default_visitor; bool has_default_visitor = dynamic_cast(&visitor); if (!has_default_visitor) { boost::prim_minimum_spanning_tree (g, predecessor, root_vertex(s). vertex_index_map(g.get_vertex_index_map()). visitor(typename dijkstra_visitor::ref(visitor)). distance_map(distance). weight_map(weight)); } else { boost::prim_minimum_spanning_tree (g, predecessor, root_vertex(s). vertex_index_map(g.get_vertex_index_map()). distance_map(distance). weight_map(weight)); } } template void export_prim_minimum_spanning_tree_in_graph() { dijkstra_visitor::declare("DijkstraVisitor", "DefaultDijkstraVisitor"); } void export_prim_minimum_spanning_tree() { using boost::python::arg; using boost::python::def; def("prim_minimum_spanning_tree", &prim_minimum_spanning_tree, (arg("graph"), arg("root_vertex"), arg("predecessor_map") = (vector_property_map*)0, arg("distance_map") = (vector_property_map*)0, arg("weight_map") = (vector_property_map*)0, arg("visitor") = dijkstra_visitor::default_arg())); def("prim_minimum_spanning_tree", &prim_minimum_spanning_tree, (arg("graph"), arg("root_vertex"), arg("predecessor_map") = (vector_property_map*)0, arg("distance_map") = (vector_property_map*)0, arg("weight_map") = (vector_property_map*)0, arg("visitor") = dijkstra_visitor::default_arg())); } template void export_prim_minimum_spanning_tree_in_graph(); template void export_prim_minimum_spanning_tree_in_graph(); } } } // end namespace boost::graph::python