BGL - edge descriptor and map

I'd like to specify better my problem. I'd like to use an edge_descriptor (graph_traits<G>::edge_descriptor) as key in a map. The graph type is something like this: typedef adjacency_list<vecS, vecS, bidirectionalS, no_property, MyStuff> G; I think that I've to overload the < operator for graph_traits<G>::edge_descriptor. Is this correct? If so, given two edge_descriptors I need to access the source and the target of the edge in such a way to define a sort ordering. Thanks, Giulio

You have to do something like this - but this doesn't support multigraphs template<typename EdgeType> struct EdgeCompare : public std::binary_function<EdgeType, EdgeType, bool> { bool operator ()(const EdgeType& edge1, const EdgeType& edge2) const { if (edge1.m_source < edge2.m_source) return true ; if (edge1.m_source == edge2.m_source && edge1.m_target < edge2.m_target) return true ; return false ; } } ; typedef graph_traits<G>::edge_descriptor MyEdgeType typedef std::set<MyEdgeType, EdgeCompare<MyEdgeType> > MyEdgeSetType ; TC -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Giulio Veronesi Sent: 21 September 2005 13:18 To: boost-users@lists.boost.org Subject: [Boost-users] BGL - edge descriptor and map I'd like to specify better my problem. I'd like to use an edge_descriptor (graph_traits<G>::edge_descriptor) as key in a map. The graph type is something like this: typedef adjacency_list<vecS, vecS, bidirectionalS, no_property, MyStuff> G; I think that I've to overload the < operator for graph_traits<G>::edge_descriptor. Is this correct? If so, given two edge_descriptors I need to access the source and the target of the edge in such a way to define a sort ordering. Thanks, Giulio _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Giulio Veronesi
-
Tony Cook