Importing networkx graphs

Good evening everyone, I’m a new Nengo user and I’m still studying how it works. Recently, I have been encouraged to use networkx as a way to model and manipulate graphs. Because I’d like to make nengo and networkx communicating each other, what I would know is if it is possible to create a neuron ensemble whose internal connectivity scheme follows a networkx graph object and, of it is yes, how it can be possible.

I know that there’s a python package called pickle for object serialization, so, for instance, is there a way to upload a serialized networkx object in nengo and to apply the connectivity scheme as it reports?

Thank you in advance for your help!

There is currently no integration with networkx in Nengo. However, if you’d still like help with this integration we can discuss it further in this thread. Specifically, how does networkx define a “connectivity scheme”? Do you have ideas how this might map onto a typical Nengo Ensemble? Alternatively, do you know if it could be wrapped in a Nengo Node for simulation?

What I would like to do is to create a complex network by using networkx; once the graph is obtained, I extract the adjacency matrix and then I would apply it to my Nengo ensemble. In this way, it should be easier to define complex networks, for example scale-free networks, because I have to read just a file which contains a matrix, instead of creating a function that creates from itself all the connections.

Assuming you can acquire a N-by-N adjacency matrix from networkx where N is the number of neurons in the neural ensemble, you can then define the connections between the neurons in the ensemble with something like:

import nengo
import numpy as np

n_neurons = 100

adj = np.zeros((n_neurons, n_neurons)) # acquire this from networkx instead

with nengo.Network() as model:
    ens = nengo.Ensemble(n_neurons=n_neurons, dimensions=1)
    nengo.Connection(ens.neurons, ens.neurons, transform=adj)

Does this help?