File: tree.py

package info (click to toggle)
regina-normal 7.4.1-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 154,244 kB
  • sloc: cpp: 295,026; xml: 9,992; sh: 1,344; python: 1,225; perl: 616; ansic: 138; makefile: 26
file content (37 lines) | stat: -rw-r--r-- 1,256 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
################################
#
#  Sample Python Script
#
#  Illustrates the traversal and manipulation of an entire packet tree.
#
#  See the file "tree.session" for the results of running this script.
#
################################

# Recreate the original SnapPea census of cusped hyperbolic manifolds
# triangulated by at most 5 tetrahedra.
#
# Since we are building a packet tree, we need to use PacketOfTriangulation3,
# not the plain type Triangulation3 (which is not a packet type).
census = Container()
for i in range(415):
    mfd = SnapPeaCensusManifold(SnapPeaCensusManifold.SEC_5, i)
    census.append(make_packet(mfd.construct(), mfd.name()))

# The triangulations are now all children of the "census" container.
# Remove all triangulations with more than two tetrahedra.
#
# Since we are deleting children, we step through the children manually
# instead of just iterating over children().
tri = census.firstChild()
while tri != None:
    next = tri.nextSibling()
    if tri.size() > 2:
        tri.makeOrphan()
    tri = next

# Print the homology of each remaining triangulation.
# This time we are not adding or removing children, so we can just iterate.
for tri in census.children():
    print(tri.label() + ":", tri.homology())