def order_parameter (G): if nx.is_connected(G): # Simulate from random initial conditions netevo.rnd_uniform_node_states(G, [(0.0, 10.0), (0.0, 10.0), (0.0, 10.0)]) # Simulate the system res, nmap, emap = netevo.simulate_ode_fixed(G, [0.0, 20.0], node_dim=3) # Calculate the order_parameter and return value mu = 0.0 for i in G.nodes(): for j in G.nodes(): if i != j: dist = np.linalg.norm(res[-1][nmap[i]:nmap[i]+2] - res[-1][nmap[j]:nmap[j]+2]) # Heaviside function (allow for some numerical error:0.01) if dist - 0.01 >= 0.0: mu += 100.0 return mu * (1.0 / (G.number_of_nodes() * (G.number_of_nodes() - 1.0))); # If the network is not connected it is not valid return float('inf')
if nx.is_connected(G): break # Only node dynamics are required - should all be chaotic Rossler oscillators G.graph['node_dyn'] = True G.graph['edge_dyn'] = False netevo.set_all_node_dynamics(G, rossler_node_dyn) #========================================= # SIMULATE THE NETWORK #========================================= # Simulate from random initial conditions netevo.rnd_uniform_node_states(G, [(0.0, 5.0), (0.0, 5.0), (0.0, 5.0)]) # Simulate the system res, nmap, emap = netevo.simulate_ode_fixed(G, [0.0, 10.0, 20.0], node_dim=3) # Print the results print "Simulation Results:" print '=================================' print "For t = 0:" for n in G.nodes(): print "Node ", n, " = [", res[0][nmap[n]], ', ', res[0][nmap[n]+1], ', ' \ , res[0][nmap[n]+2], ']' print '=================================' print "For t = 20:" for n in G.nodes(): print "Node ", n, " = [", res[2][nmap[n]], ', ', res[2][nmap[n]+1], ', ' \ , res[2][nmap[n]+2], ']'