summaryrefslogtreecommitdiff
path: root/src/Contraction
diff options
context:
space:
mode:
Diffstat (limited to 'src/Contraction')
-rw-r--r--src/Contraction/doc/so3.svg2
-rw-r--r--src/Contraction/example/CMakeLists.txt1
-rw-r--r--src/Contraction/example/Garland_heckbert.cpp6
-rw-r--r--src/Contraction/example/Garland_heckbert/Error_quadric.h2
-rw-r--r--src/Contraction/example/Rips_contraction.cpp12
-rw-r--r--src/Contraction/include/gudhi/Edge_contraction.h22
-rw-r--r--src/Contraction/include/gudhi/Skeleton_blocker_contractor.h27
7 files changed, 41 insertions, 31 deletions
diff --git a/src/Contraction/doc/so3.svg b/src/Contraction/doc/so3.svg
index adea3f38..f10cab98 100644
--- a/src/Contraction/doc/so3.svg
+++ b/src/Contraction/doc/so3.svg
@@ -177,7 +177,7 @@
x="309.4176"
y="300.58682"
id="tspan4515-4"
- style="text-align:center;text-anchor:middle">Rips complex built uppon these points</tspan><tspan
+ style="text-align:center;text-anchor:middle">Rips complex built upon these points</tspan><tspan
sodipodi:role="line"
x="309.4176"
y="308.96704"
diff --git a/src/Contraction/example/CMakeLists.txt b/src/Contraction/example/CMakeLists.txt
index f0dc885d..c5d31aca 100644
--- a/src/Contraction/example/CMakeLists.txt
+++ b/src/Contraction/example/CMakeLists.txt
@@ -4,7 +4,6 @@ if (NOT CGAL_VERSION VERSION_LESS 4.11.0)
add_executable(RipsContraction Rips_contraction.cpp)
add_executable(GarlandHeckbert Garland_heckbert.cpp)
- target_link_libraries(GarlandHeckbert ${Boost_TIMER_LIBRARY})
add_test(NAME Contraction_example_tore3D_0.2 COMMAND $<TARGET_FILE:RipsContraction>
"${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "0.2")
diff --git a/src/Contraction/example/Garland_heckbert.cpp b/src/Contraction/example/Garland_heckbert.cpp
index 9c0b5205..489ef5d0 100644
--- a/src/Contraction/example/Garland_heckbert.cpp
+++ b/src/Contraction/example/Garland_heckbert.cpp
@@ -147,7 +147,7 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- std::cout << "Load complex with " << complex.num_vertices() << " vertices" << std::endl;
+ std::clog << "Load complex with " << complex.num_vertices() << " vertices" << std::endl;
int num_contractions = atoi(argv[3]);
@@ -158,10 +158,10 @@ int main(int argc, char *argv[]) {
Gudhi::contraction::make_link_valid_contraction<EdgeProfile>(),
new GH_visitor(complex));
- std::cout << "Contract " << num_contractions << " edges" << std::endl;
+ std::clog << "Contract " << num_contractions << " edges" << std::endl;
contractor.contract_edges(num_contractions);
- std::cout << "Final complex has " <<
+ std::clog << "Final complex has " <<
complex.num_vertices() << " vertices, " <<
complex.num_edges() << " edges and " <<
complex.num_triangles() << " triangles." << std::endl;
diff --git a/src/Contraction/example/Garland_heckbert/Error_quadric.h b/src/Contraction/example/Garland_heckbert/Error_quadric.h
index 49250d7a..ae46232c 100644
--- a/src/Contraction/example/Garland_heckbert/Error_quadric.h
+++ b/src/Contraction/example/Garland_heckbert/Error_quadric.h
@@ -29,7 +29,7 @@ template <typename Point> class Error_quadric {
* Quadric corresponding to the L2 distance to the plane.
*
* According to the notation of Garland Heckbert, they
- * denote a quadric symetric matrix as :
+ * denote a quadric symmetric matrix as :
* Q = [ q11 q12 q13 q14]
* [ q12 q22 q23 q24]
* [ q13 q23 q33 q34]
diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp
index b5ce06c1..547c290e 100644
--- a/src/Contraction/example/Rips_contraction.cpp
+++ b/src/Contraction/example/Rips_contraction.cpp
@@ -39,7 +39,7 @@ void build_rips(ComplexType& complex, double offset) {
int main(int argc, char *argv[]) {
if (argc != 3) {
std::cerr << "Usage " << argv[0] << " ../../../data/meshes/SO3_10000.off 0.3 to load the file " <<
- "../../data/SO3_10000.off and contract the Rips complex built with paremeter 0.3.\n";
+ "../../data/SO3_10000.off and contract the Rips complex built with parameter 0.3.\n";
return -1;
}
@@ -52,13 +52,13 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- std::cout << "Build the Rips complex with " << complex.num_vertices() << " vertices" << std::endl;
+ std::clog << "Build the Rips complex with " << complex.num_vertices() << " vertices" << std::endl;
build_rips(complex, atof(argv[2]));
Gudhi::Clock contraction_chrono("Time to simplify and enumerate simplices");
- std::cout << "Initial complex has " <<
+ std::clog << "Initial complex has " <<
complex.num_vertices() << " vertices and " <<
complex.num_edges() << " edges" << std::endl;
@@ -69,16 +69,16 @@ int main(int argc, char *argv[]) {
Gudhi::contraction::make_remove_popable_blockers_visitor<Profile>());
contractor.contract_edges();
- std::cout << "Counting final number of simplices \n";
+ std::clog << "Counting final number of simplices \n";
unsigned num_simplices = std::distance(complex.complex_simplex_range().begin(), complex.complex_simplex_range().end());
- std::cout << "Final complex has " <<
+ std::clog << "Final complex has " <<
complex.num_vertices() << " vertices, " <<
complex.num_edges() << " edges, " <<
complex.num_blockers() << " blockers and " <<
num_simplices << " simplices" << std::endl;
- std::cout << contraction_chrono;
+ std::clog << contraction_chrono;
return EXIT_SUCCESS;
}
diff --git a/src/Contraction/include/gudhi/Edge_contraction.h b/src/Contraction/include/gudhi/Edge_contraction.h
index 6058d64b..dff6dc14 100644
--- a/src/Contraction/include/gudhi/Edge_contraction.h
+++ b/src/Contraction/include/gudhi/Edge_contraction.h
@@ -26,6 +26,7 @@ namespace contraction {
/** \defgroup contr Edge contraction
+@{
\author David Salinas
@@ -45,9 +46,9 @@ the operations needed for edge contraction algorithms have polynomial complexity
Therefore, the simplification can be done without enumerating the set of simplices that is often non tracktable in high-dimension and is then very efficient
(sub-linear with regards to the number of simplices in practice).
-A typical application of this package is homology group computation. It is illustrated in the next figure where a Rips complex is built uppon a set of high-dimensional points and
+A typical application of this package is homology group computation. It is illustrated in the next figure where a Rips complex is built upon a set of high-dimensional points and
simplified with edge contractions.
-It has initially a big number of simplices (around 20 millions) but simplifying it to a much reduced form with only 15 vertices (and 714 simplices) takes only few seconds on a desktop machine (see the example bellow).
+It has initially a big number of simplices (around 20 millions) but simplifying it to a much reduced form with only 15 vertices (and 714 simplices) takes only few seconds on a desktop machine (see the example below).
One can then compute homology group with a simplicial complex having very few simplices instead of running the homology algorithm on the much bigger initial set of
simplices which would take much more time and memory.
@@ -64,7 +65,7 @@ This class design is policy based and heavily inspired from the similar edge col
Four policies can be customized in this package:
\li Cost_policy: specify how much cost an edge contraction of a given edge. The edge with lowest cost is iteratively picked and contracted if valid.
-\li Valid_contraction_policy: specify if a given edge contraction is valid. For instance, this policy can check the link condition which ensures that the homotopy type is preserved afer the edge contraction.
+\li Valid_contraction_policy: specify if a given edge contraction is valid. For instance, this policy can check the link condition which ensures that the homotopy type is preserved after the edge contraction.
\li Placement_policy: every time an edge is contracted, its points are merge to one point specified by this policy. This may be the middle of the edge of some more sophisticated point such as the minimum of a cost as in
\cite Garland.
@@ -91,7 +92,7 @@ Despite this package is able to deal with \a arbitrary simplicial complexes (any
it is still \a 65% times faster than the CGAL package which is focused on 2-manifold.
The main reason is that few blockers appears during the simplification and hence,
the algorithm only have to deal with the graph and not higher-dimensional simplices
-(in this case triangles). However, we recall that higher-dimensional simplices are \a implicitely
+(in this case triangles). However, we recall that higher-dimensional simplices are \a implicitly
stored in the \ref skbl data-structure. Hence, one has to store
simplices in an external map if some information needs to be associated with them (information that could be a filtration value or
an orientation for instance).
@@ -152,7 +153,7 @@ void build_rips(ComplexType& complex, double offset){
int main (int argc, char *argv[])
{
if (argc!=3){
- std::cerr << "Usage "<<argv[0]<<" ../../data/SO3_10000.off 0.3 to load the file ../../data/SO3_10000.off and contract the Rips complex built with paremeter 0.3.\n";
+ std::cerr << "Usage "<<argv[0]<<" ../../data/SO3_10000.off 0.3 to load the file ../../data/SO3_10000.off and contract the Rips complex built with parameter 0.3.\n";
return -1;
}
@@ -164,13 +165,13 @@ int main (int argc, char *argv[])
std::cerr << "Unable to read file:"<<argv[1]<<std::endl;
return EXIT_FAILURE;
}
- std::cout << "Build the Rips complex"<<std::endl;
+ std::clog << "Build the Rips complex"<<std::endl;
build_rips(complex,atof(argv[2]));
boost::timer::auto_cpu_timer t;
- std::cout << "Initial complex has "<<
+ std::clog << "Initial complex has "<<
complex.num_vertices()<<" vertices and "<<
complex.num_edges()<<" edges"<<std::endl;
@@ -181,21 +182,20 @@ int main (int argc, char *argv[])
contraction::make_remove_popable_blockers_visitor<Profile>());
contractor.contract_edges();
- std::cout << "Counting final number of simplices \n";
+ std::clog << "Counting final number of simplices \n";
unsigned num_simplices = std::distance(complex.star_simplex_range().begin(),complex.star_simplex_range().end());
- std::cout << "Final complex has "<<
+ std::clog << "Final complex has "<<
complex.num_vertices()<<" vertices, "<<
complex.num_edges()<<" edges, "<<
complex.num_blockers()<<" blockers and "<<
num_simplices<<" simplices"<<std::endl;
- std::cout << "Time to simplify and enumerate simplices:\n";
+ std::clog << "Time to simplify and enumerate simplices:\n";
return EXIT_SUCCESS;
}
-}
\endcode
\verbatim
diff --git a/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h b/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
index a0d9f2b2..6911ca2e 100644
--- a/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
+++ b/src/Contraction/include/gudhi/Skeleton_blocker_contractor.h
@@ -171,8 +171,13 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
Self const* algorithm_;
};
+#if CGAL_VERSION_NR < 1050500000
typedef CGAL::Modifiable_priority_queue<Edge_handle, Compare_cost, Undirected_edge_id> PQ;
- typedef typename PQ::handle pq_handle;
+#else
+ typedef CGAL::Modifiable_priority_queue<Edge_handle, Compare_cost, Undirected_edge_id, CGAL::CGAL_BOOST_PENDING_RELAXED_HEAP> PQ;
+#endif
+
+ typedef bool pq_handle;
// An Edge_data is associated with EVERY edge in the complex (collapsible or not).
@@ -196,7 +201,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
}
bool is_in_PQ() const {
- return PQHandle_ != PQ::null_handle();
+ return PQHandle_ != false;
}
void set_PQ_handle(pq_handle h) {
@@ -204,7 +209,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
}
void reset_PQ_handle() {
- PQHandle_ = PQ::null_handle();
+ PQHandle_ = false;
}
private:
@@ -238,16 +243,22 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
}
void insert_in_PQ(Edge_handle edge, Edge_data& data) {
- data.set_PQ_handle(heap_PQ_->push(edge));
+ heap_PQ_->push(edge);
+ data.set_PQ_handle(true);
++current_num_edges_heap_;
}
void update_in_PQ(Edge_handle edge, Edge_data& data) {
+#if CGAL_VERSION_NR < 1050500000
data.set_PQ_handle(heap_PQ_->update(edge, data.PQ_handle()));
+#else
+ heap_PQ_->update(edge);
+#endif
}
void remove_from_PQ(Edge_handle edge, Edge_data& data) {
- data.set_PQ_handle(heap_PQ_->erase(edge, data.PQ_handle()));
+ heap_PQ_->erase(edge);
+ data.set_PQ_handle(false);
--current_num_edges_heap_;
}
@@ -280,7 +291,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
std::size_t id = 0;
- // xxx do a parralel for
+ // xxx do a parallel for
for (auto edge : complex_.edge_range()) {
complex_[edge].index() = id++;
Profile const& profile = create_profile(edge);
@@ -474,7 +485,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
}
void update_changed_edges() {
- // xxx do a parralel for
+ // xxx do a parallel for
DBG("update edges");
// sequential loop
@@ -530,7 +541,7 @@ typename GeometricSimplifiableComplex::Vertex_handle> {
// by definition of a blocker
// todo uniqument utile pour la link condition
- // laisser a l'utilisateur ? booleen update_heap_on_removed_blocker?
+ // laisser a l'utilisateur ? boolean update_heap_on_removed_blocker?
Simplex blocker_copy(*blocker);
for (auto x = blocker_copy.begin(); x != blocker_copy.end(); ++x) {
for (auto y = x; ++y != blocker_copy.end();) {