Giriş
Şu satırı dahil ederiz.
Şöyle yaparız.
Şu satırı dahil ederiz.
#include <boost/graph/prim_minimum_spanning_tree.hpp>
İmzası şöyleprim_minimum_spanning_tree
(const VertexListGraph& g,
typename graph_traits<VertexListGraph>::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
IndexMap index_map,
DijkstraVisitor vis)
ÖrnekŞöyle yaparız.
typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::undirectedS>
GraphTraits;
typedef GraphTraits::vertex_descriptor Vertex;
struct DijkstraStuff {
Vertex predecessor;
double distance;
boost::default_color_type color; // for use by dijkstra.
};
struct VertexProperty : DijkstraStuff {
std::string name;
VertexProperty(const std::string &aName = "") : name(aName){};
};
struct EdgeProperty {
double weight; // distance to travel along this edge.
EdgeProperty(double aWeight = 0.0) : weight(aWeight){};
};
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
VertexProperty, EdgeProperty> Graph;
struct do_nothing_dijkstra_visitor : boost::default_dijkstra_visitor {};
Graph g = ...;
boost::prim_minimum_spanning_tree(g, start_v, get(&VertexProperty::predecessor, g),
get(&VertexProperty::distance, g), get(&EdgeProperty::weight, g),
boost::identity_property_map(), do_nothing_dijkstra_visitor());
Hiç yorum yok:
Yorum Gönder