From 00e6e420e6bda8bc703de4d2de6e831821bad906 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 22 Jan 2018 12:50:03 +0000 Subject: Fix some cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3148 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 34a01d0b7d9b59e72fd14e7616a09dde50e1dbd1 --- src/Nerve_GIC/include/gudhi/GIC.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Nerve_GIC/include') diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index 9dc754f4..2fd61f14 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -169,9 +169,9 @@ class Cover_complex { double u; while (m < sampleSize) { u = GetUniform(); - if ((populationSize - t) * u >= sampleSize - m) + if ((populationSize - t) * u >= sampleSize - m) { t++; - else { + } else { samples[m] = t; t++; m++; @@ -679,8 +679,9 @@ class Cover_complex { tmp++; } u = inter3.second; - } else + } else { u = inter1.first; + } std::pair inter2 = intervals[i + 1]; while (func[points[tmp]] < inter2.first && tmp != n) { @@ -1110,9 +1111,9 @@ class Cover_complex { */ template void compute_distribution(int N = 100) { - if (distribution.size() >= N) + if (distribution.size() >= N) { std::cout << "Already done!" << std::endl; - else { + } else { for (int i = 0; i < N - distribution.size(); i++) { Cover_complex Cboot; Cboot.n = this->n; -- cgit v1.2.3 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 --- biblio/how_to_cite_gudhi.bib | 11 ++++++++- 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 ++-- 5 files changed, 61 insertions(+), 45 deletions(-) (limited to 'src/Nerve_GIC/include') diff --git a/biblio/how_to_cite_gudhi.bib b/biblio/how_to_cite_gudhi.bib index 28014ade..5994124a 100644 --- a/biblio/how_to_cite_gudhi.bib +++ b/biblio/how_to_cite_gudhi.bib @@ -128,6 +128,15 @@ , title = "Cover complex" , publisher = "{GUDHI Editorial Board}" , booktitle = "{GUDHI} User and Reference Manual" -, url = "http://gudhi.gforge.inria.fr/doc/latest/group__bottleneck__distance.html" +, url = "http://gudhi.gforge.inria.fr/doc/latest/group__cover__complex.html" +, year = 2017 +} + +@incollection{gudhi:PersistenceRepresentations +, author = "Pawel Dlotko" +, title = "Persistence representations" +, publisher = "{GUDHI Editorial Board}" +, booktitle = "{GUDHI} User and Reference Manual" +, url = "http://gudhi.gforge.inria.fr/doc/latest/group___persistence__representations.html" , year = 2017 } 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 From 497f2e8edff6d44689dff5ecdf945caadd439993 Mon Sep 17 00:00:00 2001 From: mcarrier Date: Thu, 25 Jan 2018 15:26:58 +0000 Subject: Small changes suggested by Marc git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3157 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 011f3638ca7b0c51cdd0d0983bb9e2f6fd256ad9 --- src/Nerve_GIC/include/gudhi/GIC.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/Nerve_GIC/include') diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index 27030723..642b88b0 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -50,6 +50,7 @@ #include // for std::max #include #include +#include namespace Gudhi { @@ -1044,9 +1045,7 @@ class Cover_complex { } for (auto const& simplex : simplices) { - // Add simplices - st.insert_simplex_and_subfaces(simplex); - // Add cone on simplices + // Add a simplex and a cone on it std::vector splx = simplex; splx.push_back(-2); st.insert_simplex_and_subfaces(splx); @@ -1070,7 +1069,7 @@ class Cover_complex { else st.assign_filtration(simplex, filts); } - std::vector magic = {-2}; + int magic[] = {-2}; st.assign_filtration(st.find(magic), -3); // Compute PD @@ -1084,7 +1083,7 @@ class Cover_complex { for (int i = 0; i < max_dim; i++) { std::vector > bars = pcoh.intervals_in_dimension(i); int num_bars = bars.size(); - std::cout << num_bars << " interval(s) in dimension " << i << ":" << std::endl; + if(verbose) std::cout << num_bars << " interval(s) in dimension " << i << ":" << std::endl; for (int j = 0; j < num_bars; j++) { double birth = bars[j].first; double death = bars[j].second; @@ -1212,8 +1211,8 @@ class Cover_complex { } if (type == "Nerve") { - for (std::map >::iterator it = cover.begin(); it != cover.end(); it++) - simplices.push_back(it->second); + for(auto& simplex : cover) + simplices.push_back(simplex.second); std::sort(simplices.begin(), simplices.end()); std::vector >::iterator it = std::unique(simplices.begin(), simplices.end()); simplices.resize(std::distance(simplices.begin(), it)); -- cgit v1.2.3