#NEWLINE# @ property #NEWLINE# def strong_connections( self ) : #NEWLINE# #INDENT# index_counter = [ 0 ] #NEWLINE# stack = [ ] #NEWLINE# lowlinks = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# index = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# result = [ ] #NEWLINE# graph = self . _succs #NEWLINE# def strongconnect( node ) : #NEWLINE# #INDENT# index [ node ] = index_counter [ 0 ] #NEWLINE# lowlinks [ node ] = index_counter [ 0 ] #NEWLINE# index_counter [ 0 ] += 1 #NEWLINE# stack . append ( node ) #NEWLINE# try : #NEWLINE# #INDENT# successors = graph [ node ] #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# successors = [ ] #NEWLINE# #UNINDENT# for successor in successors : #NEWLINE# #INDENT# if ( successor not in lowlinks ) : #NEWLINE# #INDENT# strongconnect ( successor ) #NEWLINE# lowlinks [ node ] = min ( lowlinks [ node ] , lowlinks [ successor ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( successor in stack ) : #NEWLINE# #INDENT# lowlinks [ node ] = min ( lowlinks [ node ] , index [ successor ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( lowlinks [ node ] == index [ node ] ) : #NEWLINE# #INDENT# connected_component = [ ] #NEWLINE# while True : #NEWLINE# #INDENT# successor = stack . pop ( ) #NEWLINE# connected_component . append ( successor ) #NEWLINE# if ( successor == node ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# component = tuple ( connected_component ) #NEWLINE# result . append ( component ) #NEWLINE# #UNINDENT# #UNINDENT# for node in graph : #NEWLINE# #INDENT# if ( node not in lowlinks ) : #NEWLINE# #INDENT# strongconnect ( node ) #NEWLINE# #UNINDENT# #UNINDENT# return result