|
Boost Users : |
Subject: [Boost-users] [BGL] how to use write_graphviz_dp with graph bundle properties
From: Pablo Madoery (madoerypablo_at_[hidden])
Date: 2013-11-09 11:59:29
Hello. I know how to use write_graphviz_dp with vertices and edges bundle
properties but i can't figure out how to print the graph_bundle property of
a graph.
i have the following code where the line with the error is commented:
#include <boost/graph/properties.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace boost;
using namespace std;
struct VertexInfo
{
int id;
};
struct EdgeInfo
{
int weight;
};
struct GraphInfo
{
int duration;
};
typedef adjacency_list<vecS, vecS, undirectedS, VertexInfo, EdgeInfo,
GraphInfo> Graph;
void printGraph(Graph graph, string file)
{
ofstream ofs(file.c_str());
dynamic_properties dp;
dp.property("node_id", get(vertex_index, graph));
dp.property("label", get(&EdgeInfo::weight, graph));
///dp.property("label", get(&graph[graph_bundle].duration)); ->error
write_graphviz_dp(ofs, graph, dp);
}
int main()
{
Graph graph;
Graph::vertex_descriptor a = add_vertex(graph);
Graph::vertex_descriptor b = add_vertex(graph);
Graph::vertex_descriptor c = add_vertex(graph);
Graph::vertex_descriptor d = add_vertex(graph);
Graph::edge_descriptor e1 = (add_edge(a, b, graph)).first;
Graph::edge_descriptor e2 = (add_edge(b, c, graph)).first;
Graph::edge_descriptor e3 = (add_edge(c, d, graph)).first;
Graph::edge_descriptor e4 = (add_edge(d, a, graph)).first;
graph[e1].weight = 1.1;
graph[e2].weight = 1.5;
graph[e3].weight = 5.2;
graph[e4].weight = 1.2;
graph[graph_bundle].duration = 10;
printGraph(graph, "graph.dot");
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net