Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions > Class Template Reference

Class computing the zigzag persistent homology of a zigzag sequence. Algorithm based on [41]. More...

#include <gudhi/zigzag_persistence.h>

Public Types

using Options = ZigzagOptions
 
using Index = typename Options::Internal_key
 
using Dimension = typename Options::Dimension
 

Public Member Functions

 Zigzag_persistence (std::function< void(Dimension, Index, Index)> stream_interval, unsigned int preallocationSize=0)
 Constructor of the Zigzag_persistence class. More...
 
template<class BoundaryRange = std::initializer_list<Index>>
Index insert_cell (const BoundaryRange &boundary, Dimension dimension)
 Updates the zigzag persistence diagram after the insertion of the given cell. More...
 
Index remove_cell (Index arrowNumber)
 Updates the zigzag persistence diagram after the removal of the given cell. More...
 
Index apply_identity ()
 To use when a cell is neither inserted nor removed, but the filtration moves along the identity operator on homology level. Useful to keep the birth/death indices aligned when insertions/removals are purposely skipped to avoid useless computation. Increases the arrow number by one. More...
 
template<typename F >
void get_current_infinite_intervals (F &&stream_infinite_interval)
 Outputs through the given callback method all birth indices which are currently not paired with a death index. More...
 

Detailed Description

template<class ZigzagOptions = Default_zigzag_options>
class Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >

Class computing the zigzag persistent homology of a zigzag sequence. Algorithm based on [41].

After construction of the class, the zigzag filtration should be given in a streaming like way, i.e., call insert_cell, remove_cell or apply_identity for each step of the filtration in order of the filtration. The pairs of birth and death indices are retrieved via the given callback method every time a pair is closed. To retrieve the open pairs (corresponding to infinite bars), use get_current_infinite_intervals.

Minimalistic example of usage

Includes

Contains the implementation of the Gudhi::zigzag_persistence::Zigzag_persistence class.

Useful aliases

Class computing the zigzag persistent homology of a zigzag filtration. Algorithm based on .
Definition: filtered_zigzag_persistence.h:442
Class computing the zigzag persistent homology of a zigzag sequence. Algorithm based on .
Definition: zigzag_persistence.h:149
typename Options::Dimension Dimension
Definition: zigzag_persistence.h:153
typename Options::Internal_key Index
Definition: zigzag_persistence.h:152

Construction with default values

//Zigzag_persistence(callback) with for example callback method as a anonymous lambda
Zigzag_persistence zp([](Dimension dim, Index birth, Index death) {
std::cout << "[" << dim << "] " << birth << " - " << death << std::endl;
});

Input of the zigzag sequence/filtration

// In all cases, it is important that the operations of insertions and removals are made **in the same order**
// as in the zigzag filtration ones wants to compute the barcode from.
// A cell has to be identified in the boundaries by the operation number the cell was inserted with in the sequence.
//inserts vertex 0 -> birth at 0 of 0-cycle
zp.insert_cell({}, 0);
//inserts vertex 1 -> birth at 1 of 0-cycle
zp.insert_cell({}, 0);
//inserts edge 2 = (0,1) -> death at 2 -> outputs (0, 1, 2)
zp.insert_cell({0, 1}, 1);
//inserts vertex 3 -> birth at 3 of 0-cycle
zp.insert_cell({}, 0);
//inserts edge 4 = (0,3) -> death at 4 -> outputs (0, 3, 4)
zp.insert_cell({0, 3}, 1);
//inserts edge 5 = (1,3) -> birth at 5 of 1-cycle
zp.insert_cell({1, 3}, 1);
//removes edge 4 -> death at 6 -> outputs (1, 5, 6)
zp.remove_cell(4);
//removes edge 2 -> birth at 7 of 0-cycle
zp.remove_cell(2);

Finalizations

