defanimate(i):globalcurrent_cycleglobalLAST_CYCLEglobalPACKETSglobaltextglobaleglobalfixed_positionsglobalGglobaltreeglobalcurr_cycle_array#print(e.get())#a.clear()print("current cycle is",current_cycle)#initialize and zero array of size (dim1*dim2)fixed_nodes=fixed_positions.keys()pos=nx.spring_layout(G,pos=fixed_positions,fixed=fixed_nodes)iterator=0curr_cycle_array=[0]*64#move through current router list and increment for eachwhile(iteratorMAX_VALUE:MAX_VALUE=curr_cycle_array[i]my_color_dict={}#heat map for current cycleb=list(range(0,64))forcinb:if(MAX_VALUE==0):my_color_dict[c]='none'elif(0.95*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<=MAX_VALUE):my_color_dict[c]='max'elif(0.75*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.95*MAX_VALUE):my_color_dict[c]='high'elif(0.65*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.75*MAX_VALUE):my_color_dict[c]='medium_high'elif(0.55*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.65*MAX_VALUE):my_color_dict[c]='medium'elif(0.45*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.55*MAX_VALUE):my_color_dict[c]='medium_low'elif(0.35*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.45*MAX_VALUE):my_color_dict[c]='low'elif(0.25*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.35*MAX_VALUE):my_color_dict[c]='very_low'elif(0.10*MAX_VALUE<=curr_cycle_array[c]&curr_cycle_array[c]<0.25*MAX_VALUE):my_color_dict[c]='very_very_low'elif(0==curr_cycle_array[c]|curr_cycle_array[c]<0.10*MAX_VALUE):my_color_dict[c]='none'c=c+1#every node in G has a 'router' var for color and a 'num_packets' var for number of packetsfornodeinG.nodes():G.node[node]['router']=my_color_dict[node]G.node[node]['num_packets']=8color_map={'none':'b','very_very_low':'lightblue','very_low':'lightgreen','low':'y','medium':'orange','medium_high':'tomato','high':'r','max':'w'}plt.subplot(221)nx.draw_networkx_nodes(G,pos,node_shape='s',node_size=250,node_color=[color_map[G.node[node]['router']]fornodeinG.nodes()])nx.draw_networkx_edges(G,pos)#nx.draw_networkx_labels(G,pos)ifcurrent_cycle==LAST_CYCLE:current_cycle=0elifcurrent_cycle