MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / find_nodes_per_depth

Method find_nodes_per_depth

pygorithm/data_structures/quadtree.py:374–386  ·  view source on GitHub ↗

Calculate the number of nodes at each depth level. This is implemented iteratively. See :py:meth:`.__str__` for usage example. :returns: dict of depth level to number of nodes :rtype: dict int: int

(self)

Source from the content-addressed store, hash-verified

372 return container['result']
373
374 def find_nodes_per_depth(self):
375 """
376 Calculate the number of nodes at each depth level.
377
378 This is implemented iteratively. See :py:meth:`.__str__` for usage example.
379
380 :returns: dict of depth level to number of nodes
381 :rtype: dict int: int
382 """
383
384 nodes_per_depth = {}
385 self._iter_helper(lambda curr, d=nodes_per_depth: d.update({ (curr.depth, d.get(curr.depth, 0) + 1) }))
386 return nodes_per_depth
387
388 def sum_entities(self, entities_per_depth=None):
389 """

Callers 2

__str__Method · 0.95
test_nodes_per_depthMethod · 0.95

Calls 1

_iter_helperMethod · 0.95

Tested by 1

test_nodes_per_depthMethod · 0.76