nngt.
Graph
(nodes=0, name='Graph', weighted=True, directed=True, from_graph=None, **kwargs)[source]¶The basic graph class, which inherits from a library class such as
gt.Graph
, networkx.DiGraph
, or igraph.Graph.
The objects provides several functions to easily access some basic properties.
Initialize Graph instance
Parameters: |
|
---|---|
Returns: | self ( |
attributes
(edge=None, name=None)[source]¶Attributes of the graph’s edges.
Parameters: |
|
---|---|
Returns: |
|
eattr_class
¶alias of _GtEProperty
edge_id
(edge)¶Return the ID a given edge or a list of edges in the graph. Raises an error if the edge is not in the graph or if one of the vertices in the edge is nonexistent.
Parameters: | edge (2-tuple or array of edges) – Edge descriptor (source, target). |
---|---|
Returns: | index (int or array of ints) – Index of the given edge. |
edges_array
¶Edges of the graph, sorted by order of creation, as an array of 2-tuple.
edges_attributes
¶Access edge attributes
New in version 0.7.
from_file
(filename, fmt='auto', separator=' ', secondary=';', attributes=None, notifier='@', ignore='#', from_string=False)[source]¶Import a saved graph from a file. @todo: implement population and shape loading, implement gml, dot, xml, gt
Parameters: |
|
---|---|
Returns: | graph ( |
from_matrix
(matrix, weighted=True, directed=True)[source]¶Creates a Graph
from a scipy.sparse
matrix or
a dense matrix.
Parameters: |
|
---|---|
Returns: |
get_betweenness
(btype='both', use_weights=False)[source]¶Betweenness centrality sequence of all nodes and edges.
Parameters: |
|
---|---|
Returns: |
|
get_degrees
(deg_type='total', node_list=None, use_weights=False)[source]¶Degree sequence of all the nodes.
Parameters: |
|
---|---|
Returns: |
|
get_delays
()[source]¶Returns the delay adjacency matrix as a
scipy.sparse.lil_matrix
if delays are present; else raises
an error.
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_weights
()[source]¶Returns the weighted adjacency matrix as a
scipy.sparse.lil_matrix
.
is_network
()[source]¶Whether the graph is a subclass of Network
(i.e. if it
has a NeuralPop
attribute).
is_spatial
()[source]¶Whether the graph is embedded in space (i.e. if it has a
Shape
attribute).
Returns True
is the graph is a subclass of
SpatialGraph
.
make_network
(graph, neural_pop, copy=False, **kwargs)[source]¶Turn a Graph
object into a Network
, or a
SpatialGraph
into a SpatialNetwork
.
Parameters: |
|
---|
Notes
In-place operation that directly converts the original graph if copy
is False
, else returns the copied Graph
turned into
a Network
.
make_spatial
(graph, shape=None, positions=None, copy=False)[source]¶Turn a Graph
object into a SpatialGraph
,
or a Network
into a SpatialNetwork
.
Parameters: |
|
---|
Notes
In-place operation that directly converts the original graph if copy
is False
, else returns the copied Graph
turned into
a SpatialGraph
.
The shape argument can be skipped if positions are given; in that
case, the neurons will be embedded in a rectangle that contains them
all.
name
¶Name of the graph.
nattr_class
¶alias of _GtNProperty
neighbours
(node, mode='all')¶Return the neighbours of node.
Parameters: |
|
---|---|
Returns: | neighbours (tuple) – The neighbours of node. |
new_edge
(source, target, attributes=None, ignore=False)¶Adding a connection to the graph, with optional properties.
Parameters: |
|
---|---|
Returns: | The new connection. |
new_edge_attribute
(name, value_type, values=None, val=None)[source]¶Create a new attribute for the edges.
New in version 0.7.
Parameters: |
|
---|
new_edges
(edge_list, attributes=None)¶Add a list of edges to the graph.
Warning
This function currently does not check for duplicate edges!
Parameters: |
|
---|
new_node
(n=1, ntype=1, attributes=None, value_types=None)¶Adding a node to the graph, with optional properties.
Parameters: |
|
---|---|
Returns: | The node or a tuple of the nodes created. |
new_node_attribute
(name, value_type, values=None, val=None)[source]¶Create a new attribute for the nodes.
New in version 0.7.
Parameters: |
|
---|
nodes_attributes
¶Access node attributes
New in version 0.7.
set_delays
(delay=None, elist=None, distribution=None, parameters=None, noise_scale=None)[source]¶Set the delay for spike propagation between neurons. ..todo :: take elist into account in Connections.delays
Parameters: |
|
---|
set_edge_attribute
(attribute, values=None, val=None, value_type=None, edges=None)[source]¶Set attributes to the connections between neurons.
Warning
The special “type” attribute cannot be modified when using graphs
that inherit from the Network
class. This is because
for biological networks, neurons make only one kind of synapse,
which is determined by the nngt.NeuralGroup
they
belong to.
Parameters: |
|
---|
set_types
(syn_type, nodes=None, fraction=None)[source]¶Set the synaptic/connection types.
Warning
The special “type” attribute cannot be modified when using graphs
that inherit from the Network
class. This is because
for biological networks, neurons make only one kind of synapse,
which is determined by the nngt.NeuralGroup
they
belong to.
Parameters: |
|
---|---|
Returns: | t_list ( |
set_weights
(weight=None, elist=None, distribution=None, parameters=None, noise_scale=None)[source]¶Set the synaptic weights.
Parameters: |
|
---|
to_file
(filename, fmt='auto', separator=' ', secondary=';', attributes=None, notifier='@')[source]¶Save graph to file; options detailed below.
See also
nngt.lib.save_to_file()
function for options.
type
¶Type of the graph.
nngt.
SpatialGraph
(nodes=0, name='Graph', weighted=True, directed=True, from_graph=None, shape=None, positions=None, **kwargs)[source]¶The detailed class that inherits from Graph
and implements
additional properties to describe spatial graphs (i.e. graph where the
structure is embedded in space.
Initialize SpatialClass instance. .. todo:: see what we do with the from_graph argument
Parameters: |
|
---|---|
Returns: | self ( |
get_positions
(neurons=None)[source]¶Returns the neurons’ positions as a (N, 2) array.
Parameters: | neurons (int or array-like, optional (default: all neurons)) – List of the neurons for which the position should be returned. |
---|
shape
¶nngt.
Network
(name='Network', weighted=True, directed=True, from_graph=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.
Initializes Network
instance.
Parameters: |
|
---|---|
Returns: | self ( |
ei_network
(size, ei_ratio=0.2, en_model='aeif_cond_alpha', en_param=None, es_model='static_synapse', es_param=None, in_model='aeif_cond_alpha', in_param=None, is_model='static_synapse', is_param=None, **kwargs)[source]¶Generate a network containing a population of two neural groups: inhibitory and excitatory neurons.
Parameters: |
|
---|---|
Returns: | net ( |
from_gids
(gids, get_connections=True, get_params=False, neuron_model='aeif_cond_alpha', neuron_param=None, syn_model='static_synapse', syn_param=None, **kwargs)[source]¶Generate a network from gids.
Warning
Unless get_connections and get_params is True, or if your
population is homogeneous and you provide the required information, the
information contained by the network and its population attribute
will be erroneous!
To prevent conflicts the to_nest()
function is not
available. If you know what you are doing, you should be able to find a
workaround...
Parameters: |
|
---|---|
Returns: | net ( |
get_neuron_type
(neuron_ids)[source]¶Return the type of the neurons (+1 for excitatory, -1 for inhibitory).
Parameters: | neuron_ids (int or tuple) – NEST gids. |
---|---|
Returns: | ids (int or tuple) – Ids in the network. Same type as the requested gids type. |
id_from_nest_gid
(gids)[source]¶Return the ids of the nodes in the nngt.Network
instance from
the corresponding NEST gids.
Parameters: | gids (int or tuple) – NEST gids. |
---|---|
Returns: | ids (int or tuple) – Ids in the network. Same type as the requested gids type. |
nest_gid
¶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’s properties. |
to_nest
(use_weights=True)[source]¶Send the network to NEST.
See also
make_nest_network()
for parameters
uniform_network
(size, neuron_model='aeif_cond_alpha', neuron_param=None, syn_model='static_synapse', syn_param=None, **kwargs)[source]¶Generate a network containing only one type of neurons.
Parameters: |
|
---|---|
Returns: | net ( |
nngt.
SpatialNetwork
(population, name='Graph', weighted=True, directed=True, shape=None, from_graph=None, positions=None, **kwargs)[source]¶Class that inherits from Network
and SpatialGraph
to provide a detailed description of a real neural network in space, i.e.
with positions and biological properties to interact with NEST.
Initialize Graph instance
Parameters: |
|
---|---|
Returns: | self ( |