Boost logo

Boost Users :

Subject: Re: [Boost-users] Problems with property_maps
From: Trevin Murakami (temurakami_at_[hidden])
Date: 2010-02-28 14:05:17


Thanks. That fixed it.

-Trevin "<3" Murakami

On Sun, Feb 28, 2010 at 9:14 AM, Jeremiah Willcock <jewillco_at_[hidden]> wrote:
> On Sat, 27 Feb 2010, Trevin Murakami wrote:
>
>> Hello all.
>>
>> I'm having issues getting property maps to work properly with my
>> custom adjacency_list.  Here's a snippet of the code:
>>
>> // Definitions
>> // define some of the properties the graphs will have
>> //
>> http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/using_adjacency_list.html
>> struct posx_t { typedef vertex_property_tag kind; };
>> struct posy_t { typedef vertex_property_tag kind; };
>>
>> typedef property<posx_t, int> VertexPosX;
>> // chain to add in posy
>> typedef property<posy_t, int, VertexPosX> VertexPos;
>> // chain to add in vertex_index
>> typedef property<vertex_index_t, int, VertexPos> VertexProperty;
>>
>> // define our special graph
>> typedef adjacency_list<listS, listS, undirectedS,
>> VertexProperty,
>> property<edge_weight_t, int> > AGraph;
>>
>> ...
>>
>> template<class T>
>> void boostToVAGraph(const AGraph & g,
>>                                        const int num_nodes, const int
>> num_edges,
>>                                        T ** idata,
>>                                        T ** odata,
>>                                        unsigned int ** segment_descriptor,
>>                                        unsigned int ** cross_pointers,
>>                                        unsigned int ** head_flags,
>>                                        T ** reference,
>>                                        const testrigOptions & testOptions)
>> {
>>        typedef AGraph Graph;
>>
>>
>>        // define the manipulator for our special properties
>>        //
>> http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/using_adjacency_list.html
>>        // requires property_map.hpp
>>        // BROKEN!!!!!
>>        property_map<AGraph, posx_t>::type
>>                getposx = get(posx_t(), g);
>>        property_map<AGraph, posy_t>::type
>>                getposy = get(posy_t(), g);
>>
>> ...
>>
>> I used another function to generate the AGraph and apply values.  And
>> using property map there seems to work.  However, I then pass it to
>> this function using:
>>
>> boostToVAGraph(g, num_nodes, num_edges, idata, odata, segment_descriptor,
>>                cross_pointers, head_flags, reference,
>>                testOptions);
>>
>> On compile, I get this error:
>> 1>agraph.cpp
>> 1>c:/Documents and Settings/All Users/Application Data/NVIDIA
>> Corporation/NVIDIA GPU Computing SDK/C/src/test/agraph.cpp(94) : error
>> C2440: 'initializing' : cannot convert from
>> 'boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>'
>> to 'boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>'
>> 1>        with
>> 1>        [
>> 1>            Graph=AGraph,
>> 1>            ValueType=int,
>> 1>            Reference=const int &,
>> 1>            Tag=posx_t
>> 1>        ]
>> 1>        and
>> 1>        [
>> 1>            Graph=AGraph,
>> 1>            ValueType=int,
>> 1>            Reference=int &,
>> 1>            Tag=posx_t
>> 1>        ]
>> 1>        No constructor could take the source type, or constructor
>> overload resolution was ambiguous
>
> The error seems to be that you are trying to convert from the const property
> map type (because the graph in boostToVAGraph is const) to the non-const one
> (property_map<AGraph, posx_t>::type).  I believe you would want
> property_map<AGraph, posx_t>::const_type as the property map type in your
> function instead.
>
> -- 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