[Graph] How to initialize edge index map?

Hi, How to initialize edge index map? I tried following: typedef adjacency_list<vecS, vecS, directedS, Vertex, Edge> graph_t; graph_traits<graph_t>::edge_iterator ei, ei_end; graph_t graph(num_nodes); ...... adding edges ...... for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei, ++index) put(edge_index, graph, *ei, index); But I always get a compilation error: /usr/include/boost/property_map.hpp: In function ‘void boost::put(const boost::put_get_helper<Reference, PropertyMap>&, K, const V&) [with PropertyMap = boost::adj_list_edge_property_map<boost::directed_tag, boost::detail::error_property_not_found, boost::detail::error_property_not_found&, unsigned int, boost::property<boost::edge_bundle_t, Edge, boost::no_property>, boost::edge_index_t>, Reference = boost::detail::error_property_not_found&, K = boost::detail::edge_desc_impl<boost::directed_tag, unsigned int>, V = int]’: /usr/include/boost/graph/detail/adjacency_list.hpp:1667: instantiated from ‘void boost::put(Property, boost::adj_list_helper<Config, Base>&, const Key&, const Value&) [with Config = boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, Vertex, Edge, boost::no_property, boost::listS>, boost::vecS, boost::vecS, boost::directedS, boost::property<boost::vertex_bundle_t, Vertex, boost::no_property>, boost::property<boost::edge_bundle_t, Edge, boost::no_property>, boost::no_property, boost::listS>::config, Base = boost::directed_graph_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, Vertex, Edge, boost::no_property, boost::listS>, boost::vecS, boost::vecS, boost::directedS, boost::property<boost::vertex_bundle_t, Vertex, boost::no_property>, boost::property<boost::edge_bundle_t, Edge, boost::no_property>, boost::no_property, boost::listS>::config>, Property = boost::edge_index_t, Key = boost::detail::edge_desc_impl<boost::directed_tag, unsigned int>, Value = int]’ shooting_star_boost_wrapper.cpp:266: instantiated from here /usr/include/boost/property_map.hpp:319: error: no match for ‘operator=’ in ‘((const boost::adj_list_edge_property_map<boost::directed_tag, boost::detail::error_property_not_found, boost::detail::error_property_not_found&, unsigned int, boost::property<boost::edge_bundle_t, Edge, boost::no_property>, boost::edge_index_t>*)((const boost::adj_list_edge_property_map<boost::directed_tag, boost::detail::error_property_not_found, boost::detail::error_property_not_found&, unsigned int, boost::property<boost::edge_bundle_t, Edge, boost::no_property>, boost::edge_index_t>&)((const boost::adj_list_edge_property_map<boost::directed_tag, boost::detail::error_property_not_found, boost::detail::error_property_not_found&, unsigned int, boost::property<boost::edge_bundle_t, Edge, boost::no_property>, boost::edge_index_t>*)(& pa))))->boost::adj_list_edge_property_map<Directed, Value, Ref, Vertex, Property, Tag>::operator[] [with Directed = boost::directed_tag, Value = boost::detail::error_property_not_found, Ref = boost::detail::error_property_not_found&, Vertex = unsigned int, Property = boost::property<boost::edge_bundle_t, Edge, boost::no_property>, Tag = boost::edge_index_t](k) = v’ /usr/include/boost/pending/detail/property.hpp:21: note: candidates are: boost::detail::error_property_not_found& boost::detail::error_property_not_found::operator=(const boost::detail::error_property_not_found&) I really can't get through all these template parameters :( Please, tell me how to initialize this map properly! Thanks, Anton.

Hi Anton, On 8/2/07, Anton A. Patrushev <anton@orkney.co.jp> wrote:
Hi, How to initialize edge index map? I tried following:
typedef adjacency_list<vecS, vecS, directedS, Vertex, Edge> graph_t;
You are using bundled properties, [snip]
for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei, ++index) put(edge_index, graph, *ei, index);
but you are trying to access a property list. If you are using bundled properties and your Edge looks like: struct Edge{ std::size_t edge_index; }; the initialization reads: for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei, ++index) graph[*ei].edge_index = index; If you were using property lists and typedef you adjacency_list like typedef adjacency_list<vecS, vecS, directedS, Vertex, property<edge_intex_t, std::size_t> > graph_t; your initialization would worked. See http://tinyurl.com/r7gv6 and http://tinyurl.com/35adta for details. HTH, Stephan

Thank you, Stephan! It's working now. Anton.
Hi Anton,
On 8/2/07, Anton A. Patrushev <anton@orkney.co.jp> wrote:
Hi, How to initialize edge index map? I tried following:
typedef adjacency_list<vecS, vecS, directedS, Vertex, Edge> graph_t;
You are using bundled properties,
[snip]
for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei, ++index) put(edge_index, graph, *ei, index);
but you are trying to access a property list. If you are using bundled properties and your Edge looks like: struct Edge{ std::size_t edge_index; }; the initialization reads:
for(tie(ei, ei_end) = edges(graph); ei != ei_end; ++ei, ++index) graph[*ei].edge_index = index;
If you were using property lists and typedef you adjacency_list like typedef adjacency_list<vecS, vecS, directedS, Vertex, property<edge_intex_t, std::size_t> > graph_t; your initialization would worked.
See http://tinyurl.com/r7gv6 and http://tinyurl.com/35adta for details.
HTH, Stephan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Anton A. Patrushev
-
Stephan Diederich