
Hi, I'm having a problem with the graph library. The problematic function looks like this below. Edge is a simple struct with vertex_a, vertex_b and cost as its members. The trick is that I need to process this big graph a few times, each time throwing out some edges and keeping others, hence the reindexing and mapping of these. I've used the graph lib previously, and worked, I'm just unable to find what am I doing wrong this time. Any help would be welcome. Thanks in advance. typedef std::pair<int, int> edge; typedef boost::adjacency_list < boost::listS, boost::vecS, boost::directedS, boost::no_property, boost::property < boost::edge_weight_t, int > > graph_t; typedef boost::graph_traits < graph_t >::vertex_descriptor vertex_descriptor; typedef boost::graph_traits < graph_t >::edge_descriptor edge_descriptor; graph_t* KGMReader::buildGraph (vector<edge>& edgs, vector<int>& weights, vector<int>& vertexmapping, int rootter) { edgs.clear (); weights.clear (); vertexmapping.clear (); for (vector<Edge>::iterator it = edges.begin (); it != edges.end (); ++it) { if (keepEdge (*it, rootter)) { vector<int>::iterator v1 = find (vertexmapping.begin (), vertexmapping.end (), it->vertex_a); vector<int>::iterator v2 = find (vertexmapping.begin (), vertexmapping.end (), it->vertex_b); if (v1 == vertexmapping.end ()) { vertexmapping.push_back (it->vertex_a); v1 = find (vertexmapping.begin (), vertexmapping.end (), it->vertex_a); } if (v2 == vertexmapping.end ()) { vertexmapping.push_back (it->vertex_b); v2 = find (vertexmapping.begin (), vertexmapping.end (), it->vertex_b); } edgs.push_back (edge (v1 - vertexmapping.begin (), v2 - vertexmapping.begin ())); weights.push_back (it->cost); edgs.push_back (edge (v2 - vertexmapping.begin (), v1 - vertexmapping.begin ())); weights.push_back (it->cost); } } qDebug () << "Vertexes: " << vertexmapping.size () << " edges " << edgs.size () << ", weights " << weights.size (); graph_t *g = 0; try { g = new graph_t (edgs.begin (), edgs.end (), weights.begin (), vertexmapping.size ()); } catch (exception& e) { qDebug () << "caught!!! " << e.what (); g = 0; } return g; } -- Tamas Marki