Graph container classesΒΆ
-
class
nngt.
Graph
(nodes=0, name='Graph', weighted=True, directed=True, libgraph=None, **kwargs)[source] The basic class that contains a
graph_tool.Graph
and some of is properties or methods to easily access them.Variables: -
add_edges
(lst_edges)[source] Add a list of edges to the graph.
Parameters: - lst_edges (list of 2-tuples or np.array of shape (edge_nb, 2)) – List of the edges that should be added as tuples (source, target)
- @todo (add example, check the edges for self-loops and multiple edges)
-
adjacency_matrix
(typed=True, weighted=True)[source] Returns the adjacency matrix of the graph as a
scipy.sparse.csr_matrix
.Parameters: weighted (bool or string, optional (default: True)) – If True, each entry adj[i,j] = w_ij
wherew_ij
is the strength of the connection from i to j, if False,adj[i,j] = 0. or 1.
. Weighted can also be a string describing an edge attribute (e.g. if “distance” refers to an edge attributedist
, thenajacency_matrix("distance")
will returnadj[i,i] = dist_ij
).Returns: adj ( scipy.sparse.csr_matrix
) – The adjacency matrix of the graph.
-
attributes
()[source] List of the graph’s attributes (synaptic weights, delays...)
-
clear_edges
()[source] Remove all the edges in the graph.
-
copy
()[source] Returns a deepcopy of the current
Graph
instance
-
edge_nb
()[source] Number of edges in the graph
-
edges
-
excitatory_subgraph
()[source] create a
Graph
instance which graph contains only the excitatory edges of the current instance’sGraphObject
-
get_betweenness
(use_weights=True)[source] Betweenness centrality sequence of all nodes and edges.
Parameters: use_weights (bool, optional (default: True)) – Whether to use weighted (True) or simple degrees (False). Returns: - node_betweenness (
numpy.array
) – Betweenness of the nodes. - edge_betweenness (
numpy.array
) – Betweenness of the edges.
- node_betweenness (
-
get_degrees
(node_list=None, deg_type='total', use_weights=True)[source] Degree sequence of all the nodes.
Parameters: - node_list (list, optional (default: None)) – List of the nodes which degree should be returned
- deg_type (string, optional (default: “total”)) – Degree type (among ‘in’, ‘out’ or ‘total’).
- use_weights (bool, optional (default: True)) – Whether to use weighted (True) or simple degrees (False).
Returns: numpy.array
or None (if an invalid type is asked).
-
get_density
()[source] Density of the graph: \(\frac{E}{N^2}\), where E is the number of edges and N the number of nodes.
-
get_edge_types
()[source]
-
get_name
()[source] Get the name of the graph
-
get_weights
()[source] Returns the weighted adjacency matrix as a
scipy.sparse.lil_matrix
.
-
graph
graph_tool.Graph
attribute of the instance
-
id
unique
int
identifying the instance
-
inhibitory_subgraph
()[source] Create a
Graph
instance which graph contains only the inhibitory edges of the current instance’sgraph_tool.Graph
-
is_directed
()[source] Whether the graph is directed or not
-
is_weighted
()[source] Whether the edges have weights
-
name
name of the graph
-
node_nb
()[source] Number of nodes in the graph
-
classmethod
num_graphs
()[source] Returns the number of alive instances.
-
set_edge_attribute
(attribute, values=None, val=None, value_type=None)[source]
-
set_name
(name='')[source] set graph name
-
set_weights
(elist=None, wlist=None, distrib=None, distrib_prop=None, correl=None, noise_scale=None)[source] Set the synaptic weights.
Parameters: - elist (class:numpy.array, optional (default: None)) – List of the edges (for user defined weights).
- wlist (class:numpy.array, optional (default: None)) – List of the weights (for user defined weights).
- distrib (class:string, optional (default: None)) – Type of distribution (choose among “constant”, “uniform”, “gaussian”, “lognormal”, “lin_corr”, “log_corr”).
- distrib_prop (dict, optional (default: {})) – Dictoinary containing the properties of the weight distribution.
- correl (class:string, optional (default: None)) – Property to which the weights should be correlated.
- noise_scale (class:int, optional (default: None)) – Scale of the multiplicative Gaussian noise that should be applied on the weights.
-
-
class
nngt.
SpatialGraph
(nodes=0, name='Graph', weighted=True, directed=True, libgraph=None, shape=None, positions=None, **kwargs)[source] The detailed class that inherits from
Graph
and implements additional properties to describe various biological functions and interact with the NEST simulator.Variables: - shape –
Shape
Shape of the neurons environment. - positions –
numpy.array
Positions of the neurons. - graph –
GraphObject
Main attribute of the class instance.
-
classmethod
make_spatial
(graph, shape=<nngt.core.graph_datastruct.Shape instance>, positions=None)[source]
-
position
-
shape
- shape –
-
class
nngt.
Network
(name='Graph', weighted=True, directed=True, libgraph=None, population=None, **kwargs)[source] The detailed class that inherits from
Graph
and implements additional properties to describe various biological functions and interact with the NEST simulator.Variables: - population –
NeuralPop
Object reparting the neurons into groups with specific properties. - graph –
GraphObject
Main attribute of the class instance - nest_gid –
numpy.array
Array containing the NEST gid associated to each neuron; it isNone
until a NEST network has been created. - id_from_nest_gid – dict
Dictionary mapping each NEST gid to the corresponding neuron index in
the
nngt.~Network
-
classmethod
ei_network
(size, ei_ratio=0.2, en_model='aeif_cond_alpha', en_param={}, es_model='static_synapse', es_param={}, in_model='aeif_cond_alpha', in_param={}, is_model='static_synapse', is_param={})[source] Generate a network containing a population of two neural groups: inhibitory and excitatory neurons.
Parameters: - size (int) – Number of neurons in the network.
- ei_ratio (double, optional (default: 0.2)) – Ratio of inhibitory neurons: \(\frac{N_i}{N_e+N_i}\).
- en_model (string, optional (default: ‘aeif_cond_alpha’)) – Nest model for the excitatory neuron.
- en_param (dict, optional (default: {})) – Dictionary of parameters for the the excitatory neuron.
- es_model (string, optional (default: ‘static_synapse’)) – NEST model for the excitatory synapse.
- es_param (dict, optional (default: {})) – Dictionary containing the excitatory synaptic parameters.
- in_model (string, optional (default: ‘aeif_cond_alpha’)) – Nest model for the inhibitory neuron.
- in_param (dict, optional (default: {})) – Dictionary of parameters for the the inhibitory neuron.
- is_model (string, optional (default: ‘static_synapse’)) – NEST model for the inhibitory synapse.
- is_param (dict, optional (default: {})) – Dictionary containing the inhibitory synaptic parameters.
Returns: net (
Network
or subclass) – Network of disconnected excitatory and inhibitory neurons.
-
static
make_network
(graph, neural_pop)[source] Turn a
Graph
object into aNetwork
, or aSpatialGraph
into aSpatialNetwork
.Parameters: - graph (
Graph
orSpatialGraph
) – Graph to convert - neural_pop (
NeuralPop
) – Population to associate to the newNetwork
Notes
In-place operation that directly converts the original graph.
- graph (
-
neuron_properties
(idx_neuron)[source] Properties of a neuron in the graph.
Parameters: idx_neuron (int) – Index of a neuron in the graph. Returns: dict of the neuron properties.
-
classmethod
num_networks
()[source] Returns the number of alive instances.
-
population
NeuralPop
that divides the neurons into groups with specific properties.
-
classmethod
uniform_network
(size, neuron_model='aeif_cond_alpha', neuron_param={}, syn_model='static_synapse', syn_param={})[source] Generate a network containing only one type of neurons.
Parameters: - size (int) – Number of neurons in the network.
- neuron_model (string, optional (default: ‘aief_cond_alpha’)) – Name of the NEST neural model to use when simulating the activity.
- neuron_param (dict, optional (default: {})) – Dictionary containing the neural parameters; the default value will make NEST use the default parameters of the model.
- syn_model (string, optional (default: ‘static_synapse’)) – NEST synaptic model to use when simulating the activity.
- syn_param (dict, optional (default: {})) – Dictionary containing the synaptic parameters; the default value will make NEST use the default parameters of the model.
Returns: net (
Network
or subclass) – Uniform network of disconnected neurons.
- population –
-
class
nngt.
SpatialNetwork
(population, name='Graph', weighted=True, directed=True, shape=None, graph=None, positions=None, **kwargs)[source] Class that inherits from
Network
andSpatialGraph
to provide a detailed description of a real neural network in space, i.e. with positions and biological properties to interact with NEST.Variables: - shape –
nngt.core.Shape
Shape of the neurons environment. - positions –
numpy.array
Positions of the neurons. - population –
NeuralPop
Object reparting the neurons into groups with specific properties. - graph –
GraphObject
Main attribute of the class instance. - nest_gid –
numpy.array
Array containing the NEST gid associated to each neuron; it isNone
until a NEST network has been created. - id_from_nest_gid – dict
Dictionary mapping each NEST gid to the corresponding neuron index in
the
nngt.~SpatialNetwork
- shape –