|
Boost Users : |
From: Jeffrey Holle (jeff.holle_at_[hidden])
Date: 2004-09-21 21:14:21
I'm using boost 1.31.0 and gcc 3.4.2.
While this problem is more of an application code problem, since I got
no help on other lists, I trying this one with hopes of a response.
I need to identify parallel edges from my graph, which is defined as:
typedef subgraph<adjacency_list<vecS,
vecS,
bidirectionalS,
property<vertex_index_t,int,VertexProperty>,
EdgeProperty> > DataGraphT;
typedef boost::graph_traits <DataGraphT>::edge_descriptor DataEdge;
In the test case that I'm working on, I know I have parallel edges,
actually 4 sets of 3.
I'd like to use this code:
DataGraph::handleParallelEdges(void)
{
typedef multiset<DataEdge,ltSubgraph> Edges;
Edges edges;
graph_traits<DataGraphT>::edge_iterator ei,ei_end;
for (tie(ei,ei_end)=boost::edges(dataGraph_);ei!=ei_end;++ei)
edges.insert(*ei);
for (Edges::const_iterator iter = edges.begin(); iter != edges.end();
advance(iter,edges.count(*iter)))
if (edges.count(*iter)>1)
cout << "See duplicate" << endl;
}
However, when count never returns.
The likely cause of this (I suspect) is the ltSubgraph functor.
Its definition is:
struct ltSubgraph : public std::binary_function<DataEdge,DataEdge,bool>
{
bool operator() (const DataEdge& s1, const DataEdge& s2) const
{
return s1.m_source < s2.m_source ||
(!(s1.m_source < s2.m_source) && s1.m_target < s2.m_target);
}
};
I say this because I can see that this functor is being continuously
called in this infinite loop.
Note that I use this functor in multiple other cases, but not with an
associate container that allows duplicate keys.
Is there a problem with this code?
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