5 #include <topology/simplex.h>
6 #include <topology/zigzag-persistence.h>
7 #include <boost/tuple/tuple.hpp>
9 typedef ZigzagPersistence<unsigned> Zigzag;
10 typedef Zigzag::SimplexIndex Index;
11 typedef Zigzag::Death Death;
12 typedef Zigzag::ZColumn Boundary;
13 typedef std::vector<Index> Complex;
15 int main(int argc, char** argv)
18 rlog::RLogInit(argc, argv);
20 //stdoutLog.subscribeTo(RLOG_CHANNEL("topology/persistence")); 29 // Adding the triangle
30 std::cout << birth << ": adding 0" << std::endl;
31 boost::tie(i, d) = zz.add(Boundary(), birth++); // A
35 std::cout << birth << ": adding 1" << std::endl;
36 boost::tie(i, d) = zz.add(Boundary(), birth++); // B
40 std::cout << birth << ": adding 2" << std::endl;
41 boost::tie(i, d) = zz.add(Boundary(), birth++); // C
45 std::cout << birth << ": adding 3" << std::endl;
46 boost::tie(i, d) = zz.add(Boundary(c.begin(),
47 boost::next(c.begin(),2)),
51 if (d) std::cout << "Death of: " << *d << std::endl;
53 std::cout << birth << ": adding 4" << std::endl;
54 boost::tie(i, d) = zz.add(Boundary(boost::next(c.begin()),
55 boost::next(c.begin(),3)),
59 if (d) std::cout << "Death of: " << *d << std::endl;
61 std::cout << birth << ": adding 5" << std::endl;
63 Boundary bdry; bdry.append(*c.begin(), zz.cmp); bdry.append(*boost::next(c.begin(), 2), zz.cmp);
64 boost::tie(i, d) = zz.add(bdry, birth++); // AC
69 std::cout << birth << ": adding 6" << std::endl;
70 boost::tie(i, d) = zz.add(Boundary(boost::next(c.begin(), 3),
71 boost::next(c.begin(), 6)),
75 if (d) std::cout << "Death of: " << *d << std::endl;
79 // Removing the triangle in reverse order
80 for (Complex::reverse_iterator cur = c.rbegin(); cur != c.rend(); ++cur)
82 std::cout << birth << ": removing " << (*cur)->order << std::endl;
83 d = zz.remove(*cur, birth++);
84 if (d) std::cout << "Death of: " << *d << std::endl;