Boost logo

Boost :

Subject: Re: [boost] [graph]Direct Edge Access
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2013-03-07 19:41:18

On Thu, 7 Mar 2013, Takatoshi Kondo wrote:

> Hi Jeremiah,
> Thank you for your reply. I'm relieved that I understand correctly. I
> come up with a related question.
> I think that general graph algorithm developers should test two
> different things.
> One is concepts. If function my_algo() required
> VertexAndEdgeListGraphConcept for the parameter g, it should be
> checked as follows:
> #include <boost/graph/graph_concepts.hpp>
> template <typename Graph>
> void my_algo(Graph g) {
> BOOST_CONCEPT_ASSERT(( boost::VertexAndEdgeListGraphConcept<Graph> ));
> boost::edge(0, 1, g); // accidental invalid use ... Line A
> }
> But this test cannot detect out of concepts functions usage as Line A
> if class Graph accidentally provide them.
> So, these problems should be detected the following test:
> void my_algo_test() {
> typedef /* Only satisfies VertexAndListGraphConcept*/ Graph; // ... Line B
> Graph g;
> my_algo(g);
> }
> How do I define the type that is only satisfied specific concepts?

Those are called "archetypes" in the terminology of the Boost Concept
Check Library
There is a set of them for Boost.Graph concepts in
<boost/graph/graph_archetypes.hpp>. They do not appear to have
documentation, but example uses include most files with the name pattern
*_cc.cpp in libs/graph/test (e.g., bfs_cc.cpp).

-- Jeremiah Willcock

Boost list run by bdawes at, gregod at, cpdaniel at, john at