Giriş
Şu satırı dahil ederiz.
Örnek
Elimizde bir graph olsun.
Şöyle yaparız.
Şu satırı dahil ederiz.
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/filtered_graph.hpp>
Constructor - predicate + predicateÖrnek
Elimizde bir graph olsun.
/// vertex properties
struct VertexData {
std::string label;
int num;
};
/// edges properties
struct EdgeData {
std::string edge_name;
double edge_confidence;
};
/// define the boost-graph
typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS,
VertexData,
boost::property<boost::edge_weight_t, double, EdgeData> > Graph;
Elimizde bir graph nesnesi olsun.Graph g;
Şöyle yaparız.struct Predicate { // both edge and vertex
bool operator()(Graph::edge_descriptor) const { return ...; }
bool operator()(Graph::vertex_descriptor vd) const { return ...; }
} predicate;
using Filtered = boost::filtered_graph<Graph, Predicate, Predicate>;
Filtered fg(g, predicate, predicate);
Örnek
Şöyle yaparız.
struct NotZero { bool operator()(V vd) const { return 0 != vd; } };
using F = boost::filtered_graph<G, boost::keep_all, NotZero>;
boost::dynamic_properties dp;
dp.property("node_id", id);
dp.property("shape", boost::make_constant_property<V>(std::string("Mrecord")));
dp.property("label", label);
write_graphviz_dp(std::cout, F(g, {}, {}), dp);
Hiç yorum yok:
Yorum Gönder