example$ regina-python
Regina 4.95
Software for 3-manifold topology and normal surface theory
Copyright (c) 1999-2013, The Regina development team
>>> ################################
... #
... #  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.
... census = NContainer()
>>> NCensus.formCensus(census, 2, NBoolSet.sTrue,
...     NBoolSet.sTrue, NBoolSet.sFalse, 0, 0)
16
>>> 
>>> # Calculate the homology of each triangulation in the census.
... # The triangulations are all children of the "census" container.
... tri = census.getFirstTreeChild()
>>> while tri != None:
...     print tri.getPacketLabel() + ":", tri.getHomologyH1()
...     tri = tri.getNextTreeSibling()
... 
Item 1: Z_7
Item 2: Z_5
Item 3: Z
Item 4: Z_3
Item 5: Z_8
Item 6: 0
Item 7: 0
Item 8: 0
Item 9: Z_2
Item 10: 0
Item 11: 0
Item 12: Z_3
Item 13: 0
Item 14: Z_3
Item 15: 2 Z_2
Item 16: Z_2
>>> 
>>> # Remove all triangulations with trivial homology from the tree.
... tri = census.getFirstTreeChild()
>>> while tri != None:
...     next = tri.getNextTreeSibling()
...     hom = tri.getHomologyH1()
...     if hom.isTrivial():
...         tri.makeOrphan()
...     tri = next
... 
<regina.engine.NTriangulation object at 0x1088396e0>
<regina.engine.NTriangulation object at 0x108839670>
<regina.engine.NTriangulation object at 0x1088397c0>
<regina.engine.NTriangulation object at 0x108839520>
<regina.engine.NTriangulation object at 0x108839750>
<regina.engine.NTriangulation object at 0x108839670>
>>> 
>>> # Print the homology of each remaining triangulation.
... tri = census.getFirstTreeChild()
>>> while tri != None:
...     print tri.getPacketLabel() + ":", tri.getHomologyH1()
...     tri = tri.getNextTreeSibling()
... 
Item 1: Z_7
Item 2: Z_5
Item 3: Z
Item 4: Z_3
Item 5: Z_8
Item 9: Z_2
Item 12: Z_3
Item 14: Z_3
Item 15: 2 Z_2
Item 16: Z_2
>>> 

