Analysis module

Content

nngt.analysis.degree_distrib(net, deg_type='total', node_list=None, use_weights=True, log=False, num_bins=30)[source]

Computing the degree distribution of a network.

Parameters:
  • net (Graph or subclass) – the network to analyze.
  • deg_type (string, optional (default: “total”)) – type of degree to consider (“in”, “out”, or “total”).
  • node_list (list or numpy.array of ints, optional (default: None)) – Restrict the distribution to a set of nodes (default: all nodes).
  • use_weights (bool, optional (default: True)) – use weighted degrees (do not take the sign into account: all weights are positive).
  • log (bool, optional (default: False)) – use log-spaced bins.
Returns:

  • counts (numpy.array) – number of nodes in each bin
  • deg (numpy.array) – bins

nngt.analysis.betweenness_distrib(net, use_weights=True, log=False)[source]

Computing the betweenness distribution of a network

Parameters:
  • net (Graph or subclass) – the network to analyze.
  • use_weights (bool, optional (default: True)) – use weighted degrees (do not take the sign into account : all weights are positive).
  • log (bool, optional (default: False)) – use log-spaced bins.
Returns:

  • ncounts (numpy.array) – number of nodes in each bin
  • nbetw (numpy.array) – bins for node betweenness
  • ecounts (numpy.array) – number of edges in each bin
  • ebetw (numpy.array) – bins for edge betweenness

nngt.analysis.assortativity(net, deg_type='total')[source]

Assortativity of the graph. àtodo: check how the various libraries functions work.

Parameters:
  • net (Graph or subclass) – Network to analyze.
  • deg_type (string, optional (default: ‘total’)) – Type of degree to take into account (among ‘in’, ‘out’ or ‘total’).
Returns:

a float describing the network assortativity.

nngt.analysis.reciprocity(net)[source]

Returns the network reciprocity, defined as \(E^\leftrightarrow/E\), where \(E^\leftrightarrow\) and \(E\) are, respectively, the number of bidirectional edges and the total number of edges in the network.

nngt.analysis.clustering(net)[source]

Returns the global clustering coefficient of the graph, defined as

\[c = 3 imes\]
rac{ ext{number of triangles}}
{ ext{number of connected triples}}
nngt.analysis.num_iedges(net)[source]

Returns the number of inhibitory connections.

nngt.analysis.num_scc(net, listing=False)[source]

Returns the number of strongly connected components, i.e. ensembles where all nodes inside the ensemble can reach any other node in the ensemble using the directed edges.

See also

num_wcc()

nngt.analysis.num_wcc(net, listing=False)[source]

Connected components if the directivity of the edges is ignored (i.e. all edges are considered as bidirectional).

See also

num_scc()

nngt.analysis.diameter(net)[source]

Pseudo-diameter of the graph @todo: weighted diameter

nngt.analysis.spectral_radius(net, typed=True, weighted=True)[source]

Spectral radius of the graph, defined as the eigenvalue of greatest module.

Parameters:
  • net (Graph or subclass) – Network to analyze.
  • typed (bool, optional (default: True)) – Whether the excitatory/inhibitory type of the connnections should be considered.
  • weighted (bool, optional (default: True)) – Whether the weights should be taken into account.
Returns:

the spectral radius as a float.

nngt.analysis.adjacency_matrix(net, typed=True, weighted=True)[source]

Adjacency matrix of the graph.

Parameters:
  • net (Graph or subclass) – Network to analyze.
  • typed (bool, optional (default: True)) – Whether the excitatory/inhibitory type of the connnections should be considered (only if the weighing factor is the synaptic strength).
  • weighted (bool, optional (default: True)) – Whether weights should be taken into account; if True, then connections are weighed by their synaptic strength, if False, then a binary matrix is returned, if weighted is a string, then the ponderation is the correponding value of the edge attribute (e.g. “distance” will return an adjacency matrix where each connection is multiplied by its length).
Returns:

a csr_matrix.