File: tree.py

package info (click to toggle)
regina-normal 4.5-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 16,824 kB
  • ctags: 7,862
  • sloc: cpp: 63,296; ansic: 12,913; sh: 10,556; perl: 3,294; makefile: 947; python: 188
file content (42 lines) | stat: -rw-r--r-- 1,273 bytes parent folder | download | duplicates (4)
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
38
39
40
41
42
################################
#
#  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.
#
################################

# Create a new census of finite orientable closed 3-manifold
# triangulations with two tetrahedra.
from regina import NBoolSet
census = regina.NContainer()
regina.NCensus.formCensus(census, 2, NBoolSet.sTrue,
    NBoolSet.sTrue, NBoolSet.sFalse, 0, 0)

# Calculate the homology of each triangulation in the census.
# Note that formCensus() will have inserted each new triangulation as
# a child packet of the overall census container.
tri = census.getFirstTreeChild()
while tri != None:
    print tri.getPacketLabel() + ":", tri.getHomologyH1()
    tri = tri.getNextTreeSibling()


# Remove from the tree each triangulation with trivial homology.
tri = census.getFirstTreeChild()
while tri != None:
    next = tri.getNextTreeSibling()
    hom = tri.getHomologyH1()
    if hom.isTrivial():
        tri.makeOrphan()
    tri = next


# Print the homology of each remaining triangulation.
tri = census.getFirstTreeChild()
while tri != None:
    print tri.getPacketLabel() + ":", tri.getHomologyH1()
    tri = tri.getNextTreeSibling()