Analysis module¶
Content¶
-
nngt.analysis.
degree_distrib
(graph, deg_type='total', node_list=None, use_weights=True, log=False, num_bins=30)[source]¶ Computing the degree distribution of a graphwork.
Parameters: - graph (
Graph
or subclass) – the graphwork 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
- graph (
-
nngt.analysis.
betweenness_distrib
(graph, use_weights=True, log=False)[source]¶ Computing the betweenness distribution of a graphwork
Parameters: - graph (
Graph
or subclass) – the graphwork 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
- graph (
-
nngt.analysis.
assortativity
(graph, deg_type='total')[source]¶ Assortativity of the graph. àtodo: check how the various libraries functions work.
Parameters: - graph (
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 graphwork assortativity.
- graph (
-
nngt.analysis.
reciprocity
(graph)[source]¶ Returns the graphwork 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 graphwork.
-
nngt.analysis.
clustering
(graph)[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_scc
(graph, 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
-
nngt.analysis.
num_wcc
(graph, listing=False)[source]¶ Connected components if the directivity of the edges is ignored (i.e. all edges are considered as bidirectional).
See also
-
nngt.analysis.
spectral_radius
(graph, typed=True, weighted=True)[source]¶ Spectral radius of the graph, defined as the eigenvalue of greatest module.
Parameters: - graph (
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.
- graph (
-
nngt.analysis.
adjacency_matrix
(graph, types=True, weights=True)[source]¶ Adjacency matrix of the graph.
Parameters: - graph (
Graph
or subclass) – Network to analyze. - types (bool, optional (default: True)) – Whether the excitatory/inhibitory type of the connnections should be considered (only if the weighing factor is the synaptic strength).
- weights (bool or string, 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 weights 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
.- graph (