1 from dionysus import Simplex, ZigzagPersistence, \
5 complex = {Simplex((0,), 0): None, # A 6 Simplex((1,), 1): None, # B
7 Simplex((2,), 2): None, # C
8 Simplex((0,1), 2.5): None, # AB
9 Simplex((1,2), 2.9): None, # BC
10 Simplex((0,2), 3.5): None, # CA
11 Simplex((0,1,2), 5): None} # ABC
14 for s in sorted(complex.keys()): print s
17 #enable_log("topology/persistence") 18 zz = ZigzagPersistence()
20 # Add all the simplices
22 for s in sorted(complex.keys(), data_cmp):
23 print "%d: Adding %s" % (b, s)
24 i,d = zz.add([complex[ss] for ss in s.boundary], b)
26 if d: print "Interval (%d, %d)" % (d, b-1)
29 # Remove all the simplices
30 for s in sorted(complex.keys(), data_cmp, reverse = True):
31 print "%d: Removing %s" % (b, s)
32 d = zz.remove(complex[s], b)
34 if d: print "Interval (%d, %d)" % (d, b-1)