[Lemon-user] Iterate through weighted edges
Alpár Jüttner
alpar at cs.elte.hu
Mon Feb 14 12:32:09 CET 2011
Hi,
>
> I want to create a graph with weighted edges and iterate through
> outgoing edges of a given node with ascending weights.
Unfortunately you must somehow sort the edges by hand in this case.
For example:
std::multimap<double,ListDigraph::Arc> m;
for (ListDigraph::OutArcIt a(g, n1); a!=INVALID; ++a)
m.insert(std::pair<double,ListDigraph::Arc>(length,a));
int count = 0;
for (std::multimap<double,ListDigraph::Arc>::iterator i =
m.begin();i!=m.end;++i)
{
++count;
ListDigraph::Arc a = i->second;
Node ns= g.source(a);
Node nd = g.target(a);
cout << coords[ns] << "," << coords[nd] << "\t/ arc length : "
<< length[a] << endl;
}
Regards,
Alpár
More information about the Lemon-user
mailing list