#NEWLINE# def _next_rooted_tree( predecessor , p = None ) : #NEWLINE# #INDENT# 'One iteration of the Beyer-Hedetniemi algorithm.' #NEWLINE# if ( p is None ) : #NEWLINE# #INDENT# p = ( len ( predecessor ) - 1 ) #NEWLINE# while ( predecessor [ p ] == 1 ) : #NEWLINE# #INDENT# p -= 1 #NEWLINE# #UNINDENT# #UNINDENT# if ( p == 0 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# q = ( p - 1 ) #NEWLINE# while ( predecessor [ q ] != ( predecessor [ p ] - 1 ) ) : #NEWLINE# #INDENT# q -= 1 #NEWLINE# #UNINDENT# result = list ( predecessor ) #NEWLINE# for i in range ( p , len ( result ) ) : #NEWLINE# #INDENT# result [ i ] = result [ ( ( i - p ) + q ) ] #NEWLINE# #UNINDENT# return result