- navis.betweeness_centrality(x, from_=None, directed=True)¶
Calculate vertex/node betweenness.
Betweenness is (roughly) defined by the number of shortest paths going through a vertex or an edge.
from ("leafs" | "branch_points" | iterable, optional) –
If provided will only consider paths from given nodes to root(s):
leafswill only use paths from leafs to the root
branch_pointswill only use paths from branch points to the root
from_can also be a list/array of node IDs
Only implemented for
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
omit_failures (bool) – If True will omit failures instead of raising an exception. Ignored if input is single neuron.
Adds “betweenness” as column in the node table (for TreeNeurons) or as
.betweennessproperty (for MeshNeurons).
- Return type:
>>> import navis >>> n = navis.example_neurons(2, kind='skeleton') >>> n.reroot(n.soma, inplace=True) >>> _ = navis.betweeness_centrality(n) >>> n.nodes.betweenness.max() 436866 >>> m = navis.example_neurons(1, kind='mesh') >>> _ = navis.betweeness_centrality(m) >>> m.betweenness.max() 59637