I was wondering if there was a way to get a sorted vector of a boost graph's edges without the use of lambda functions.
I.e. I am currently sorting like this:
std::vector<Edge> edgs = ...;
std::sort(edgs.begin(),edgs.end(),
[&](const Edge& e1, const Edge& e2){
return g[e1].source < g[e2].source || (g[e1].source == g[e2].source && g[e1].target < g[e2].target);
});
Where g
is the graph we have taken the edges from and
struct EdgeProperties{
int weight;
int source;
int target;
};
typedef boost::adjacency_list<vecS,vecS,undirectedS,no_property,EdgeProperties> Graph;
typedef boost::graph_traits<Graph> Traits;
typedef Traits::vertex_descriptor Vertex;
typedef Traits::edge_descriptor Edge;
Works, but I'd prefer not having to use lambda functions. Is there a way to avoid them (still using the std::sort) or am I stuck with them?