Skip to content

Instantly share code, notes, and snippets.

@WPettersson
Created December 28, 2014 12:02
Show Gist options
  • Save WPettersson/6cdf935bd12b13e26591 to your computer and use it in GitHub Desktop.
Save WPettersson/6cdf935bd12b13e26591 to your computer and use it in GitHub Desktop.
Notes on partial triangulation census of 3-manifold implementation
# Given FPG on n nodes
# Take tree decomposition of FPG, arbitrarily assign a root
# Let "contains" consisting of n "true" bools
# Let seen := {}
# Take root bag and assign properties as follows:
# Let bag.contains = contains
# Let bag.toAdd = bag.contents \setminus seen
# Let seen = seen + bag.contents
# Let contains = contains \setminus seen
# Iterate through children with same process
# Description:
# bag.contains denotes the tetrahedra which will be in the triangulation at this stage of the enumeration (true if present, false if not)
# bag.toAdd are the tetrahedra which are to be added at this stage of the enumeration
# Enumeration process, run at root node and recurses down:
# First create the "new" tetrahedra at this bag.
For i in bag.toAdd:
now.triangulation.newSimplex( i.toString() ) # To avoid constant reindexing of tetrahedra, use descriptions to refer to them? Better idea?
For j in {0,1,2,3}:
if now.contains[ FPG.dest(i,j).simp ]:
gluings.append( (NFacetSpec(i,j), FPG.dest(i,j) ) # Find the gluings which need to be tried here
# Start recursion call
start(0)
# new function
# Finds the next starter. The "i" denotes which child number we are currently iterating through.
def start(i) {
if i == number_of_children: # Iterated through all children, time to try gluing
tryGluing(0)
return
int size_at_start = now.triangulation.size() # Used for backtracking
for child_triangulation in child[i].iterator:
child_triangulation.moveTo(now.triangulation) # Add on the bits from the child
start(i+1); # Recurse
# Backtrack by deleting tetrahedra. moveTo() will re-create them from next child triangulation
while (now.triangulation.size() > size_at_start)
now.triangulation.removeTetrahedronAt(now.triangulation.size())
tryEdge(0)
# new function
# Tries the next gluing. The "i" indicates which gluing we are testing.
def tryEdge(i) {
if i == number_of_edges: # Everything glued up, so store this
store(now.triangulation)
return
e = edges[i]
for g in possible_gluings: # Each of 6
perm = makePerm(g, e[0].face, e[1].face) # Create the NPerm object from the gluing + faces
tetA = getTet(e[0].simp) # Need to find the right tetrahedron from description to avoid reindexing.
tetB = getTet(e[1].simp)
tetA.joinTo(e[0].face,tetB, perm) # Glue
if now.triangulation.isValidPartial(): # Test validity. No closed vertex links (unless all faces glued), no edges glued in reverse.
tryEdge(i+1);
tetA.simp.unjoin(e[0].face) # Backtrack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment