#NEWLINE# def _extend( nnbrs , cand , done , so_far , cliques ) : #NEWLINE# #INDENT# maxconn = ( - 1 ) #NEWLINE# numb_cand = len ( cand ) #NEWLINE# for n in done : #NEWLINE# #INDENT# cn = ( cand & nnbrs [ n ] ) #NEWLINE# conn = len ( cn ) #NEWLINE# if ( conn > maxconn ) : #NEWLINE# #INDENT# pivotnbrs = cn #NEWLINE# maxconn = conn #NEWLINE# if ( conn == numb_cand ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for n in cand : #NEWLINE# #INDENT# cn = ( cand & nnbrs [ n ] ) #NEWLINE# conn = len ( cn ) #NEWLINE# if ( conn > maxconn ) : #NEWLINE# #INDENT# pivotnbrs = cn #NEWLINE# maxconn = conn #NEWLINE# #UNINDENT# #UNINDENT# smallercand = set ( ( cand - pivotnbrs ) ) #NEWLINE# for n in smallercand : #NEWLINE# #INDENT# cand . remove ( n ) #NEWLINE# so_far . append ( n ) #NEWLINE# nn = nnbrs [ n ] #NEWLINE# new_cand = ( cand & nn ) #NEWLINE# new_done = ( done & nn ) #NEWLINE# if ( ( not new_cand ) and ( not new_done ) ) : #NEWLINE# #INDENT# cliques . append ( so_far [ : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not new_done ) and ( len ( new_cand ) is 1 ) ) : #NEWLINE# #INDENT# cliques . append ( ( so_far + list ( new_cand ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# _extend ( nnbrs , new_cand , new_done , so_far , cliques ) #NEWLINE# #UNINDENT# #UNINDENT# done . add ( so_far . pop ( ) )