# Create an undirected graph with only node dynamics G = nx.Graph() G.graph['node_dyn'] = True G.graph['edge_dyn'] = False # Graph should have a ring topology n_nodes = 30 G.add_node(0) for i in range(1, n_nodes): G.add_node(i) G.add_edge(i-1, i) G.add_edge(i, 0) # All nodes are Kuramoto oscillators (discrete-time) netevo.set_all_node_dynamics(G, kuramoto_node_dyn) # Set random initial conditions for each node netevo.rnd_uniform_node_states (G, [(0.0, 6.2)]) #========================================= # DEFINE THE VISUAL REPORTER #========================================= # Create the figure to display the visualization fig = plt.figure(figsize=(6,6)) # Node positions to use for the visualization pos=nx.circular_layout(G) # A visual reporter that will display the current state of the network
dist = np.linalg.norm(s1 - s2) return 0.08 * dist #========================================= # CREATE THE NETWORK #========================================= # Create a fully connected graph G = nx.complete_graph(12) # Both node and edge dynamics are required G.graph['node_dyn'] = True G.graph['edge_dyn'] = True # All nodes are chaotic Lorenz oscillators netevo.set_all_node_dynamics(G, lorenz_node_dyn) # All edges follow the adaptive rule netevo.set_all_edge_dynamics(G, adaptive_law_edge_dyn) # Randomly assign node states netevo.rnd_uniform_node_states(G, [(0.1, 20.0), (0.1, 20.0), (0.1, 20.0)]) # Edges all start with a very weak strength netevo.rnd_uniform_edge_states(G, [(0.00000001, 0.00000001)]) #========================================= # DEFINE THE VISUAL REPORTER #========================================= # Create the figure to display the visualization fig = plt.figure(figsize=(6.5,6.5)) # Node positions to use for the visualization
#========================================= # CREATE THE NETWORK #========================================= # Create a random undirected graph and check valid (n=50, m=100) n = 20 G = [] while True: G = nx.gnm_random_graph(n, 2*n) if nx.is_connected(G): break # No dynamics are required G.graph['node_dyn'] = True G.graph['edge_dyn'] = False netevo.set_all_node_dynamics(G, rossler_node_dyn) #========================================= # EVOLVE THE NETWORK #========================================= # Perform the evolution (using simulated dynamics as part of the performance measure) iteration, G_final = netevo.evolve_sa(G, order_parameter, rewire, initial_temp=100.0, min_temp=0.0001, reporter=netevo.evo_sa_reporter) # Output GML files containing the initial and final toplogies (viewable in Cytoscape/yEd) netevo.write_to_file(G, 'evolution_sa_dyn_initial.gml') netevo.write_to_file(G_final, 'evolution_sa_dyn_final.gml', node_keys=['state'])