1 --- a/examples/alphashapes/alphashapes.py Thu Apr 16 00:23:01 2009 -0700
2 +++ b/examples/alphashapes/alphashapes.py Mon Jul 25 23:21:29 2011 -0700
3 @@ -12,16 +12,15 @@
4 exit()
5
6 points = [p for p in points_file(argv[1])]
7 -simplices = []
8 +f = Filtration()
9 if len(points[0]) == 2: # 2D
10 - fill_alpha2D_complex(points, simplices)
11 + fill_alpha2D_complex(points, f)
12 elif len(points[1]) == 3: # 3D
13 - fill_alpha3D_complex(points, simplices)
14 + fill_alpha3D_complex(points, f)
15
16 -simplices.sort(vertex_cmp) # Must ensure lexicographic ordering
17 -print "Total number of simplices:", len(simplices)
18 +print "Total number of simplices:", len(f)
19
20 -f = Filtration(simplices, data_dim_cmp)
21 +f.sort(data_dim_cmp)
22 print "Filtration initialized"
23
24 p = StaticPersistence(f)
25 @@ -31,12 +30,13 @@
26 print "Simplices paired"
27
28 print "Outputting persistence diagram"
29 +smap = p.make_simplex_map(f)
30 for i in p:
31 if i.sign():
32 - b = simplices[f[p(i)]]
33 - if i == i.pair:
34 - print b.dimension(), sqrt(b.data), "inf"
35 + b = smap[i]
36 + if i.unpaired():
37 + print b.dimension(), sqrt(b.data[0]), "inf"
38 continue
39
40 - d = simplices[f[p(i.pair)]]
41 - print b.dimension(), sqrt(b.data), sqrt(d.data)
42 + d = smap[i.pair()]
43 + print b.dimension(), sqrt(b.data[0]), sqrt(d.data[0])