Generation module

Content

Functions that generates the underlying connectivity of graphs, as well as the synaptic properties (weight/strength and delay).

Functions (connectivity)
erdos_renyi Random graph studied by Erdos and Renyi
random_free_scale An uncorrelated free-scale graph
price_free_scale Price’s network (Barabasi-Albert if undirected)
newman_watts Newman-Watts small world network
distance_rule Distance-dependent connection probability
Functions (weigths/delays)
gaussian_eprop Random gaussian distribution
lognormal_eprop Random lognormal distribution
uniform_eprop Random uniform distribution
custom_eprop User defined distribution
correlated_fixed_eprop Computed from an edge property
correlated_proba_eprop Randomly drawn, correlated to an edge property
nngt.generation.erdos_renyi(nodes=0, density=0.1, edges=-1, avg_deg=-1.0, reciprocity=-1.0, weighted=True, directed=True, multigraph=False, name='ER', shape=None, positions=None, population=None, from_graph=None)[source]

Generate a random graph as defined by Erdos and Renyi but with a reciprocity that can be chosen.

Parameters:
  • nodes (int, optional (default: None)) – The number of nodes in the graph.
  • density (double, optional (default: 0.1)) – Structural density given by edges / nodes\(^2\).
  • edges (int (optional)) – The number of edges between the nodes
  • avg_deg (double, optional) – Average degree of the neurons given by edges / nodes.
  • reciprocity (double, optional (default: -1 to let it free)) – Fraction of edges that are bidirectional (only for directed graphs – undirected graphs have a reciprocity of 1 by definition)
  • weighted (bool, optional (default: True)) – Whether the graph edges have weights.
  • directed (bool, optional (default: True)) – Whether the graph is directed or not.
  • multigraph (bool, optional (default: False)) – Whether the graph can contain multiple edges between two nodes.
  • name (string, optional (default: “ER”)) – Name of the created graph.
  • shape (Shape, optional (default: None)) – Shape of the neurons’ environment.
  • positions (numpy.ndarray, optional (default: None)) – A 2D or 3D array containing the positions of the neurons in space.
  • population (NeuralPop, optional (default: None)) – Population of neurons defining their biological properties (to create a Network).
  • from_graph (Graph or subclass, optional (default: None)) – Initial graph whose nodes are to be connected.
Returns:

graph_er (Graph, or subclass) – A new generated graph or the modified from_graph.

Notes

nodes is required unless from_graph or population is provided. If an from_graph is provided, all preexistant edges in the object will be deleted before the new connectivity is implemented.

nngt.generation.newman_watts(coord_nb, proba_shortcut, nodes=0, directed=True, multigraph=False, name='ER', shape=None, positions=None, population=None, from_graph=None, **kwargs)[source]

Generate a small-world graph using the Newman-Watts algorithm. @todo: generate the edges of a circular graph to not replace the graph of the from_graph and implement chosen reciprocity.

Parameters:
  • coord_nb (int) – The number of neighbours for each node on the initial topological lattice.
  • proba_shortcut (double) – Probability of adding a new random (shortcut) edge for each existing edge on the initial lattice.
  • nodes (int, optional (default: None)) – The number of nodes in the graph.
  • density (double, optional (default: 0.1)) – Structural density given by edges / (nodes`*`nodes).
  • edges (int (optional)) – The number of edges between the nodes
  • avg_deg (double, optional) – Average degree of the neurons given by edges / nodes.
  • directed (bool, optional (default: True)) – Whether the graph is directed or not.
  • multigraph (bool, optional (default: False)) – Whether the graph can contain multiple edges between two nodes.
  • name (string, optional (default: “ER”)) – Name of the created graph.
  • shape (Shape, optional (default: None)) – Shape of the neurons’ environment
  • positions (numpy.ndarray, optional (default: None)) – A 2D or 3D array containing the positions of the neurons in space
  • from_graph (Graph or subclass, optional (default: None)) – Initial graph whose nodes are to be connected.
Returns:

graph_nw (Graph or subclass)

Notes

nodes is required unless from_graph or population is provided.

nngt.generation.connect_neural_types(network, source_type, target_type, graph_model, model_param)[source]

Function to connect excitatory and inhibitory population with a given graph model.

Parameters:
  • network (Network or SpatialNetwork) – The network to connect.
  • source_type (int) – The type of source neurons (1 for excitatory, ``-1 for inhibitory neurons).
  • source_type (int) – The type of target neurons.
  • graph_model (string) – The name of the connectivity model (among “erdos_renyi”, “random_scale_free”, “price_scale_free”, and “newman_watts”).
  • model_param (dict) – Dictionary containing the model parameters (the keys are the keywords of the associated generation function — see above).
nngt.generation.connect_neural_groups(network, source_groups, target_groups, graph_model, model_param)[source]

Function to connect excitatory and inhibitory population with a given graph model.

Parameters:
  • network (Network or SpatialNetwork) – The network to connect.
  • source_groups (tuple of strings) – Names of the source groups (which contain the pre-synaptic neurons)
  • target_groups (tuple of strings) – Names of the target groups (which contain the post-synaptic neurons)
  • graph_model (string) – The name of the connectivity model (among “erdos_renyi”, “random_scale_free”, “price_scale_free”, and “newman_watts”).
  • model_param (dict) – Dictionary containing the model parameters (the keys are the keywords of the associated generation function — see above).