Boost logo

Boost Users :

From: François Duranleau (duranlef_at_[hidden])
Date: 2006-09-08 14:15:44


On Thu, 7 Sep 2006, Eric Fowler wrote:

> How do I declare a graph that does not allow parallel edges?
>
> I have come up with this but IMO it is sort of, well, kludgey:
>
> typedef adjacency_list<setS, vecS, bidirectionalS> Graph;
>
> This works because std::set does not like multiple entries.
>
> But what if for performance reasons (say) I want a listS or vecS instead of
> setS?
>
> In adjacency_list.hpp I find:
> template <>
> struct parallel_edge_traits<setS> {
> typedef disallow_parallel_edge_tag type; };
>
> Which suggest the existence of a more elegant mechanism.
>
> Anybody know what that is?

You could write a wrapper around std::vector or std::list that enforces
unicity of it's elements, create a tag (e.g. my_tagS) for it and then a
few thins like this:

struct my_tagS {} ;

template < typename ValueType >
class my_container
{
     // ...
} ;

namespace boost {

template < typename ValueType >
struct container_gen< my_tagS , ValueType >
{
     typedef my_container< ValueType > type ;
} ;

template <>
struct parallel_edge_traits< my_tagS >
{
     typedef disallow_parallel_edge_tag type ;
} ;

}

I have never tried it, though, so no guaranty it will work out.

-- 
François Duranleau
LIGUM, Université de Montréal
"Any sufficiently advanced technology is indistinguishable from magic"
                                                         - Arthur C. Clarke

_______________________________________________
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