Skip to content

Commit

Permalink
Merge branch 'GUDHI:master' into persistence_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
hschreiber authored Nov 24, 2023
2 parents 750da6e + 36effe9 commit e3bef46
Show file tree
Hide file tree
Showing 56 changed files with 551 additions and 276 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ foreach(GUDHI_MODULE ${GUDHI_MODULES})
endforeach()
endforeach()

if (WITH_GUDHI_THIRD_PARTY)
if (WITH_GUDHI_GUDHUI)
add_subdirectory(src/GudhUI)
endif()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "alpha_complex_dim3_exact_kernel_dynamic"
#include <boost/test/unit_test.hpp>

#include <CGAL/Epeck_d.h>

#include "Alpha_complex_dim3_unit_test.h"

// Use dynamic_dimension_tag for the user to be able to set dimension
typedef CGAL::Epeck_d< CGAL::Dynamic_dimension_tag > Exact_kernel_d;

BOOST_AUTO_TEST_CASE(Alpha_complex_from_OFF_file_exact_kernel_dynamic_dimension) {
test_alpha_complex_from_OFF_file<Exact_kernel_d>();
}

BOOST_AUTO_TEST_CASE(Alpha_complex_from_empty_points_exact_kernel_dynamic_dimension) {
test_alpha_complex_from_empty_points<Exact_kernel_d>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "alpha_complex_dim3_exact_kernel_static"
#include <boost/test/unit_test.hpp>

#include <CGAL/Epeck_d.h>

#include "Alpha_complex_dim3_unit_test.h"

// Use static dimension_tag for the user not to be able to set dimension
typedef CGAL::Epeck_d< CGAL::Dimension_tag<3> > Exact_kernel_s;

BOOST_AUTO_TEST_CASE(Alpha_complex_from_OFF_file_exact_kernel_static_dimension) {
test_alpha_complex_from_OFF_file<Exact_kernel_s>();
}

BOOST_AUTO_TEST_CASE(Alpha_complex_from_empty_points_exact_kernel_static_dimension) {
test_alpha_complex_from_empty_points<Exact_kernel_s>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "alpha_complex_dim3_inexact_kernel_dynamic"
#include <boost/test/unit_test.hpp>

#include <CGAL/Epick_d.h>

#include "Alpha_complex_dim3_unit_test.h"

// Use dynamic_dimension_tag for the user to be able to set dimension
typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Inexact_kernel_d;

BOOST_AUTO_TEST_CASE(Alpha_complex_from_OFF_file_inexact_kernel_dynamic_dimension) {
test_alpha_complex_from_OFF_file<Inexact_kernel_d>();
}

BOOST_AUTO_TEST_CASE(Alpha_complex_from_empty_points_inexact_kernel_dynamic_dimension) {
test_alpha_complex_from_empty_points<Inexact_kernel_d>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau
*
* Copyright (C) 2023 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "alpha_complex_dim3_inexact_kernel_static"
#include <boost/test/unit_test.hpp>

#include <CGAL/Epick_d.h>

#include "Alpha_complex_dim3_unit_test.h"

// Use static dimension_tag for the user not to be able to set dimension
typedef CGAL::Epick_d< CGAL::Dimension_tag<3> > Inexact_kernel_s;

BOOST_AUTO_TEST_CASE(Alpha_complex_from_OFF_file_inexact_kernel_static_dimension) {
test_alpha_complex_from_OFF_file<Inexact_kernel_s>();
}

BOOST_AUTO_TEST_CASE(Alpha_complex_from_empty_points_inexact_kernel_static_dimension) {
test_alpha_complex_from_empty_points<Inexact_kernel_s>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
* Copyright (C) 2015 Inria
*
* Modification(s):
* - 2023/11 Vincent Rouvreau: Split the test
* - YYYY/MM Author: Description of the modification
*/

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "alpha_complex_dim3"
#include <boost/test/unit_test.hpp>
#include <boost/mpl/list.hpp>

#include <CGAL/Epick_d.h>
#include <CGAL/Epeck_d.h>
Expand All @@ -23,7 +21,7 @@
#include <gudhi/Alpha_complex.h>
#include <gudhi/Simplex_tree.h>

// Use dynamic_dimension_tag for the user to be able to set dimension
/*// Use dynamic_dimension_tag for the user to be able to set dimension
typedef CGAL::Epeck_d< CGAL::Dynamic_dimension_tag > Exact_kernel_d;
// Use static dimension_tag for the user not to be able to set dimension
typedef CGAL::Epeck_d< CGAL::Dimension_tag<3> > Exact_kernel_s;
Expand All @@ -34,8 +32,10 @@ typedef CGAL::Epick_d< CGAL::Dimension_tag<3> > Inexact_kernel_s;
// The triangulation uses the default instantiation of the TriangulationDataStructure template parameter
typedef boost::mpl::list<Exact_kernel_d, Exact_kernel_s, Inexact_kernel_d, Inexact_kernel_s> list_of_kernel_variants;
*/

BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_OFF_file, TestedKernel, list_of_kernel_variants) {
template<class CGAL_kernel>
void test_alpha_complex_from_OFF_file() {
// ----------------------------------------------------------------------------
//
// Init of an alpha-complex from a OFF file
Expand All @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_OFF_file, TestedKernel, list_of
std::clog << "========== OFF FILE NAME = " << off_file_name << " - alpha²=" <<
max_alpha_square_value << "==========" << std::endl;

Gudhi::alpha_complex::Alpha_complex<TestedKernel> alpha_complex_from_file(off_file_name);
Gudhi::alpha_complex::Alpha_complex<CGAL_kernel> alpha_complex_from_file(off_file_name);

Gudhi::Simplex_tree<> simplex_tree_60;
BOOST_CHECK(alpha_complex_from_file.create_complex(simplex_tree_60, max_alpha_square_value));
Expand Down Expand Up @@ -84,18 +84,19 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_OFF_file, TestedKernel, list_of
}


BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_empty_points, TestedKernel, list_of_kernel_variants) {
template<class CGAL_kernel>
void test_alpha_complex_from_empty_points() {
std::clog << "========== Alpha_complex_from_empty_points ==========" << std::endl;

// ----------------------------------------------------------------------------
// Init of an empty list of points
// ----------------------------------------------------------------------------
std::vector<typename TestedKernel::Point_d> points;
std::vector<typename CGAL_kernel::Point_d> points;

// ----------------------------------------------------------------------------
// Init of an alpha complex from the list of points
// ----------------------------------------------------------------------------
Gudhi::alpha_complex::Alpha_complex<TestedKernel> alpha_complex_from_points(points);
Gudhi::alpha_complex::Alpha_complex<CGAL_kernel> alpha_complex_from_points(points);

std::clog << "alpha_complex_from_points.num_vertices()=" << alpha_complex_from_points.num_vertices() << std::endl;
BOOST_CHECK(alpha_complex_from_points.num_vertices() == points.size());
Expand Down
20 changes: 16 additions & 4 deletions src/Alpha_complex/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)

add_executable ( Alpha_complex_test_unit Alpha_complex_unit_test.cpp )
target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY})
add_executable ( Alpha_complex_dim3_test_unit Alpha_complex_dim3_unit_test.cpp )
target_link_libraries(Alpha_complex_dim3_test_unit ${CGAL_LIBRARY})
add_executable ( Alpha_complex_dim3_Epeck_dynamic_test_unit Alpha_complex_dim3_Epeck_dynamic_unit_test.cpp )
target_link_libraries(Alpha_complex_dim3_Epeck_dynamic_test_unit ${CGAL_LIBRARY})
add_executable ( Alpha_complex_dim3_Epeck_static_test_unit Alpha_complex_dim3_Epeck_static_unit_test.cpp )
target_link_libraries(Alpha_complex_dim3_Epeck_static_test_unit ${CGAL_LIBRARY})
add_executable ( Alpha_complex_dim3_Epick_dynamic_test_unit Alpha_complex_dim3_Epick_dynamic_unit_test.cpp )
target_link_libraries(Alpha_complex_dim3_Epick_dynamic_test_unit ${CGAL_LIBRARY})
add_executable ( Alpha_complex_dim3_Epick_static_test_unit Alpha_complex_dim3_Epick_static_unit_test.cpp )
target_link_libraries(Alpha_complex_dim3_Epick_static_test_unit ${CGAL_LIBRARY})
add_executable ( Delaunay_complex_Epeck_dynamic_test_unit Delaunay_complex_Epeck_dynamic_unit_test.cpp )
target_link_libraries(Delaunay_complex_Epeck_dynamic_test_unit ${CGAL_LIBRARY})
add_executable ( Delaunay_complex_Epeck_static_test_unit Delaunay_complex_Epeck_static_unit_test.cpp )
Expand All @@ -20,15 +26,21 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
target_link_libraries(Delaunay_complex_Epick_static_test_unit ${CGAL_LIBRARY})
if(TARGET TBB::tbb)
target_link_libraries(Alpha_complex_test_unit TBB::tbb)
target_link_libraries(Alpha_complex_dim3_test_unit TBB::tbb)
target_link_libraries(Alpha_complex_dim3_Epeck_dynamic_test_unit TBB::tbb)
target_link_libraries(Alpha_complex_dim3_Epeck_static_test_unit TBB::tbb)
target_link_libraries(Alpha_complex_dim3_Epick_dynamic_test_unit TBB::tbb)
target_link_libraries(Alpha_complex_dim3_Epick_static_test_unit TBB::tbb)
target_link_libraries(Delaunay_complex_Epeck_dynamic_test_unit TBB::tbb)
target_link_libraries(Delaunay_complex_Epeck_static_test_unit TBB::tbb)
target_link_libraries(Delaunay_complex_Epick_dynamic_test_unit TBB::tbb)
target_link_libraries(Delaunay_complex_Epick_static_test_unit TBB::tbb)
endif()

gudhi_add_boost_test(Alpha_complex_test_unit)
gudhi_add_boost_test(Alpha_complex_dim3_test_unit)
gudhi_add_boost_test(Alpha_complex_dim3_Epeck_dynamic_test_unit)
gudhi_add_boost_test(Alpha_complex_dim3_Epeck_static_test_unit)
gudhi_add_boost_test(Alpha_complex_dim3_Epick_dynamic_test_unit)
gudhi_add_boost_test(Alpha_complex_dim3_Epick_static_test_unit)
gudhi_add_boost_test(Delaunay_complex_Epeck_dynamic_test_unit)
gudhi_add_boost_test(Delaunay_complex_Epeck_static_test_unit)
gudhi_add_boost_test(Delaunay_complex_Epick_dynamic_test_unit)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ foreach(GUDHI_MODULE ${GUDHI_MODULES})
endforeach()
endforeach()

if (WITH_GUDHI_THIRD_PARTY)
if (WITH_GUDHI_GUDHUI)
add_subdirectory(GudhUI)
endif()

Expand Down
4 changes: 2 additions & 2 deletions src/Nerve_GIC/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(TARGET TBB::tbb)
target_link_libraries(VoronoiGIC TBB::tbb)
endif()

file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
file(COPY KeplerMapperVisuFromTxtFile.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
# Copy files for not to pollute sources when testing
file(COPY "${CMAKE_SOURCE_DIR}/data/points/human.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)

Expand All @@ -20,4 +20,4 @@ add_test(NAME Nerve_GIC_utilities_VoronoiGIC COMMAND $<TARGET_FILE:VoronoiGIC>

install(TARGETS Nerve DESTINATION bin)
install(TARGETS VoronoiGIC DESTINATION bin)
install(FILES KeplerMapperVisuFromTxtFile.py km.py km.py.COPYRIGHT DESTINATION bin)
install(FILES KeplerMapperVisuFromTxtFile.py DESTINATION bin)
44 changes: 5 additions & 39 deletions src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python

import km
import numpy as np
from collections import defaultdict
import argparse
from gudhi.cover_complex import _save_to_html

"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
Expand All @@ -30,48 +28,16 @@
args = parser.parse_args()

with open(args.file, 'r') as f:
network = {}
mapper = km.KeplerMapper(verbose=0)
data = np.zeros((3,3))
projected_data = mapper.fit_transform( data, projection="sum", scaler=None )

nodes = defaultdict(list)
links = defaultdict(list)
custom = defaultdict(list)

dat = f.readline()
lens = f.readline()
color = f.readline();
param = [float(i) for i in f.readline().split(" ")]

nums = [int(i) for i in f.readline().split(" ")]
num_nodes = nums[0]
num_edges = nums[1]

for i in range(0,num_nodes):
point = [float(j) for j in f.readline().split(" ")]
nodes[ str(int(point[0])) ] = [ int(point[0]), point[1], int(point[2]) ]
links[ str(int(point[0])) ] = []
custom[ int(point[0]) ] = point[1]

m = min([custom[i] for i in range(0,num_nodes)])
M = max([custom[i] for i in range(0,num_nodes)])

for i in range(0,num_edges):
edge = [int(j) for j in f.readline().split(" ")]
links[ str(edge[0]) ].append( str(edge[1]) )
links[ str(edge[1]) ].append( str(edge[0]) )

network["nodes"] = nodes
network["links"] = links
network["meta"] = lens

points = [[float(j) for j in f.readline().split(" ")] for i in range(0, nums[0])]
edges = [[int(j) for j in f.readline().split(" ")] for i in range(0, nums[1])]
html_output_filename = args.file.rsplit('.', 1)[0] + '.html'
mapper.visualize(network, color_function=color, path_html=html_output_filename, title=dat,
graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=custom, width_html=0,
height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=param[0],gain=param[1], minimum=m,maximum=M)
message = repr(html_output_filename) + " is generated. You can now use your favorite web browser to visualize it."
print(message)


f.close()

_save_to_html(dat, lens, color, param, points, edges, html_output_filename)
10 changes: 5 additions & 5 deletions src/Persistent_cohomology/example/plain_homology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#include <cstdint> // for std::uint8_t

/* We could perfectly well use the default Simplex_tree<> (which uses
* Simplex_tree_options_full_featured), the following simply demonstrates
* Simplex_tree_options_default), the following simply demonstrates
* how to save on storage by not storing a filtration value. */

struct MyOptions : Gudhi::Simplex_tree_options_full_featured {
// Implicitly use 0 as filtration value for all simplices
static const bool store_filtration = false;
// The persistence algorithm needs this
struct MyOptions : Gudhi::Simplex_tree_options_minimal {
// Implicitly use 0 as filtration value for all simplices - inherited from Simplex_tree_options_minimal
// static const bool store_filtration = false;
// However the persistence algorithm needs this
static const bool store_key = true;
// I have few vertices
typedef short Vertex_handle;
Expand Down
2 changes: 1 addition & 1 deletion src/Persistent_cohomology/test/betti_numbers_unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <gudhi/Simplex_tree.h>
#include <gudhi/Persistent_cohomology.h>

struct MiniSTOptions : Gudhi::Simplex_tree_options_full_featured {
struct MiniSTOptions : Gudhi::Simplex_tree_options_minimal {
// Implicitly use 0 as filtration value for all simplices
static const bool store_filtration = false;
// The persistence algorithm needs this
Expand Down
17 changes: 13 additions & 4 deletions src/Simplex_tree/benchmark/simplex_tree_cofaces_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,23 @@ void benchmark_stars_computation(int nb_vertices) {
std::clog << benchmark_cofaces << std::endl;
}

struct Simplex_tree_options_stable_simplex_handles {
struct Stree_basic_cofaces_options {
typedef Gudhi::linear_indexing_tag Indexing_tag;
typedef int Vertex_handle;
typedef double Filtration_value;
typedef std::uint32_t Simplex_key;
static const bool store_key = true;
static const bool store_filtration = true;
static const bool contiguous_vertices = false;
static const bool link_nodes_by_label = false;
static const bool stable_simplex_handles = false;
};

struct Stree_fast_cofaces_options : Stree_basic_cofaces_options {
static const bool link_nodes_by_label = true;
};

struct Stree_fast_cofaces_stable_simplex_handles_options : Stree_basic_cofaces_options {
static const bool link_nodes_by_label = true;
static const bool stable_simplex_handles = true;
};
Expand All @@ -105,13 +114,13 @@ int main(int argc, char *argv[]) {
nb_vertices = atoi(argv[1]);

std::clog << "** Without cofaces computation optimization" << std::endl;
benchmark_stars_computation<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(nb_vertices);
benchmark_stars_computation<Gudhi::Simplex_tree<Stree_basic_cofaces_options>>(nb_vertices);

std::clog << "** With cofaces computation optimization" << std::endl;
benchmark_stars_computation<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_cofaces>>(nb_vertices);
benchmark_stars_computation<Gudhi::Simplex_tree<Stree_fast_cofaces_options>>(nb_vertices);

std::clog << "** With cofaces computation optimization and stable simplex handles" << std::endl;
benchmark_stars_computation<Gudhi::Simplex_tree<Simplex_tree_options_stable_simplex_handles> >(nb_vertices);
benchmark_stars_computation<Gudhi::Simplex_tree<Stree_fast_cofaces_stable_simplex_handles_options> >(nb_vertices);

return EXIT_SUCCESS;
}
Loading

0 comments on commit e3bef46

Please sign in to comment.