Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] Problem trying to delete vertices from a graph using named vertices, please help!
From: Camillo Anania (anacron10_at_[hidden])
Date: 2010-04-01 15:51:00


Jeremiah wrote:

2010/3/30 Jeremiah Willcock <jewillco_at_[hidden]>
>
> On Mon, 29 Mar 2010, Camillo Anania wrote:
>
>> Hi guys,I have a graph so defined:
>>
>> typedef boost::adjacency_list<boost::listS, boost::listS, boost::bidirectionalS, Osm::VertexProperties, EdgeProperties> Graph;
>>
 Osm::Graph osmGraph;
>>
>>
>> I'm trying to delete some vertices from osmGraph using the usual remove_vertex(Vertex, Graph) but I get the following error from Visual
>> Studio 2008 when compiling:
>
> What is Vertex defined as here?
>

Here I call remove_vertex(v ,osmGraph) where v is defined like:
typedef boost::graph_traits<Osm::Graph>::vertex_descriptor Vertex;

>> boost_1_40_0\boost/graph/named_graph.hpp(349) : error C2664: 'boost::multi_index::detail::hashed_index_iterator<Node,BucketArray>boost::multi_index::detail::hashed_index<KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>::erase(boost::multi_index::detail::hashed_in
>> dex_iterator<Node,BucketArray>)' : cannot convert parameter 1 from 'void *' to
>> 'boost::multi_index::detail::hashed_index_iterator<Node,BucketArray>'
>>
>> the code I use is:
>> {
>> vector<int> component(num_vertices(osmGraph));
>> int num = strong_components(osmGraph,
>>             make_iterator_property_map(&component[0], get(&Osm::VertexProperties::id, osmGraph)),
>>             vertex_index_map(get(&Osm::VertexProperties::id, osmGraph)));
>> int main_comp = component[depotID];
>> for (int i = 0; i != component.size(); i++){
>> if (component[i] == main_comp)
>> continue;
>>
>> if (is_incident_to_required_edge(osmGraph, i)){
>> cerr << "Required components on input topology are not strongly connected. Check the input .osm file" << endl;
>> return 1;
>> }
>> else {
>> clear_vertex(osm_get_vertex(i, osmGraph), osmGraph);
>> Osm::Vertex osm_v = osm_get_vertex(i, osmGraph);
>> cout << "id=" << osmGraph[osm_v].id << endl;
>> remove_vertex(osm_v, osmGraph);
>> }
>> }
>> }
>
> What is Osm::Vertex, and what does osm_get_vertex do?

Osm::Vertex is like above and is:
namespace Osm { typedef
boost::graph_traits<Osm::Graph>::vertex_descriptor Vertex;}

osm_get_vertex is defined like this:

Osm::Vertex osm_get_vertex(int id_vertice, Osm::Graph& g){
        typedef boost::graph_traits<Osm::Graph>::vertex_iterator vertex_iter;
        std::pair<vertex_iter, vertex_iter> vp;
        for (vp = vertices(g); vp.first != vp.second; ++vp.first) {
        int uid = g[*vp.first].id;
                if ( uid == id_vertice) return *vp.first;
        }
        return NULL;
}

I do this because the vertex(v, g) doesnt work when the graph index
vertices are not numbered from 0 with continuity. Do you know why that
happens? Also the other algorithms Boost gives doesnt work if vertices
indexes are not numbered with continuity from 0. Graphs I'm working
with graphs having OutEdgeList = VertexList = ListS.

>
>> why it doesnt work? why the same code with the graph defined in the following way works?
>>
>> typedef adjacency_list < listS, listS, bidirectionalS, property < vertex_name_t, std::string,
>> //vertex property
>> property < vertex_unique_id_t, int, property < vertex_color_t, boost::default_color_type> ............. >,
>> //edge property
>> property < edge_index_t, int, property < edge_num_bins_t, int, property < edge_unique_id_t, int, property < edge_name_t,
>> std::string> ..............>
>> > Graph;
>
> Are you perhaps using a different vertex type in this case?

Here the vertex are defined like:
typedef graph_traits<Graph>::vertex_descriptor Vertex;

where Graph is:
typedef adjacency_list < listS, listS, bidirectionalS, property <
vertex_name_t, std::string,
//vertex property
property < vertex_unique_id_t, int, property < vertex_color_t,
boost::default_color_type> ............. >,
//edge property
property < edge_index_t, int, property < edge_num_bins_t, int,
property < edge_unique_id_t, int, property < edge_name_t,
std::string> ..............>
> Graph;

Thanks.

Camillo

> -- Jeremiah Willcock
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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