Zigzag Filtrations

A zigzag filtration allows cells to enter and exit a complex at specified parameters. Construction is similar to a filtration, but you need to specify entry as well as exit time. Zigzag filtration functionality is under the bats::zigzag namespace.

bats::zigzag::ZigzagFiltration<bats::SimplicialComplex> F;

std::vector<size_t> spx;
// create a cycle that persists for a while
spx = {0,1}; F.add_recursive(0.0, 10.0, spx);
spx = {0,2}; F.add_recursive(0.0, 10.0, spx);
spx = {1,2}; F.add_recursive(0.0, 10.0, spx);

// now block cycle for some period of time
spx = {0,1,2}; F.add(2.0, 4.0, spx);

You can compute a barcode using bats::barcode

using F2 = ModP<int, 2>;
auto ps = bats::zigzag::barcode(F, 1, F2(),
   bats::no_optimization_flag(),
   bats::standard_reduction_flag()
);

for (auto& pk : ps) {
   for (auto p : pk) {
       if (p.length() > 0)
           std::cout << p << std::endl;
   }
}

You should see the following output

0 : (0,10) <0(1),0(0)>
1 : (0,2) <2(1),0(1)>
1 : (4,10) <0(0),2(0)>

This indicates that there is a single connected component in the zigzag filtration. The two H1 classes correspond to the cycle, which isn’t present when we put in the triangle between parameters 2 and 4.