class RunDefiningVisitor
set the height of the complete binary tree node that each node maps to
Public Instance Methods
postVisit(node)
click to toggle source
# File lib/visitor/numbering_visitor.rb, line 157 def postVisit(node) # the child with a greatest binaryTreeHeight larger than the current node's binaryTreeHeight # is the runTail, the current node is the runHead (which we need to set in runTail) if (node.children != nil) then maxBinaryTreeHeight = node.binaryTreeHeight maxBinaryTreeHeightNode = nil node.children.values.each do |child| if (child.runTail.binaryTreeHeight > maxBinaryTreeHeight) then maxBinaryTreeHeight = child.runTail.binaryTreeHeight maxBinaryTreeHeightNode = child end end if (maxBinaryTreeHeightNode != nil) then node.runTail = maxBinaryTreeHeightNode.runTail # runHead is ONLY valid in the runTail node, # the alternative is to traverse from runTail to node whenever runHead changes # (or to do this only on final change) node.runTail.runHead = node end end end
preVisit(node)
click to toggle source
# File lib/visitor/numbering_visitor.rb, line 148 def preVisit(node) # every node gets the runTail set correctly # runHead is ONLY valid in the runTail node node.runHead = node.runTail = node parentDfsNumber = 0 parentDfsNumber = node.parent.dfsNumber if (node.parent != nil) return true end