| 1 |
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. |
| 2 |
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. |
| 3 |
* Author(s): Clément Maria |
| 4 |
* |
| 5 |
* Copyright (C) 2014 Inria |
| 6 |
* |
| 7 |
* Modification(s): |
| 8 |
* - YYYY/MM Author: Description of the modification |
| 9 |
*/ |
| 10 |
|
| 11 |
#ifndef DOC_PERSISTENT_COHOMOLOGY_INTRO_PERSISTENT_COHOMOLOGY_H_ |
| 12 |
#define DOC_PERSISTENT_COHOMOLOGY_INTRO_PERSISTENT_COHOMOLOGY_H_ |
| 13 |
|
| 14 |
// needs namespace for Doxygen to link on classes |
| 15 |
namespace Gudhi { |
| 16 |
// needs namespace for Doxygen to link on classes |
| 17 |
namespace persistent_cohomology { |
| 18 |
|
| 19 |
/** \defgroup persistent_cohomology Persistent Cohomology |
| 20 |
|
| 21 |
\author Clément Maria |
| 22 |
|
| 23 |
Computation of persistent cohomology using the algorithm of |
| 24 |
\cite DBLP:journals/dcg/SilvaMV11 and \cite DBLP:conf/compgeom/DeyFW14 |
| 25 |
and the Compressed Annotation Matrix |
| 26 |
implementation of \cite DBLP:conf/esa/BoissonnatDM13 . Some \ref specialcasepersistence "special cases" |
| 27 |
using different algorithms are also provided at the end of this page. |
| 28 |
|
| 29 |
The theory of homology consists in attaching to a topological space a sequence of |
| 30 |
(homology) groups, |
| 31 |
capturing global topological features |
| 32 |
like connected components, holes, cavities, etc. Persistent homology studies the evolution |
| 33 |
-- birth, life and death -- of |
| 34 |
these features when the topological space is changing. Consequently, the theory is essentially |
| 35 |
composed of three elements: |
| 36 |
topological spaces, their homology groups and an evolution scheme. |
| 37 |
|
| 38 |
\section persistencetopolocalspaces Topological Spaces |
| 39 |
Topological spaces are represented by simplicial complexes. |
| 40 |
Let \f$V = \{1, \cdots ,|V|\}\f$ be a set of <EM>vertices</EM>. |
| 41 |
A <EM>simplex</EM> \f$\sigma\f$ is a subset of vertices |
| 42 |
\f$\sigma \subseteq V\f$. A <EM>simplicial complex</EM> \f$\mathbf{K}\f$ |
| 43 |
on \f$V\f$ is a collection of simplices \f$\{\sigma\}\f$, |
| 44 |
\f$\sigma \subseteq V\f$, such that \f$\tau \subseteq \sigma \in \mathbf{K} |
| 45 |
\Rightarrow \tau \in \mathbf{K}\f$. The dimension \f$n=|\sigma|-1\f$ of \f$\sigma\f$ |
| 46 |
is its number of elements minus 1. A <EM>filtration</EM> of a simplicial complex is |
| 47 |
a function \f$f:\mathbf{K} \rightarrow \mathbb{R}\f$ satisfying \f$f(\tau)\leq |
| 48 |
f(\sigma)\f$ whenever \f$\tau \subseteq \sigma\f$. |
| 49 |
|
| 50 |
We define the concept FilteredComplex which enumerates the requirements for a class |
| 51 |
to represent a filtered complex from which persistent homology may be computed. |
| 52 |
We use the vocabulary of simplicial complexes, but the concept |
| 53 |
is valid for any type of cell complex. The main requirements |
| 54 |
are the definition of: |
| 55 |
\li type <CODE>Indexing_tag</CODE>, which is a model of the concept |
| 56 |
<CODE>IndexingTag</CODE>, |
| 57 |
describing the nature of the indexing scheme, |
| 58 |
\li type Simplex_handle to manipulate simplices, |
| 59 |
\li method <CODE>int dimension(Simplex_handle)</CODE> returning |
| 60 |
the dimension of a simplex, |
| 61 |
\li type and method <CODE>Boundary_simplex_range |
| 62 |
boundary_simplex_range(Simplex_handle)</CODE> that returns |
| 63 |
a range giving access to the codimension 1 subsimplices of the |
| 64 |
input simplex, as-well-as the coefficients \f$(-1)^i\f$ in the |
| 65 |
definition of the operator \f$\partial\f$. The iterators have |
| 66 |
value type <CODE>Simplex_handle</CODE>, |
| 67 |
\li type and method |
| 68 |
<CODE>Filtration_simplex_range filtration_simplex_range ()</CODE> |
| 69 |
that returns a range giving |
| 70 |
access to all the simplices of the complex read in the order |
| 71 |
assigned by the indexing scheme, |
| 72 |
\li type and method |
| 73 |
<CODE>Filtration_value filtration (Simplex_handle)</CODE> that returns the value of |
| 74 |
the filtration on the simplex represented by the handle. |
| 75 |
|
| 76 |
\section persistencehomology Homology |
| 77 |
For a ring \f$\mathcal{R}\f$, the group of <EM>n-chains</EM>, |
| 78 |
denoted \f$\mathbf{C}_n(\mathbf{K},\mathcal{R})\f$, of \f$\mathbf{K}\f$ is the |
| 79 |
group of formal sums of |
| 80 |
n-simplices with \f$\mathcal{R}\f$ coefficients. The <EM>boundary operator</EM> is a |
| 81 |
linear operator |
| 82 |
\f$\partial_n: \mathbf{C}_n(\mathbf{K},\mathcal{R}) \rightarrow \mathbf{C}_{n-1}(\mathbf{K},\mathcal{R})\f$ |
| 83 |
such that \f$\partial_n \sigma = \partial_n [v_0, \cdots , v_n] = |
| 84 |
\sum_{i=0}^n (-1)^{i}[v_0,\cdots ,\widehat{v_i}, \cdots,v_n]\f$, |
| 85 |
where \f$\widehat{v_i}\f$ means \f$v_i\f$ is omitted from the list. The chain |
| 86 |
groups form a sequence: |
| 87 |
|
| 88 |
\f[\cdots \ \ \mathbf{C}_n(\mathbf{K},\mathcal{R}) \xrightarrow{\ \partial_n\ } \mathbf{C}_{n-1}(\mathbf{K},\mathcal{R}) |
| 89 |
\xrightarrow{\partial_{n-1}} \cdots \xrightarrow{\ \partial_2 \ } |
| 90 |
\mathbf{C}_1(\mathbf{K},\mathcal{R}) \xrightarrow{\ \partial_1 \ } \mathbf{C}_0(\mathbf{K},\mathcal{R}) \f] |
| 91 |
|
| 92 |
of finitely many groups \f$\mathbf{C}_n(\mathbf{K},\mathcal{R})\f$ and homomorphisms |
| 93 |
\f$\partial_n\f$, indexed by the dimension \f$n \geq 0\f$. |
| 94 |
The boundary operators satisfy the property \f$\partial_n \circ \partial_{n+1}=0\f$ |
| 95 |
for every \f$n > 0\f$ |
| 96 |
and we define the homology groups: |
| 97 |
|
| 98 |
\f[\mathbf{H}_n(\mathbf{K},\mathcal{R}) = \ker \partial_n / \mathrm{im} \ \partial_{n+1}\f] |
| 99 |
|
| 100 |
We refer to \cite Munkres-elementsalgtop1984 for an introduction to homology |
| 101 |
theory and to \cite DBLP:books/daglib/0025666 for an introduction to persistent homology. |
| 102 |
|
| 103 |
\section persistenceindexingscheme Indexing Scheme |
| 104 |
"Changing" a simplicial complex consists in applying a simplicial map. |
| 105 |
An <EM>indexing scheme</EM> is a directed graph together with a traversal |
| 106 |
order, such that two |
| 107 |
consecutive nodes in the graph are connected by an arrow (either forward or backward). |
| 108 |
The nodes represent simplicial complexes and the directed edges simplicial maps. |
| 109 |
|
| 110 |
From the computational point of view, there are two types of indexing schemes of |
| 111 |
interest |
| 112 |
in persistent homology: <EM>linear</EM> ones |
| 113 |
\f$\bullet \longrightarrow \bullet \longrightarrow \cdots \longrightarrow \bullet |
| 114 |
\longrightarrow \bullet\f$ |
| 115 |
in persistent homology \cite DBLP:journals/dcg/ZomorodianC05 , |
| 116 |
and <EM>zigzag</EM> ones |
| 117 |
\f$\bullet \longrightarrow \bullet \longleftarrow \cdots |
| 118 |
\longrightarrow \bullet |
| 119 |
\longleftarrow \bullet \f$ in zigzag persistent |
| 120 |
homology \cite DBLP:journals/focm/CarlssonS10. |
| 121 |
These indexing schemes have a natural left-to-right traversal order, and we |
| 122 |
describe them with ranges and iterators. |
| 123 |
In the current release of the Gudhi library, only the linear case is implemented. |
| 124 |
|
| 125 |
In the following, we consider the case where the indexing scheme is induced |
| 126 |
by a filtration. |
| 127 |
Ordering the simplices |
| 128 |
by increasing filtration values (breaking ties so as a simplex appears after |
| 129 |
its subsimplices of same filtration value) provides an indexing scheme. |
| 130 |
|
| 131 |
\section pcohexamples Examples |
| 132 |
|
| 133 |
We provide several example files: run these examples with -h for details on their use, and read the README file. |
| 134 |
|
| 135 |
\li \gudhi_example_link{Rips_complex,rips_persistence.cpp} computes the Rips complex of a point cloud and outputs its persistence |
| 136 |
diagram. |
| 137 |
\code $> ./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 \endcode |
| 138 |
\code The complex contains 177838 simplices |
| 139 |
and has dimension 3 |
| 140 |
3 0 0 inf |
| 141 |
3 1 0.0983494 inf |
| 142 |
3 1 0.104347 inf |
| 143 |
3 2 0.138335 inf \endcode |
| 144 |
|
| 145 |
More details on the <a href="../../ripscomplex/">Rips complex utilities</a> dedicated page. |
| 146 |
|
| 147 |
\li \gudhi_example_link{Persistent_cohomology,rips_multifield_persistence.cpp} computes the Rips complex of a point cloud and outputs its |
| 148 |
persistence diagram with a family of field coefficients. |
| 149 |
|
| 150 |
\li \gudhi_example_link{Rips_complex,rips_distance_matrix_persistence.cpp} computes the Rips complex of a distance matrix and |
| 151 |
outputs its persistence diagram. |
| 152 |
|
| 153 |
The file should contain square or lower triangular distance matrix with semicolons as separators. |
| 154 |
The code do not check if it is dealing with a distance matrix. It is the user responsibility to provide a valid input. |
| 155 |
Please refer to data/distance_matrix/lower_triangular_distance_matrix.csv for an example of a file. |
| 156 |
|
| 157 |
More details on the <a href="../../ripscomplex/">Rips complex utilities</a> dedicated page. |
| 158 |
|
| 159 |
\li \gudhi_example_link{Rips_complex,rips_correlation_matrix_persistence.cpp} |
| 160 |
computes the Rips complex of a correlation matrix and outputs its persistence diagram. |
| 161 |
|
| 162 |
Note that no check is performed if the matrix given as the input is a correlation matrix. |
| 163 |
It is the user responsibility to ensure that this is the case. The input is to be given either as a square or a lower |
| 164 |
triangular matrix. |
| 165 |
Please refer to data/correlation_matrix/lower_triangular_correlation_matrix.csv for an example of a file. |
| 166 |
|
| 167 |
More details on the <a href="../../ripscomplex/">Rips complex utilities</a> dedicated page. |
| 168 |
|
| 169 |
\li \gudhi_example_link{Alpha_complex,alpha_complex_3d_persistence.cpp} computes the persistent homology with |
| 170 |
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. |
| 171 |
\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 \endcode |
| 172 |
\code Simplex_tree dim: 3 |
| 173 |
2 0 0 inf |
| 174 |
2 1 0.0682162 1.0001 |
| 175 |
2 1 0.0934117 1.00003 |
| 176 |
2 2 0.56444 1.03938 \endcode |
| 177 |
|
| 178 |
More details on the <a href="../../alphacomplex/">Alpha complex utilities</a> dedicated page. |
| 179 |
|
| 180 |
CGAL can be forced to compute the exact values, it is slower, but it is necessary when points are on a grid |
| 181 |
for instance (the fast version `--fast` would give incorrect values). |
| 182 |
\code $> ./alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off --exact -p 2 -m 0.1 \endcode |
| 183 |
\code Simplex_tree dim: 3 |
| 184 |
2 0 0 inf |
| 185 |
2 2 0.0002 0.2028 \endcode |
| 186 |
|
| 187 |
It can also compute the persistent homology with |
| 188 |
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the weighted alpha complex on points sampling from an OFF file |
| 189 |
and a weights file. |
| 190 |
\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off |
| 191 |
--weight-file ../../data/points/tore3D_300.weights -p 2 -m 0.45 \endcode |
| 192 |
\code Simplex_tree dim: 3 |
| 193 |
2 0 -1 inf |
| 194 |
2 1 -0.931784 0.000103311 |
| 195 |
2 1 -0.906588 2.60165e-05 |
| 196 |
2 2 -0.43556 0.0393798 \endcode |
| 197 |
|
| 198 |
One can also compute the persistent homology with |
| 199 |
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on points sampling from an OFF file. |
| 200 |
The second parameter is a \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid. |
| 201 |
Note that the lengths of the sides of the periodic cuboid have to be the same. |
| 202 |
\code $> ./alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off |
| 203 |
--cuboid-file ../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0 \endcode |
| 204 |
\code Simplex_tree dim: 3 |
| 205 |
3 0 0 inf |
| 206 |
3 1 0.0025 inf |
| 207 |
3 1 0.0025 inf |
| 208 |
3 1 0.0025 inf |
| 209 |
3 2 0.005 inf |
| 210 |
3 2 0.005 inf |
| 211 |
3 2 0.005 inf |
| 212 |
3 3 0.0075 inf \endcode |
| 213 |
|
| 214 |
In order to compute the persistent homology with |
| 215 |
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on weighted points from an OFF file. The |
| 216 |
additional parameters of this program are:<br> |
| 217 |
(a) The file with the weights of points. The file consist of a sequence of numbers (as many as points). |
| 218 |
Note that the weight of each single point have to be bounded by 1/64 times the square of the cuboid edge length.<br> |
| 219 |
(b) A \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid. |
| 220 |
Note that the lengths of the sides of the periodic cuboid have to be the same.<br> |
| 221 |
\code $> ./alpha_complex_3d_persistence ../../data/points/shifted_sphere.off |
| 222 |
--weight-file ../../data/points/shifted_sphere.weights |
| 223 |
--cuboid-file ../../data/points/iso_cuboid_3_in_0_10.txt -p 3 -m 1.0 \endcode |
| 224 |
\code Simplex_tree dim: 3 |
| 225 |
3 0 -0.0001 inf |
| 226 |
3 1 16.0264 inf |
| 227 |
3 1 16.0273 inf |
| 228 |
3 1 16.0303 inf |
| 229 |
3 2 36.8635 inf |
| 230 |
3 2 36.8704 inf |
| 231 |
3 2 36.8838 inf |
| 232 |
3 3 58.6783 inf \endcode |
| 233 |
|
| 234 |
\li \gudhi_example_link{Alpha_complex,alpha_complex_persistence.cpp} computes the persistent homology with |
| 235 |
\f$\mathbb{Z}/p\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. |
| 236 |
\code $> ./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off \endcode |
| 237 |
\code Alpha complex is of dimension 3 - 9273 simplices - 300 vertices. |
| 238 |
Simplex_tree dim: 3 |
| 239 |
2 0 0 inf |
| 240 |
2 1 0.0682162 1.0001 |
| 241 |
2 1 0.0934117 1.00003 |
| 242 |
2 2 0.56444 1.03938 \endcode |
| 243 |
|
| 244 |
More details on the <a href="../../alphacomplex/">Alpha complex utilities</a> dedicated page. |
| 245 |
|
| 246 |
\li \gudhi_example_link{Persistent_cohomology,plain_homology.cpp} computes the plain homology of a simple simplicial complex without |
| 247 |
filtration values. |
| 248 |
|
| 249 |
\section specialcasepersistence Special cases |
| 250 |
|
| 251 |
In order to compute the persistent homology of a piecewise-linear function on \f$\mathbb{R}\f$, the standard strategy would be to |
| 252 |
create a path complex (special case of cubical or simplicial complex), define a lower-star filtration on it, and finally |
| 253 |
apply a general persistence algorithm. compute_persistence_of_function_on_line() computes this persistence diagram |
| 254 |
directly on the function in linear time using the algorithm of \cite arxivpers1d . |
| 255 |
\include persistence_on_a_line.cpp |
| 256 |
outputs |
| 257 |
\code |
| 258 |
0.7 1.5 |
| 259 |
0 3.1 |
| 260 |
-1 inf |
| 261 |
\endcode |
| 262 |
*/ |
| 263 |
|
| 264 |
} // namespace persistent_cohomology |
| 265 |
|
| 266 |
} // namespace Gudhi |
| 267 |
|
| 268 |
#endif // DOC_PERSISTENT_COHOMOLOGY_INTRO_PERSISTENT_COHOMOLOGY_H_ |