コード例 #1
0
#=========================================
# 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
pos = nx.circular_layout(G)
# Function to generate the visualisation of the network
コード例 #2
0
    G.add_node(i)
    G.add_edge(i-1, i)
G.add_node(12)

for n in range(12):
    G.node[n]['color'] = 'b'
G.node[12]['color'] = 'r'

# 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, netevo.no_edge_dyn)

# Randomly assign node states
netevo.rnd_uniform_node_states (G, [(3.0, 10.0), (3.0, 10.0), (3.0, 10.0)])
# Edges all start with a very weak strength
netevo.rnd_uniform_edge_states (G, [(0.3, 0.3)])

# Our pinning node has no dynamics just fixed states that change
G.node[12]['state'] = [30.0, 30.0, 30.0]
G.node[12]['dyn'] = pinner_node_dyn

#=========================================
# DEFINE THE VISUAL REPORTER
#=========================================

# Turn on animation in pylab