summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--biblio/bibliography.bib4
-rw-r--r--src/cython/CMakeLists.txt4
-rw-r--r--src/cython/cython/witness_complex.pyx285
-rw-r--r--src/cython/doc/euclidean_strong_witness_complex_ref.rst10
-rw-r--r--src/cython/doc/euclidean_witness_complex_ref.rst10
-rw-r--r--src/cython/doc/strong_witness_complex_ref.rst10
-rw-r--r--src/cython/doc/witness_complex_sum.rst20
-rw-r--r--src/cython/doc/witness_complex_user.rst86
-rw-r--r--src/cython/include/Witness_complex_interface.h150
9 files changed, 149 insertions, 430 deletions
diff --git a/biblio/bibliography.bib b/biblio/bibliography.bib
index 8e202d32..9d53a628 100644
--- a/biblio/bibliography.bib
+++ b/biblio/bibliography.bib
@@ -976,6 +976,6 @@ language={English}
title={Topological estimation using witness complexes},
author={De Silva, Vin and Carlsson, Gunnar},
journal={Proc. Sympos. Point-Based Graphics},
- pages={157--166},
+ pages={157-166},
year={2004}
-} \ No newline at end of file
+}
diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt
index e1d71c75..bcc1e929 100644
--- a/src/cython/CMakeLists.txt
+++ b/src/cython/CMakeLists.txt
@@ -50,9 +50,13 @@ if(PYTHON_PATH AND CYTHON_PATH)
# Developper version for doc images
file(GLOB GUDHI_DEV_DOC_IMAGES "${CMAKE_SOURCE_DIR}/src/*/doc/*.png")
file(COPY ${GUDHI_DEV_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img")
+ file(GLOB GUDHI_DEV_DOC_IMAGES "${CMAKE_SOURCE_DIR}/src/*/doc/*.svg")
+ file(COPY ${GUDHI_DEV_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img")
# User version for doc images
file(GLOB GUDHI_USER_DOC_IMAGES "${CMAKE_SOURCE_DIR}/doc/*/*.png")
file(COPY ${GUDHI_USER_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img")
+ file(GLOB GUDHI_USER_DOC_IMAGES "${CMAKE_SOURCE_DIR}/doc/*/*.svg")
+ file(COPY ${GUDHI_USER_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img")
# Biblio
file(GLOB GUDHI_BIB_FILES "${CMAKE_SOURCE_DIR}/biblio/*.bib")
file(COPY ${GUDHI_BIB_FILES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/")
diff --git a/src/cython/cython/witness_complex.pyx b/src/cython/cython/witness_complex.pyx
index b2ad4e68..e0d8b1e3 100644
--- a/src/cython/cython/witness_complex.pyx
+++ b/src/cython/cython/witness_complex.pyx
@@ -30,28 +30,10 @@ __license__ = "GPL v3"
cdef extern from "Witness_complex_interface.h" namespace "Gudhi":
cdef cppclass Witness_complex_interface "Gudhi::witness_complex::Witness_complex_interface":
- Witness_complex_interface(vector[vector[double]] points, int number_of_landmarks)
- double filtration()
- double simplex_filtration(vector[int] simplex)
- void set_filtration(double filtration)
- void initialize_filtration()
- int num_vertices()
- int num_simplices()
- void set_dimension(int dimension)
- int dimension()
- bint find_simplex(vector[int] simplex)
- bint insert_simplex_and_subfaces(vector[int] simplex,
- double filtration)
- vector[pair[vector[int], double]] get_filtered_tree()
- vector[pair[vector[int], double]] get_skeleton_tree(int dimension)
- vector[pair[vector[int], double]] get_star_tree(vector[int] simplex)
- vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex,
- int dimension)
- void remove_maximal_simplex(vector[int] simplex)
- vector[double] get_point(int vertex)
- vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence)
- vector[int] get_betti_numbers()
- vector[int] get_persistent_betti_numbers(double from_value, double to_value)
+ Witness_complex_interface(vector[vector[pair[size_t, double]]] nearest_landmark_table)
+ void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square)
+ void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square,
+ unsigned limit_dimension)
# WitnessComplex python interface
cdef class WitnessComplex:
@@ -65,258 +47,35 @@ cdef class WitnessComplex:
def __init__(self, points=None, number_of_landmarks=5):
"""WitnessComplex constructor.
- :param points: A list of points in d-Dimension.
- :type points: list of list of double
- :param number_of_landmarks: Number of landmarks to build the
- WitnessComplex.
- :type number_of_landmarks: int
+ :param nearest_landmark_table: A list of nearest landmark.
+ :type nearest_landmark_table: list of list of pair of unsigned and double
"""
# The real cython constructor
- def __cinit__(self, points=None, number_of_landmarks=5):
- if points is not None:
- self.thisptr = new Witness_complex_interface(points,
- number_of_landmarks)
+ def __cinit__(self, nearest_landmark_table=None):
+ if nearest_landmark_table is not None:
+ self.thisptr = new Witness_complex_interface(nearest_landmark_table)
def __dealloc__(self):
if self.thisptr != NULL:
del self.thisptr
def __is_defined(self):
- """Returns true if AlphaComplex pointer is not NULL.
+ """Returns true if WitnessComplex pointer is not NULL.
"""
return self.thisptr != NULL
- def get_filtration(self):
- """This function returns the main simplicial complex filtration value.
-
- :returns: float -- the simplicial complex filtration value.
- """
- return self.thisptr.filtration()
-
- def filtration(self, simplex):
- """This function returns the simplicial complex filtration value for a
- given N-simplex.
-
- :param simplex: The N-simplex, represented by a list of vertex.
- :type simplex: list of int.
- :returns: float -- the simplicial complex filtration value.
- """
- return self.thisptr.simplex_filtration(simplex)
-
- def set_filtration(self, filtration):
- """This function sets the main simplicial complex filtration value.
-
- :param filtration: The filtration value.
- :type filtration: float.
- """
- self.thisptr.set_filtration(<double> filtration)
-
- def initialize_filtration(self):
- """This function initializes and sorts the simplicial complex
- filtration vector.
-
- .. note::
-
- This function must be launched before persistence, betti_numbers,
- persistent_betti_numbers or get_filtered_tree after inserting or
- removing simplices.
- """
- self.thisptr.initialize_filtration()
-
- def num_vertices(self):
- """This function returns the number of vertices of the simplicial
- complex.
-
- :returns: int -- the simplicial complex number of vertices.
+ def create_simplex_tree(self, max_alpha_square, limit_dimension = -1):
"""
- return self.thisptr.num_vertices()
-
- def num_simplices(self):
- """This function returns the number of simplices of the simplicial
- complex.
-
- :returns: int -- the simplicial complex number of simplices.
- """
- return self.thisptr.num_simplices()
-
- def dimension(self):
- """This function returns the dimension of the simplicial complex.
-
- :returns: int -- the simplicial complex dimension.
- """
- return self.thisptr.dimension()
-
- def set_dimension(self, dimension):
- """This function sets the dimension of the simplicial complex.
-
- :param dimension: The new dimension value.
- :type dimension: int.
- """
- self.thisptr.set_dimension(<int>dimension)
-
- def find(self, simplex):
- """This function returns if the N-simplex was found in the simplicial
- complex or not.
-
- :param simplex: The N-simplex to find, represented by a list of vertex.
- :type simplex: list of int.
- :returns: bool -- true if the simplex was found, false otherwise.
- """
- cdef vector[int] complex
- for i in simplex:
- complex.push_back(i)
- return self.thisptr.find_simplex(complex)
-
- def insert(self, simplex, filtration=0.0):
- """This function inserts the given N-simplex with the given filtration
- value (default value is '0.0').
-
- :param simplex: The N-simplex to insert, represented by a list of
- vertex.
- :type simplex: list of int.
- :param filtration: The filtration value of the simplex.
- :type filtration: float.
- :returns: bool -- true if the simplex was found, false otherwise.
- """
- cdef vector[int] complex
- for i in simplex:
- complex.push_back(i)
- return self.thisptr.insert_simplex_and_subfaces(complex,
- <double>filtration)
-
- def get_filtered_tree(self):
- """This function returns the tree sorted by increasing filtration
- values.
-
- :returns: list of tuples(simplex, filtration) -- the tree sorted by
- increasing filtration values.
- """
- cdef vector[pair[vector[int], double]] coface_tree \
- = self.thisptr.get_filtered_tree()
- ct = []
- for filtered_complex in coface_tree:
- v = []
- for vertex in filtered_complex.first:
- v.append(vertex)
- ct.append((v, filtered_complex.second))
- return ct
-
- def get_skeleton_tree(self, dimension):
- """This function returns the tree skeleton of a maximum given
- dimension.
-
- :param dimension: The skeleton dimension value.
- :type dimension: int.
- :returns: list of tuples(simplex, filtration) -- the skeleton tree
- of a maximum dimension.
- """
- cdef vector[pair[vector[int], double]] coface_tree \
- = self.thisptr.get_skeleton_tree(<int>dimension)
- ct = []
- for filtered_complex in coface_tree:
- v = []
- for vertex in filtered_complex.first:
- v.append(vertex)
- ct.append((v, filtered_complex.second))
- return ct
-
- def get_star_tree(self, simplex):
- """This function returns the star tree of a given N-simplex.
-
- :param simplex: The N-simplex, represented by a list of vertex.
- :type simplex: list of int.
- :returns: list of tuples(simplex, filtration) -- the star tree of a
- simplex.
- """
- cdef vector[int] complex
- for i in simplex:
- complex.push_back(i)
- cdef vector[pair[vector[int], double]] coface_tree \
- = self.thisptr.get_star_tree(complex)
- ct = []
- for filtered_complex in coface_tree:
- v = []
- for vertex in filtered_complex.first:
- v.append(vertex)
- ct.append((v, filtered_complex.second))
- return ct
-
- def get_coface_tree(self, simplex, codimension):
- """This function returns the coface tree of a given N-simplex with a
- given codimension.
-
- :param simplex: The N-simplex, represented by a list of vertex.
- :type simplex: list of int.
- :param codimension: The codimension. If codimension = 0, all cofaces
- are returned (equivalent of get_star_tree function)
- :type codimension: int.
- :returns: list of tuples(simplex, filtration) -- the coface tree of a
- simplex.
- """
- cdef vector[int] complex
- for i in simplex:
- complex.push_back(i)
- cdef vector[pair[vector[int], double]] coface_tree \
- = self.thisptr.get_coface_tree(complex, <int>codimension)
- ct = []
- for filtered_complex in coface_tree:
- v = []
- for vertex in filtered_complex.first:
- v.append(vertex)
- ct.append((v, filtered_complex.second))
- return ct
-
- def remove_maximal_simplex(self, simplex):
- """This function removes a given maximal N-simplex from the simplicial
- complex.
-
- :param simplex: The N-simplex, represented by a list of vertex.
- :type simplex: list of int.
- """
- self.thisptr.remove_maximal_simplex(simplex)
-
- def persistence(self, homology_coeff_field=11, min_persistence=0):
- """This function returns the persistence of the simplicial complex.
-
- :param homology_coeff_field: The homology coefficient field. Must be a
- prime number
- :type homology_coeff_field: int.
- :param min_persistence: The minimum persistence value to take into
- account (strictly greater than min_persistence). Default value is
- 0.0.
- Sets min_persistence to -1.0 to see all values.
- :type min_persistence: float.
- :note: list of pairs(dimension, pair(birth, death)) -- the
- persistence of the simplicial complex.
- """
- return self.thisptr.get_persistence(homology_coeff_field, min_persistence)
-
- def betti_numbers(self):
- """This function returns the Betti numbers of the simplicial complex.
-
- :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]).
-
- :note: betti_numbers function requires persistence function to be
- launched first.
- """
- return self.thisptr.get_betti_numbers()
-
- def persistent_betti_numbers(self, from_value, to_value):
- """This function returns the persistent Betti numbers of the
- simplicial complex.
-
- :param from_value: The persistence birth limit to be added in the
- numbers (persistent birth <= from_value).
- :type from_value: float.
- :param to_value: The persistence death limit to be added in the
- numbers (persistent death > to_value).
- :type to_value: float.
-
- :returns: list of int -- The persistent Betti numbers ([B0, B1, ...,
- Bn]).
-
- :note: persistent_betti_numbers function requires persistence
- function to be launched first.
+ :param max_alpha_square: The maximum alpha square threshold the
+ simplices shall not exceed. Default is set to infinity.
+ :type max_alpha_square: float
+ :returns: A simplex tree created from the Delaunay Triangulation.
+ :rtype: SimplexTree
"""
- return self.thisptr.get_persistent_betti_numbers(from_value, to_value)
+ simplex_tree = SimplexTree()
+ if limit_dimension is not -1:
+ self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension)
+ else:
+ self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square)
+ return simplex_tree
diff --git a/src/cython/doc/euclidean_strong_witness_complex_ref.rst b/src/cython/doc/euclidean_strong_witness_complex_ref.rst
new file mode 100644
index 00000000..bebf0f9a
--- /dev/null
+++ b/src/cython/doc/euclidean_strong_witness_complex_ref.rst
@@ -0,0 +1,10 @@
+=================================================
+Euclidean strong witness complex reference manual
+=================================================
+
+.. autoclass:: gudhi.EuclideanStrongWitnessComplex
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+ .. automethod:: gudhi.EuclideanStrongWitnessComplex.__init__
diff --git a/src/cython/doc/euclidean_witness_complex_ref.rst b/src/cython/doc/euclidean_witness_complex_ref.rst
new file mode 100644
index 00000000..29b8806f
--- /dev/null
+++ b/src/cython/doc/euclidean_witness_complex_ref.rst
@@ -0,0 +1,10 @@
+==========================================
+Euclidean witness complex reference manual
+==========================================
+
+.. autoclass:: gudhi.EuclideanWitnessComplex
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+ .. automethod:: gudhi.EuclideanWitnessComplex.__init__
diff --git a/src/cython/doc/strong_witness_complex_ref.rst b/src/cython/doc/strong_witness_complex_ref.rst
new file mode 100644
index 00000000..4ed4fe46
--- /dev/null
+++ b/src/cython/doc/strong_witness_complex_ref.rst
@@ -0,0 +1,10 @@
+=======================================
+Strong witness complex reference manual
+=======================================
+
+.. autoclass:: gudhi.StrongWitnessComplex
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+ .. automethod:: gudhi.StrongWitnessComplex.__init__
diff --git a/src/cython/doc/witness_complex_sum.rst b/src/cython/doc/witness_complex_sum.rst
index 1b20d4bc..b65522ba 100644
--- a/src/cython/doc/witness_complex_sum.rst
+++ b/src/cython/doc/witness_complex_sum.rst
@@ -1,25 +1,17 @@
================================================================= =================================== ===================================
:Author: Siargey Kachanovich :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3
+:Euclidean version requires: CGAL :math:`\geq` 4.6.0 Eigen3
================================================================= =================================== ===================================
+-----------------------------------------------------------------+----------------------------------------------------------------------+
| .. image:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on |
-| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`:Wit(W,L)` is a simplicial |
-| | complex defined on two sets of points in :math:`\mathbb{R}^D`: |
-| | |
-| | * :math:`W` set of **witnesses** and |
-| | * :math:`L \subseteq W` set of **landmarks**. |
-| | |
-| | The simplices are based on landmarks and a simplex belongs to the |
-| | witness complex if and only if it is witnessed, that is: |
-| | |
-| | :math:`\sigma \subset L` is witnessed if there exists a point |
-| | :math:`w \in W` such that w is closer to the vertices of |
-| | :math:`\sigma` than other points in :math:`L` and all of its faces |
-| | are witnessed as well. |
+| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. |
| | |
| | The data structure is described in |
| | :cite:`boissonnatmariasimplextreealgorithmica`. |
+-----------------------------------------------------------------+----------------------------------------------------------------------+
-| :doc:`witness_complex_user` | :doc:`witness_complex_ref` |
+| :doc:`witness_complex_user` | * :doc:`witness_complex_ref` |
+| | * :doc:`strong_witness_complex_ref` |
+| | * :doc:`euclidean_witness_complex_ref` |
+| | * :doc:`euclidean_strong_witness_complex_ref` |
+-----------------------------------------------------------------+----------------------------------------------------------------------+
diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst
index 604c7357..071d8ef5 100644
--- a/src/cython/doc/witness_complex_user.rst
+++ b/src/cython/doc/witness_complex_user.rst
@@ -6,26 +6,80 @@ Definition
.. include:: witness_complex_sum.rst
+
+Definitions
+-----------
+
+Witness complex is a simplicial complex defined on two sets of points in :math:`\mathbb{R}^D`:
+
+- :math:`W` set of **witnesses** and
+- :math:`L` set of **landmarks**.
+
+Even though often the set of landmarks :math:`L` is a subset of the set of witnesses :math:`W`, it is not a requirement
+for the current implementation.
+
+Landmarks are the vertices of the simplicial complex and witnesses help to decide on which simplices are inserted via a
+predicate "is witnessed".
+
+De Silva and Carlsson in their paper :cite:`de2004topological` differentiate **weak witnessing** and
+**strong witnessing**:
+
+- *weak*: :math:`\sigma \subset L` is witnessed by :math:`w \in W` if :math:`\forall l \in \sigma,\ \forall l' \in \mathbf{L \setminus \sigma},\ d(w,l) \leq d(w,l')`
+- *strong*: :math:`\sigma \subset L` is witnessed by :math:`w \in W` if :math:`\forall l \in \sigma,\ \forall l' \in \mathbf{L},\ d(w,l) \leq d(w,l')`
+
+where :math:`d(.,.)` is a distance function.
+
+Both definitions can be relaxed by a real value :math:`\alpha`:
+
+- *weak*: :math:`\sigma \subset L` is :math:`\alpha`-witnessed by :math:`w \in W` if :math:`\forall l \in \sigma,\ \forall l' \in \mathbf{L \setminus \sigma},\ d(w,l)^2 \leq d(w,l')^2 + \alpha^2`
+- *strong*: :math:`\sigma \subset L` is :math:`\alpha`-witnessed by :math:`w \in W` if :math:`\forall l \in \sigma,\ \forall l' \in \mathbf{L},\ d(w,l)^2 \leq d(w,l')^2 + \alpha^2`
+
+which leads to definitions of **weak relaxed witness complex** (or just relaxed witness complex for short) and
+**strong relaxed witness complex** respectively.
+
+.. figure:: img/swit.svg
+ :alt: Strongly witnessed simplex
+ :figclass: align-center
+
+ Strongly witnessed simplex
+
+
+In particular case of 0-relaxation, weak complex corresponds to **witness complex** introduced in
+:cite:`de2004topological`, whereas 0-relaxed strong witness complex consists of just vertices and is not very
+interesting. Hence for small relaxation weak version is preferable.
+However, to capture the homotopy type (for example using Gudhi::persistent_cohomology::Persistent_cohomology) it is
+often necessary to work with higher filtration values. In this case strong relaxed witness complex is faster to compute
+and offers similar results.
+
Implementation
--------------
-The principal class of this module is Gudhi::Witness_complex.
+The two complexes described above are implemented in the corresponding classes
+
+- :doc:`witness_complex_ref`
+- :doc:`strong_witness_complex_ref`
+- :doc:`euclidean_witness_complex_ref`
+- :doc:`euclidean_strong_witness_complex_ref`
+
+The construction of the Euclidean versions of complexes follow the same scheme:
+
+1. Construct a search tree on landmarks.
+2. Construct lists of nearest landmarks for each witness.
+3. Construct the witness complex for nearest landmark lists.
+
+In the non-Euclidean classes, the lists of nearest landmarks are supposed to be given as input.
+
+The constructors take on the steps 1 and 2, while the function 'create_complex' executes the step 3.
+
+Constructing weak relaxed witness complex from an off file
+----------------------------------------------------------
+
+Let's start with a simple example, which reads an off point file and computes a weak witness complex.
-In both cases, the constructor for this class takes a {witness}x{closest_landmarks} table, where each row represents a
-witness and consists of landmarks sorted by distance to this witness.
+Example2: Computing persistence using strong relaxed witness complex
+--------------------------------------------------------------------
-.. todo::
- This table can be constructed by two additional classes Landmark_choice_by_furthest_point and
- Landmark_choice_by_random_point also included in the module.
+Here is an example of constructing a strong witness complex filtration and computing persistence on it:
-.. figure::
- img/bench_Cy8.png
- :align: center
-
- Running time as function on number of landmarks.
+.. include:: biblio.rst
-.. figure::
- img/bench_sphere.png
- :align: center
-
- Running time as function on number of witnesses for |L|=300.
diff --git a/src/cython/include/Witness_complex_interface.h b/src/cython/include/Witness_complex_interface.h
index a753bc1d..38661cb6 100644
--- a/src/cython/include/Witness_complex_interface.h
+++ b/src/cython/include/Witness_complex_interface.h
@@ -25,161 +25,41 @@
#include <gudhi/Simplex_tree.h>
#include <gudhi/Witness_complex.h>
-#include <gudhi/Construct_closest_landmark_table.h>
-#include <gudhi/pick_n_random_points.h>
-#include "Persistent_cohomology_interface.h"
+#include "Simplex_tree_interface.h"
#include <vector>
#include <utility> // std::pair
#include <iostream>
+#include <cstddef>
namespace Gudhi {
namespace witness_complex {
class Witness_complex_interface {
- typedef typename Simplex_tree<>::Simplex_handle Simplex_handle;
- typedef typename Simplex_tree<>::Filtration_value Filtration_value;
- typedef typename Simplex_tree<>::Vertex_handle Vertex_handle;
- typedef typename std::pair<Simplex_handle, bool> Insertion_result;
- using Simplex = std::vector<Vertex_handle>;
- using Filtered_complex = std::pair<Simplex, Filtration_value>;
- using Complex_tree = std::vector<Filtered_complex>;
+ using Nearest_landmark_range = std::vector<std::pair<std::size_t, double>>;
+ using Nearest_landmark_table = std::vector<Nearest_landmark_range>;
public:
- Witness_complex_interface(std::vector<std::vector<double>>&points, int number_of_landmarks)
- : pcoh_(nullptr) {
- std::vector<std::vector< int > > knn;
- std::vector<std::vector<double>> landmarks;
- Gudhi::subsampling::pick_n_random_points(points, number_of_landmarks, std::back_inserter(landmarks));
- Gudhi::witness_complex::construct_closest_landmark_table<Filtration_value>(points, landmarks, knn);
-
- Gudhi::witness_complex::witness_complex(knn, number_of_landmarks, points[0].size(), simplex_tree_);
+ Witness_complex_interface(Nearest_landmark_table& nlt) {
+ witness_complex_ = new Witness_complex<Nearest_landmark_table>(nlt);
}
- bool find_simplex(const Simplex& vh) {
- return (simplex_tree_.find(vh) != simplex_tree_.null_simplex());
+ void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square,
+ std::size_t limit_dimension) {
+ witness_complex_->create_complex(*simplex_tree, max_alpha_square, limit_dimension);
+ simplex_tree->initialize_filtration();
}
- bool insert_simplex_and_subfaces(const Simplex& complex, Filtration_value filtration = 0) {
- Insertion_result result = simplex_tree_.insert_simplex_and_subfaces(complex, filtration);
- return (result.second);
+ void create_simplex_tree(Simplex_tree_interface<>* simplex_tree,
+ double max_alpha_square) {
+ witness_complex_->create_complex(*simplex_tree, max_alpha_square, std::numeric_limits<std::size_t>::max());
+ simplex_tree->initialize_filtration();
}
- Filtration_value simplex_filtration(const Simplex& complex) {
- return simplex_tree_.filtration(simplex_tree_.find(complex));
- }
-
- void remove_maximal_simplex(const Simplex& complex) {
- return simplex_tree_.remove_maximal_simplex(simplex_tree_.find(complex));
- }
-
- Complex_tree get_filtered_tree() {
- Complex_tree filtered_tree;
- for (auto f_simplex : simplex_tree_.filtration_simplex_range()) {
- Simplex simplex;
- for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
- }
- filtered_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex)));
- }
- return filtered_tree;
-
- }
-
- Complex_tree get_skeleton_tree(int dimension) {
- Complex_tree skeleton_tree;
- for (auto f_simplex : simplex_tree_.skeleton_simplex_range(dimension)) {
- Simplex simplex;
- for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
- }
- skeleton_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex)));
- }
- return skeleton_tree;
- }
-
- Complex_tree get_star_tree(const Simplex& complex) {
- Complex_tree star_tree;
- for (auto f_simplex : simplex_tree_.star_simplex_range(simplex_tree_.find(complex))) {
- Simplex simplex;
- for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
- }
- star_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex)));
- }
- return star_tree;
- }
-
- Complex_tree get_coface_tree(const Simplex& complex, int dimension) {
- Complex_tree coface_tree;
- for (auto f_simplex : simplex_tree_.cofaces_simplex_range(simplex_tree_.find(complex), dimension)) {
- Simplex simplex;
- for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
- }
- coface_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex)));
- }
- return coface_tree;
- }
-
- // Specific to Witness complex because no inheritance
- Filtration_value filtration() const {
- return simplex_tree_.filtration();
- }
-
- void set_filtration(Filtration_value fil) {
- simplex_tree_.set_filtration(fil);
- }
-
- void initialize_filtration() {
- simplex_tree_.initialize_filtration();
- }
-
- size_t num_vertices() const {
- return simplex_tree_.num_vertices();
- }
-
- size_t num_simplices() {
- return simplex_tree_.num_simplices();
- }
-
- int dimension() const {
- return simplex_tree_.dimension();
- }
-
- void set_dimension(int dimension) {
- simplex_tree_.set_dimension(dimension);
- }
-
- std::vector<std::pair<int, std::pair<double, double>>> get_persistence(int homology_coeff_field, double min_persistence) {
- if (pcoh_ != nullptr) {
- delete pcoh_;
- }
- pcoh_ = new Persistent_cohomology_interface<Simplex_tree<>>(&simplex_tree_);
- return pcoh_->get_persistence(homology_coeff_field, min_persistence);
- }
-
- std::vector<int> get_betti_numbers() const {
- if (pcoh_ != nullptr) {
- return pcoh_->betti_numbers();
- }
- std::vector<int> betti_numbers;
- return betti_numbers;
- }
-
- std::vector<int> get_persistent_betti_numbers(Filtration_value from, Filtration_value to) const {
- if (pcoh_ != nullptr) {
- return pcoh_->persistent_betti_numbers(from, to);
- }
- std::vector<int> persistent_betti_numbers;
- return persistent_betti_numbers;
- }
-
private:
- Simplex_tree<> simplex_tree_;
- Persistent_cohomology_interface<Simplex_tree<>>* pcoh_;
+ Witness_complex<Nearest_landmark_table>* witness_complex_;
};