// Only the closed bars where output so far, so the open/infinite bars still need to be retrieved.
//in this example, outputs (0, 0) and (0, 7)
zp.get_current_infinite_intervals([](Dimension dim, Index birth){
std::cout << "[" << dim << "] " << birth << " - inf" << std::endl;
});
Template Parameters
ZigzagOptionsStructure following the ZigzagOptions concept. Default value: Default_zigzag_options.
Examples
example_usage_zigzag_persistence.cpp.

Member Typedef Documentation

◆ Dimension

template<class ZigzagOptions = Default_zigzag_options>
using Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::Dimension = typename Options::Dimension

Type for dimension values.

◆ Index

template<class ZigzagOptions = Default_zigzag_options>
using Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::Index = typename Options::Internal_key

Key and index type, has to be signed.

◆ Options

template<class ZigzagOptions = Default_zigzag_options>
using Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::Options = ZigzagOptions

Zigzag options.

Constructor & Destructor Documentation

◆ Zigzag_persistence()

template<class ZigzagOptions = Default_zigzag_options>
Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::Zigzag_persistence ( std::function< void(Dimension, Index, Index)>  stream_interval,
unsigned int  preallocationSize = 0 
)
inline

Constructor of the Zigzag_persistence class.

After construction of the class, the zigzag filtration should be given in a streaming like way, i.e., call insert_cell, remove_cell or apply_identity for each step of the filtration in order of the filtration. The pairs of birth and death indices are retrieved via the given callback method every time a pair is closed. To retrieve the open pairs (corresponding to infinite bars), use get_current_infinite_intervals.

Parameters
stream_intervalCallback method to process the birth and death index pairs. Has to take three arguments as input: first the dimension of the cycle, then the birth index of the cycle and third the death index of the cycle. An index always corresponds to the arrow number the event occurred (one call to insert_cell, remove_cell or apply_identity is equal to one arrow and increases the arrow count by one).
preallocationSizeReserves space for preallocationSize cells in the internal data structure. This is optional and just helps skip a few reallocations. The optimal value (no reallocation, no wasted space) is the number of cells in the biggest complex of the filtration. Default value: 0.

Member Function Documentation

◆ apply_identity()

template<class ZigzagOptions = Default_zigzag_options>
Index Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::apply_identity ( )
inline

To use when a cell is neither inserted nor removed, but the filtration moves along the identity operator on homology level. Useful to keep the birth/death indices aligned when insertions/removals are purposely skipped to avoid useless computation. Increases the arrow number by one.

Returns
Number of the operation.

◆ get_current_infinite_intervals()

template<class ZigzagOptions = Default_zigzag_options>
template<typename F >
void Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::get_current_infinite_intervals ( F &&  stream_infinite_interval)
inline

Outputs through the given callback method all birth indices which are currently not paired with a death index.

Template Parameters
FType of the callback method. Takes two arguments: the dimension of the cycle and the birth index of the cycle.
Parameters
stream_infinite_intervalMethod processing the unpaired birth indices.

◆ insert_cell()

template<class ZigzagOptions = Default_zigzag_options>
template<class BoundaryRange = std::initializer_list<Index>>
Index Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::insert_cell ( const BoundaryRange &  boundary,
Dimension  dimension 
)
inline

Updates the zigzag persistence diagram after the insertion of the given cell.

Template Parameters
BoundaryRangeRange type needing size, begin and end members.
Parameters
boundaryBoundary of the inserted cell. The boundary should be represented by all the cells with non-zero coefficients generating it. A cell should be represented by the arrow number when the cell appeared for the first time in the filtration (if a cell was inserted and then removed and reinserted etc., only the last insertion counts). The cell range should be ordered by increasing arrow numbers.
dimensionDimension of the inserted cell.
Returns
Number of the operation.

◆ remove_cell()

template<class ZigzagOptions = Default_zigzag_options>
Index Gudhi::zigzag_persistence::Zigzag_persistence< ZigzagOptions >::remove_cell ( Index  arrowNumber)
inline

Updates the zigzag persistence diagram after the removal of the given cell.

Parameters
arrowNumberArrow number of when the cell to remove was inserted for the last time.
Returns
Number of the operation.

The documentation for this class was generated from the following file: