Method: BiDimensionalTree#get_depth_horiz
- Defined in:
- lib/bi-dimensional-access.rb
#get_depth_horiz(node = @root, depth = 1, maxdepth = 0) ⇒ Object
Return the max depth of the tree
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/bi-dimensional-access.rb', line 228 def get_depth_horiz(node = @root, depth = 1, maxdepth = 0) unless node.west.nil? maxdepth = get_depth_horiz(node.west, depth + 1, maxdepth) end unless node.east.nil? maxdepth = get_depth_horiz(node.east, depth + 1, maxdepth) end if node.west.nil? and node.east.nil? and depth > maxdepth maxdepth = depth end maxdepth end |