From cafbe7d63d0e16e27721864a1ffa1a67d8f0374f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 25 Jan 2018 14:06:24 +0000 Subject: Code review : fix camel case for types and use of std::log instead of log Add CGAL dependency for Nerve_GIC (link to bottleneck) Add persistence representation in bibtex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3155 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8a45497b3d1f34a5c4a1c7856113c6b7680a12a2 --- src/Nerve_GIC/example/CMakeLists.txt | 44 ++++++++++++++++++++---------------- src/Nerve_GIC/include/gudhi/GIC.h | 28 +++++++++++------------ src/Nerve_GIC/test/CMakeLists.txt | 19 +++++++++------- src/Nerve_GIC/test/test_GIC.cpp | 4 ++-- 4 files changed, 51 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/Nerve_GIC/example/CMakeLists.txt b/src/Nerve_GIC/example/CMakeLists.txt index 461b6db2..73728dc0 100644 --- a/src/Nerve_GIC/example/CMakeLists.txt +++ b/src/Nerve_GIC/example/CMakeLists.txt @@ -1,29 +1,33 @@ cmake_minimum_required(VERSION 2.6) project(Nerve_GIC_examples) -add_executable ( Nerve Nerve.cpp ) -add_executable ( CoordGIC CoordGIC.cpp ) -add_executable ( FuncGIC FuncGIC.cpp ) -add_executable ( VoronoiGIC VoronoiGIC.cpp ) +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) -if (TBB_FOUND) - target_link_libraries(Nerve ${TBB_LIBRARIES}) - target_link_libraries(CoordGIC ${TBB_LIBRARIES}) - target_link_libraries(FuncGIC ${TBB_LIBRARIES}) - target_link_libraries(VoronoiGIC ${TBB_LIBRARIES}) -endif() + add_executable ( Nerve Nerve.cpp ) + add_executable ( CoordGIC CoordGIC.cpp ) + add_executable ( FuncGIC FuncGIC.cpp ) + add_executable ( VoronoiGIC VoronoiGIC.cpp ) -file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + if (TBB_FOUND) + target_link_libraries(Nerve ${TBB_LIBRARIES}) + target_link_libraries(CoordGIC ${TBB_LIBRARIES}) + target_link_libraries(FuncGIC ${TBB_LIBRARIES}) + target_link_libraries(VoronoiGIC ${TBB_LIBRARIES}) + endif() -add_test(NAME Nerve_GIC_example_nerve COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/human.off" "2" "10" "0.3") + file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -add_test(NAME Nerve_GIC_example_VoronoiGIC COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/human.off" "100") + add_test(NAME Nerve_GIC_example_nerve COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/human.off" "2" "10" "0.3") -add_test(NAME Nerve_GIC_example_CoordGIC COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "0") + add_test(NAME Nerve_GIC_example_VoronoiGIC COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/human.off" "100") -add_test(NAME Nerve_GIC_example_FuncGIC COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat.off" - "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat_PCA1") + add_test(NAME Nerve_GIC_example_CoordGIC COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "0") + + add_test(NAME Nerve_GIC_example_FuncGIC COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat.off" + "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat_PCA1") + +endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index 2fd61f14..27030723 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -58,13 +58,13 @@ namespace cover_complex { using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; -using PersistenceDiagram = std::vector >; +using Persistence_diagram = std::vector >; using Graph = boost::subgraph< boost::adjacency_list > > >; -using vertex_t = boost::graph_traits::vertex_descriptor; -using IndexMap = boost::property_map::type; -using WeightMap = boost::property_map::type; +using Vertex_t = boost::graph_traits::vertex_descriptor; +using Index_map = boost::property_map::type; +using Weight_map = boost::property_map::type; /** * \class Cover_complex @@ -105,12 +105,12 @@ class Cover_complex { Graph one_skeleton_OFF; // one-skeleton given by the input OFF file (if it exists). Graph one_skeleton; // one-skeleton used to compute the connected components. - std::vector vertices; // vertices of one_skeleton. + std::vector vertices; // vertices of one_skeleton. std::vector > simplices; // simplices of output simplicial complex. std::vector voronoi_subsamples; // Voronoi germs (in case of Voronoi cover). - PersistenceDiagram PD; + Persistence_diagram PD; std::vector distribution; std::map > @@ -359,8 +359,8 @@ class Cover_complex { public: void set_graph_weights() { - IndexMap index = boost::get(boost::vertex_index, one_skeleton); - WeightMap weight = boost::get(boost::edge_weight, one_skeleton); + Index_map index = boost::get(boost::vertex_index, one_skeleton); + Weight_map weight = boost::get(boost::edge_weight, one_skeleton); boost::graph_traits::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = boost::edges(one_skeleton); ei != ei_end; ++ei) boost::put(weight, *ei, @@ -420,7 +420,7 @@ class Cover_complex { */ template double set_graph_from_automatic_rips(Distance distance, int N = 100) { - int m = floor(n / exp((1 + rate_power) * log(log(n) / log(rate_constant)))); + int m = floor(n / std::exp((1 + rate_power) * std::log(std::log(n) / std::log(rate_constant)))); m = std::min(m, n - 1); std::vector samples(m); double delta = 0; @@ -521,7 +521,7 @@ class Cover_complex { } double reso = 0; - IndexMap index = boost::get(boost::vertex_index, one_skeleton); + Index_map index = boost::get(boost::vertex_index, one_skeleton); if (type == "GIC") { boost::graph_traits::edge_iterator ei, ei_end; @@ -660,7 +660,7 @@ class Cover_complex { int id = 0; int pos = 0; - IndexMap index = boost::get(boost::vertex_index, one_skeleton); // int maxc = -1; + Index_map index = boost::get(boost::vertex_index, one_skeleton); // int maxc = -1; std::map > preimages; std::map funcstd; @@ -799,8 +799,8 @@ class Cover_complex { SampleWithoutReplacement(n, m, voronoi_subsamples); if (distances.size() == 0) compute_pairwise_distances(distance); set_graph_weights(); - WeightMap weight = boost::get(boost::edge_weight, one_skeleton); - IndexMap index = boost::get(boost::vertex_index, one_skeleton); + Weight_map weight = boost::get(boost::edge_weight, one_skeleton); + Index_map index = boost::get(boost::vertex_index, one_skeleton); std::vector mindist(n); for (int j = 0; j < n; j++) mindist[j] = std::numeric_limits::max(); @@ -1220,7 +1220,7 @@ class Cover_complex { } if (type == "GIC") { - IndexMap index = boost::get(boost::vertex_index, one_skeleton); + Index_map index = boost::get(boost::vertex_index, one_skeleton); if (functional_cover) { // Computes the simplices in the GIC by looking at all the edges of the graph and adding the diff --git a/src/Nerve_GIC/test/CMakeLists.txt b/src/Nerve_GIC/test/CMakeLists.txt index 03fe47ca..c35cdff7 100644 --- a/src/Nerve_GIC/test/CMakeLists.txt +++ b/src/Nerve_GIC/test/CMakeLists.txt @@ -1,14 +1,17 @@ cmake_minimum_required(VERSION 2.6) project(Graph_induced_complex_tests) -include(GUDHI_test_coverage) +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + include(GUDHI_test_coverage) -add_executable ( Nerve_GIC_test_unit test_GIC.cpp ) -target_link_libraries(Nerve_GIC_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(Nerve_GIC_test_unit ${TBB_LIBRARIES}) -endif() + add_executable ( Nerve_GIC_test_unit test_GIC.cpp ) + target_link_libraries(Nerve_GIC_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Nerve_GIC_test_unit ${TBB_LIBRARIES}) + endif() -file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -gudhi_add_coverage_test(Nerve_GIC_test_unit) + gudhi_add_coverage_test(Nerve_GIC_test_unit) + +endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Nerve_GIC/test/test_GIC.cpp b/src/Nerve_GIC/test/test_GIC.cpp index a8b1e7f7..d633753c 100644 --- a/src/Nerve_GIC/test/test_GIC.cpp +++ b/src/Nerve_GIC/test/test_GIC.cpp @@ -24,11 +24,11 @@ #define BOOST_TEST_MODULE "graph_induced_complex" #include -#include // float comparison + #include #include #include -#include // std::max + #include #include #include -- cgit v1.2.3