|
Boost : |
From: Alexey Nikitin (reductor_at_[hidden])
Date: 2003-09-26 04:16:45
> Two options come to mind:
> 1) Add an internal edge_index property to your edges, and use an
> std::map<std::Size_t, edge_descriptor>, or
Thanks, this is work.
> 2) Just make your map into an edge property. That'll give you O(1)
> access instead of O(lg n) access.
This method looks very prettily, but next code not compiled:
#define _DEBUG
#include <cassert>
#include <utility>
#include <boost/graph/adjacency_list.hpp>
using namespace boost;
using namespace std;
struct EDescr;
struct edge_descr_t { typedef edge_property_tag kind; };
typedef property<edge_descr_t, EDescr> EDescrProp;
typedef adjacency_list<vecS, vecS, directedS, no_property, EDescrProp>
Graph;
typedef graph_traits<Graph>::edge_descriptor EdgeDescr;
struct EDescr
{
EDescr() {};
EDescr(EdgeDescr e) : edge(e) {}
operator EdgeDescr() const { return edge; }
operator EdgeDescr&() { return edge; }
EdgeDescr edge;
};
int main()
{
Graph g(8);
pair<EdgeDescr,bool> e0 = add_edge(0, 1, g);
assert(e0.second);
pair<EdgeDescr,bool> e1 = add_edge(1, 2, g);
assert(e1.second);
put(edge_descr_t(), g, e0.first, e1.first);
put(edge_descr_t(), g, e1.first, e0.first);
}
with error
... boost\pending\property.hpp(24) : error C2079:
'boost::property<Tag,T>::m_value' uses undefined struct 'EDescr'
with
[
Tag=edge_descr_t,
T=EDescr
]
and many other. I'm use MSVC 7.1.
Can you help my correct this example?
Thanks, Alexey.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk