assigning level to nodes
def leveling ( src : int ) : NEW_LINE INDENT for i in range ( len ( g [ src ] ) ) : NEW_LINE INDENT des = g [ src ] [ i ] NEW_LINE if not level [ des ] : NEW_LINE INDENT level [ des ] = level [ src ] + 1 NEW_LINE leveling ( des ) NEW_LINE DEDENT DEDENT DEDENT visited = [ False ] * maxn NEW_LINE