#NEWLINE# def showDomain( self , a = 0 ) : #NEWLINE# #INDENT# s = self . state #NEWLINE# if ( self . networkGraph is None ) : #NEWLINE# #INDENT# self . networkGraph = nx . Graph ( ) #NEWLINE# for ( computer_id , ( neighbors , compstatus ) ) in enumerate ( zip ( self . NEIGHBORS , s ) ) : #NEWLINE# #INDENT# self . networkGraph . add_node ( computer_id , node_color = 'w' ) #NEWLINE# #UNINDENT# for uniqueEdge in self . UNIQUE_EDGES : #NEWLINE# #INDENT# self . networkGraph . add_edge ( uniqueEdge [ 0 ] , uniqueEdge [ 1 ] , edge_color = 'k' ) #NEWLINE# #UNINDENT# self . networkPos = nx . circular_layout ( self . networkGraph ) #NEWLINE# nx . draw_networkx_nodes ( self . networkGraph , self . networkPos , node_color = 'w' ) #NEWLINE# nx . draw_networkx_edges ( self . networkGraph , self . networkPos , edges_color = 'k' ) #NEWLINE# nx . draw_networkx_labels ( self . networkGraph , redNodes . networkPos ) #NEWLINE# plt . show ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# plt . clf ( ) #NEWLINE# blackEdges = [ ] #NEWLINE# redEdges = [ ] #NEWLINE# greenNodes = [ ] #NEWLINE# redNodes = [ ] #NEWLINE# for ( computer_id , ( neighbors , compstatus ) ) in enumerate ( zip ( self . NEIGHBORS , s ) ) : #NEWLINE# #INDENT# if ( compstatus == self . RUNNING ) : #NEWLINE# #INDENT# greenNodes . append ( computer_id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# redNodes . append ( computer_id ) #NEWLINE# #UNINDENT# #UNINDENT# for uniqueEdge in self . UNIQUE_EDGES : #NEWLINE# #INDENT# if ( ( s [ uniqueEdge [ 0 ] ] == self . RUNNING ) and ( s [ uniqueEdge [ 1 ] ] == self . RUNNING ) ) : #NEWLINE# #INDENT# blackEdges . append ( uniqueEdge ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# redEdges . append ( uniqueEdge ) #NEWLINE# #UNINDENT# #UNINDENT# if redNodes : #NEWLINE# #INDENT# nx . draw_networkx_nodes ( self . networkGraph , self . networkPos , nodelist = redNodes , node_color = 'r' , linewidths = 2 ) #NEWLINE# #UNINDENT# if greenNodes : #NEWLINE# #INDENT# nx . draw_networkx_nodes ( self . networkGraph , self . networkPos , nodelist = greenNodes , node_color = 'w' , linewidths = 2 ) #NEWLINE# #UNINDENT# if blackEdges : #NEWLINE# #INDENT# nx . draw_networkx_edges ( self . networkGraph , self . networkPos , edgelist = blackEdges , edge_color = 'k' , width = 2 , style = 'solid' ) #NEWLINE# #UNINDENT# if redEdges : #NEWLINE# #INDENT# nx . draw_networkx_edges ( self . networkGraph , self . networkPos , edgelist = redEdges , edge_color = 'k' , width = 2 , style = 'dotted' ) #NEWLINE# #UNINDENT# #UNINDENT# nx . draw_networkx_labels ( self . networkGraph , self . networkPos ) #NEWLINE# plt . draw ( )