From 39aa69c8b968f9f86a71106d64785b0f31c20914 Mon Sep 17 00:00:00 2001 From: mcarrier Date: Fri, 12 May 2017 15:40:28 +0000 Subject: git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Nerve_GIC@2414 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 31b0cc927a8122cdc90abb5a24b6dba2481f2c48 --- src/Nerve_GIC/test/test.cpp | 79 ----------------------------------- src/Nerve_GIC/test/test_GIC.cpp | 92 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 79 deletions(-) delete mode 100644 src/Nerve_GIC/test/test.cpp create mode 100644 src/Nerve_GIC/test/test_GIC.cpp (limited to 'src/Nerve_GIC/test') diff --git a/src/Nerve_GIC/test/test.cpp b/src/Nerve_GIC/test/test.cpp deleted file mode 100644 index 20e5ee4d..00000000 --- a/src/Nerve_GIC/test/test.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Mathieu Carrière - * - * Copyright (C) 2017 INRIA Saclay (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE "graph_induced_complex" - -#include -#include // float comparison -#include -#include -#include -#include // std::max -#include -#include -#include - -bool are_almost_the_same(float a, float b) { - return std::fabs(a - b) < std::numeric_limits::epsilon(); -} - -BOOST_AUTO_TEST_CASE(check_nerve) { - - Gudhi::graph_induced_complex::Graph_induced_complex GIC; - std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); - std::string cover_file_name("data/cover"); GIC.set_cover_from_file(cover_file_name); - std::string cloud_file_name("data/cloud"); GIC.set_color_from_file(cloud_file_name); - GIC.find_Nerve_simplices(); Simplex_tree stree; GIC.create_complex(stree); - - BOOST_CHECK(stree.num_vertices() == 3); - BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 0); - BOOST_CHECK(stree.dimension() == 0); -} - -BOOST_AUTO_TEST_CASE(check_GICMAP) { - - Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(1); - std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); - std::string cover_file_name("data/cover"); GIC.set_cover_from_file(cover_file_name); - std::string cloud_file_name("data/cloud"); GIC.set_color_from_file(cloud_file_name); - GIC.find_GICMAP_simplices_with_functional_minimal_cover(); Simplex_tree stree; GIC.create_complex(stree); - - BOOST_CHECK(stree.num_vertices() == 3); - BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 2); - BOOST_CHECK(stree.dimension() == 1); -} - -BOOST_AUTO_TEST_CASE(check_GIC) { - - Gudhi::graph_induced_complex::Graph_induced_complex GIC; - std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); - std::string cover_file_name("data/cover"); GIC.set_cover_from_file(cover_file_name); - std::string cloud_file_name("data/cloud"); GIC.set_color_from_file(cloud_file_name); - GIC.find_GIC_simplices(); Simplex_tree stree; GIC.create_complex(stree); - - BOOST_CHECK(stree.num_vertices() == 3); - BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 4); - BOOST_CHECK(stree.dimension() == 2); -} - - diff --git a/src/Nerve_GIC/test/test_GIC.cpp b/src/Nerve_GIC/test/test_GIC.cpp new file mode 100644 index 00000000..1ca44f19 --- /dev/null +++ b/src/Nerve_GIC/test/test_GIC.cpp @@ -0,0 +1,92 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Mathieu Carrière + * + * Copyright (C) 2017 INRIA Saclay (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "graph_induced_complex" + +#include +#include // float comparison +#include +#include +#include +#include // std::max +#include +#include +#include + +bool are_almost_the_same(float a, float b) { + return std::fabs(a - b) < std::numeric_limits::epsilon(); +} + +BOOST_AUTO_TEST_CASE(check_nerve) { + + Gudhi::graph_induced_complex::Graph_induced_complex GIC; + std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); + std::string cover_file_name("data/cover"); GIC.set_cover_from_file(cover_file_name); + std::string cloud_file_name("data/cloud"); GIC.set_color_from_file(cloud_file_name); + GIC.find_Nerve_simplices(); Simplex_tree stree; GIC.create_complex(stree); + + BOOST_CHECK(stree.num_vertices() == 3); + BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 0); + BOOST_CHECK(stree.dimension() == 0); +} + +BOOST_AUTO_TEST_CASE(check_GICMAP) { + + Gudhi::graph_induced_complex::Graph_induced_complex GIC; GIC.set_verbose(1); + std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); + std::string cover_file_name("data/cover"); GIC.set_cover_from_file(cover_file_name); + std::string cloud_file_name("data/cloud"); GIC.set_color_from_file(cloud_file_name); + GIC.find_GICMAP_simplices_with_functional_minimal_cover(); Simplex_tree stree; GIC.create_complex(stree); + + BOOST_CHECK(stree.num_vertices() == 3); + BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 2); + BOOST_CHECK(stree.dimension() == 1); +} + +BOOST_AUTO_TEST_CASE(check_GICcover) { + + Gudhi::graph_induced_complex::Graph_induced_complex GIC; + std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); + std::string cover_file_name("data/cover"); GIC.set_cover_from_file(cover_file_name); + std::string cloud_file_name("data/cloud"); GIC.set_color_from_file(cloud_file_name); + GIC.find_GIC_simplices(); Simplex_tree stree; GIC.create_complex(stree); + + BOOST_CHECK(stree.num_vertices() == 3); + BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 4); + BOOST_CHECK(stree.dimension() == 2); +} + +BOOST_AUTO_TEST_CASE(check_GICvoronoi) { + + Gudhi::graph_induced_complex::Graph_induced_complex GIC; + std::string cloud_file_name("data/cloud"); GIC.set_color_from_coordinate(cloud_file_name); + std::string graph_file_name("data/graph"); GIC.set_graph_from_file(graph_file_name); + GIC.set_cover_from_Voronoi(2,cloud_file_name); + GIC.find_GIC_simplices(); Simplex_tree stree; GIC.create_complex(stree); + + BOOST_CHECK(stree.num_vertices() == 2); + BOOST_CHECK((stree.num_simplices()-stree.num_vertices()) == 1); + BOOST_CHECK(stree.dimension() == 1); +} + + -- cgit v1.2.3