Two methods for computing graph statistics online. Tree name and edge are the only inputs.
conn = StrictRedis()
def online_size(sender, tree_name=None, edge=None):
conn.incr('{0}.size'.format(tree_name))
def online_depth(sender, tree_name=None, edge=None):
with conn.lock('{0}.depth'.format(tree_name)):
current_depth = conn.get('{0}.depth'.format(tree_name)) or 0
if int(current_depth) < edge.generation:
conn.set('{0}.depth'.format(tree_name), edge.generation)