Boost logo

Boost Users :

Subject: Re: [Boost-users] Adding additional property in Boost graph object.
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2009-11-30 15:48:48


On Mon, 30 Nov 2009, Amanullah Yasin wrote:

> Hi, 
> Dear all
>
> I want to add one additional edge property in Boost graph object of type "bool". Please guide me how i can do it. I tried but not successful. 
>
> ////////////////////// Here is the main definition of Boost graph object "slGraph"  /////////////////////////////////////////////////////////////////////////
> namespace boost {
>   struct computable_object_t
>   {
>     typedef vertex_property_tag kind;
>   };
> }
>
> typedef boost::property<boost::vertex_index_t, unsigned int,
>                         boost::property<boost::computable_object_t,
>                                         plComputableObject*> > slVertexProperty;
>
> typedef boost::property<boost::edge_weight_t, slScoreValueType> slEdgeProperty;
>
> typedef boost::adjacency_list<boost::vecS, boost::listS, boost::bidirectionalS,
> \                              slVertexProperty, slEdgeProperty> slGraph;
>
> typedef slGraph::vertex_descriptor slNode;
> typedef slGraph::edge_descriptor slEdge;
> typedef slGraph::vertex_iterator slNodeIterator;
> typedef slGraph::edge_iterator slEdgeIterator;
> typedef slGraph::out_edge_iterator slOutEdgeIterator;
> typedef slGraph::in_edge_iterator slInEdgeIterator;
> typedef slGraph::adjacency_iterator slOutNodeIterator;
> typedef slGraph::inv_adjacency_iterator slInNodeIterator;

You don't need to put your property tag in the boost namespace. Is there
anything you tried to do to add the new property and failed? You can just
add a new element to the chain of boost::property elements for your edge
properties (slEdgeProperty), given your property tag (see the definition
of computable_object_t for how to create a tag, but use edge_property_tag
for yours). You can also use bundled properties
(http://www.boost.org/doc/libs/1_41_0/libs/graph/doc/bundles.html) which
will greately simplify adding properties.

-- 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