Boost logo

Boost Users :

Subject: Re: [Boost-users] How to find edge between two vertices of undirected graph?
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-06-11 15:29:35


On Thu, 10 Jun 2010, Eric Fowler wrote:

> It seems I do not have a mutable graph. This sort of raises another
> issue: how do I declare an object that is described by a concept? 

The best you can do is apply a concept checking class. That doesn't
filter the members so you can only use the MutableGraph-required
functions, but it at least makes sure that the graph you have is a
MutableGraph.

> For example, in this case I know I need a MutableGraph, and I see from the doc (http://www.boost.org/doc/libs/1_43_0/libs/graph/doc/MutableGraph.html) that MutableGraphs
> have certain properties, such as DefaultConstructible, etc. 
>
> Now, how do I declare a MutableGraph, and know I have one? I know that:
>
>  typedef adjacency_list<vecS, vecS, undirectedS, POS<position_type> LEN<position_type> > DG;

What methods are missing? Could you please try applying the MutableGraph
concept checking class to the DG type and see what breaks?

> More to the point, how do I read something like: 
>
> template <class G>
> struct GraphConcept
> {
> typedef typename boost::graph_traits<G>::vertex_descriptor vertex_descriptor;
> typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
> ..blah...
> void constraints() {
> function_requires< DefaultConstructibleConcept<vertex_descriptor> >();
> function_requires< EqualityComparableConcept<vertex_descriptor> >();
> function_requires< AssignableConcept<vertex_descriptor> >();
> ...blah....
>
> }
> G g;
> };
>
> And produce something that looks like:
>
> typedef adjacency_list<blahS, blabS, ...etc...> MyGraphType;

What do you mean? You want to add methods/functions to the graph type to
make it model a specific concept?

-- Jeremiah Willcock


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