Boost logo

Boost Users :

Subject: Re: [Boost-users] newbie - graph library - vertex properties
From: Suresh Kumar (suresh.amritapuri_at_[hidden])
Date: 2009-12-17 00:54:17


Hi Tobias

I managed to figure out how to use the property maps. When we can get
vertex property as graph[vertex_descriptor] why property maps? again,
when the above method is available, what do we gain by vertex_bundle
property tag etc?

Thanks
suresh

On Wed, Dec 16, 2009 at 5:00 PM, Suresh Kumar
<suresh.amritapuri_at_[hidden]> wrote:
> Hi,
>
> For example, I wrote the following:
>  typedef property_map<Map, double Highway::*>::const_type IndexMap;
>  IndexMap index = get(&Highway::miles,map);
>
> But I am unable to figure out how to get the actual vertex property
> from the IndexMap index.
>
> Also, how do we use, get(vertex_bundle, map)?
>
> Thanks
> suresh
>
>
> On Wed, Dec 16, 2009 at 4:09 PM, Suresh Kumar
> <suresh.amritapuri_at_[hidden]> wrote:
>> Hi Tobias,
>>
>> Can you just show, how to access the vertex properties using the get()
>>  function?. I know that map[vertex_descriptior] gives me the
>> vertex_properties of that particular vertex. But I am unable to figure
>> out how to use the get function for single vertex property as well as
>> for the vertex_bundle,
>>
>> Thanks
>> suresh
>>
>> On Tue, Dec 15, 2009 at 3:18 PM, Tobias Columbus <t.columbus_at_[hidden]> wrote:
>>> Hi again,
>>>
>>> Try the following code, which just compiles fine with g++ 4.4.1 on my
>>> system:
>>>
>>> struct City{...};
>>> struct Highway{...};
>>>
>>> typedef ... Map;
>>>
>>> int main(){
>>> Map map;
>>> Map::vertex_descriptor v = add_vertex( map );
>>> Map::vertex_descriptor u = add_vertex( map );
>>> map[v].name = "Troy";
>>> map[v].population = 49170;
>>> map[v].zipcodes.push_back(12180);
>>> Map::edge_descriptor e = add_edge( u, v, map ).first;
>>> map[e].name = "I-87";
>>> map[e].miles = 10;
>>> map[e].speed_limit = 65;
>>> map[e].lanes = 4;
>>> map[e].divided = true;
>>> return 0;
>>> }
>>>
>>> Generally I would suggest reading
>>> http://www.boost.org/doc/libs/1_41_0/libs/graph/doc/quick_tour.html
>>> which gives a quick overview of how to handle graphs in BGL.
>>>
>>> If you work through this tutorial, vertex and edge properties will also
>>> get explained.
>>>
>>> Regards
>>> Tobias
>>>
>>> On Tuesday 15 December 2009 05:00:01 pm List User wrote:
>>>> Hi Tobias Columbus,
>>>>
>>>> In fact I had tried that also. But then I got a funny message while
>>> executing like this: Ubuntu 9.04, g++ 4.3.3
>>>> //Map::vertex_descriptor v = *vertices(map).first;
>>>>  Map::vertex_descriptor v = add_vertex(map);
>>>>
>>>> suresh_at_suresh-laptop:~/C++$ ./a.out
>>>> *** glibc detected *** ./a.out: free(): invalid pointer: 0x09f9c064
>>> ***
>>>> ======= Backtrace: =========
>>>> /lib/tls/i686/cmov/libc.so.6[0xb7e6a604]
>>>> /lib/tls/i686/cmov/libc.so.6(cfree+0x96)[0xb7e6c5b6]
>>>> /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb804d231]
>>>> ../a.out[0x8049e7d]
>>>> ../a.out[0x8049ea7]
>>>> ..
>>>> ..
>>>> ..
>>>>
>>>> so what to do next?
>>>>
>>>> suresh
>>>>
>>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>
>>
>>
>> --
>> R. Suresh Kumar
>> PhD Student, Vislab
>> #216, Engineering II Bldg
>> University of California, Riverside,
>> CA 92521
>>
>
>
>
> --
> R. Suresh Kumar
> PhD Student, Vislab
> #216, Engineering II Bldg
> University of California, Riverside,
> CA 92521
>

-- 
R. Suresh Kumar
PhD Student, Vislab
#216, Engineering II Bldg
University of California, Riverside,
CA 92521

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