Different out edge iterators was the problem for my filtered graph example.
On Mon, 12 Jul 2010, W.P. McNeill wrote:
OK.I would put a warning about not subclassing BGL components on the Boost Graph Concepts page since this is a point in the documentation that gives an
overview of the way all the graph concepts are implemented. It is also a page that I personally kept referring back to. I guess the warning should mention
that this prohibition is an STL thing, and not specific to BGL.
That's up to you -- I don't mind if you use the C functions for those things.
I'll take a look at Boost.Program_options, Boost.Lexical_cast, and Boost.Random.
"complement"?
Putting filtered_graph over a grid_graph does seem like the right way to go. However, I'm having problems doing this. I can create a filtered version of a
grid graph, however I get build errors when I try to call graph concept functions on it. Here's a simple example:
#include <iostream>
#include <boost/graph/grid_graph.hpp>
#include <boost/graph/filtered_graph.hpp>
#include <set>
using namespace boost;
#define RANK 2
typedef grid_graph<RANK> Graph;
typedef graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef graph_traits<Graph>::edge_descriptor edge_descriptor;
typedef graph_traits<Graph>::out_edge_iterator out_edge_iterator;
// Print vertices as (x, y).
std::ostream& operator<<(std::ostream& output, const vertex_descriptor& u) {
return output << "(" << u[0] << ", " << u[1] << ")";
}
// Print edges as (x1, y1) -> (x2, y2).
std::ostream& operator<<(std::ostream& output, const edge_descriptor& e) {
return output << e.first << "->" << e.second;
}
typedef std::set<vertex_descriptor> VertexSet;
typedef vertex_subset_compliment_filter<Graph, VertexSet>::type
VertexFilteredGraph;
int main(int argc, char* argv[]) {
array<std::size_t, RANK> lengths = { {3, 3} };
Graph g(lengths);
VertexSet omit;
omit.insert(vertex(1, g)); // Filter vertex (1, 0) out of the graph.
VertexFilteredGraph fg = make_vertex_subset_compliment_filter(g, omit);
fg will have a different out_edge_iterator type than g does, since fg's iterator will need to do the filtering. I think that is the cause of the errors you are getting.
// Print the out edges coming from (0, 0) in the unfiltered and filtered
// graphs.
vertex_descriptor u = vertex(0, g);
std::cout << "Unfiltered out edges from " << u << std::endl;
out_edge_iterator oi, oi_end;
for (tie(oi, oi_end) = out_edges(u, g); oi != oi_end; oi++)
std::cout << *oi << std::endl;
std::cout << "Filtered out edges from " << u << std::endl;
for (tie(oi, oi_end) = out_edges(u, fg); oi != oi_end; oi++)
std::cout << *oi << std::endl;
return 0;
}
-- Jeremiah Willcock
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users