I have Delaunay triangulating over some points and you want to iterate over all the edges in it in increasing order of length in order to build a minimum spanning thread.
I tried using the following approach, but I can not compile it:
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> T;
typedef K::Point_2 P;
typedef T::Vertex_handle Vh;
typedef T::Vertex_iterator Vi;
typedef T::Edge_iterator Ei;
bool sortFunction (Ei a, Ei b) {
K::FT la, lb;
la = CGAL::squared_distance(a.source().point(), a.target().point());
lb = CGAL::squared_distance(b.source().point(), b.target().point());
return la < lb;
}
...
T g;
...
std::vector<Ei> edges;
for (Ei ei = g.edges_begin(); ei != g.edges_end(); ei++) {
edges.push_back(ei);
}
std::sort(edges.begin(), edges.end(), sortFunction);
...
Compilation error in sortFunctionsaying that sourceit is not a member Edge_iterator. However, the documentation confuses me.
The CGAL documentation says that the type of value of an edge iterator is a semi-task.
There it is said that I can use source()and target()to access points.
However, this does not seem to be the case. What have I messed up here?
source
share