navis.betweeness_centrality¶
- navis.betweeness_centrality(x, from_=None, directed=True)[source]¶
Calculate vertex/node betweenness.
Betweenness is (roughly) defined by the number of shortest paths going through a vertex or an edge.
- Parameters:
x (TreeNeuron | MeshNeuron | NeuronList) –
from ("leafs" | "branch_points" | iterable, optional) –
If provided will only consider paths from given nodes to root(s):
leafs
will only use paths from leafs to the rootbranch_points
will only use paths from branch points to the rootfrom_
can also be a list/array of node IDs
Only implemented for
directed=True
!directed (bool) – Whether to use the directed or undirected graph.
parallel (bool) – If True and input is NeuronList, use parallel processing. Requires pathos.
n_cores (int, optional) – Numbers of cores to use if
parallel=True
. Defaults to half the available cores.progress (bool) – Whether to show a progress bar. Overruled by
navis.set_pbars
.omit_failures (bool) – If True will omit failures instead of raising an exception. Ignored if input is single neuron.
- Returns:
Adds “betweenness” as column in the node table (for TreeNeurons) or as
.betweenness
property (for MeshNeurons).- Return type:
neuron
Examples
>>> import navis >>> n = navis.example_neurons(2, kind='skeleton') >>> n.reroot(n.soma, inplace=True) >>> _ = navis.betweeness_centrality(n) >>> n[0].nodes.betweenness.max() 436866 >>> m = navis.example_neurons(1, kind='mesh') >>> _ = navis.betweeness_centrality(m) >>> m.betweenness.max() 59637