TopologyGraph#
- class braintools.visualize.morphology.TopologyGraph(node_ids, edges, root_id, level='node', values=None, value_label=None, highlight_fractions=None, times=None)[source]#
A rooted graph with optional per-node values or highlight fractions.
The input of
plot_topology_graph(). Nodes are integer identifiers (for example branch indices, control-volume IDs or solver-node IDs).- Parameters:
node_ids (
tuple[int,...]) – Node identifiers;valuesis aligned with this order.edges (
tuple[tuple[int,int],...]) –(parent_id, child_id)pairs.root_id (
int) – Identifier of the root node.level (
str) – What a node represents,"node"(default),"cv"or"branch"."branch"graphs are topology-only:plot_topology_graph()rejects colour-map arguments for them.values (
Any) – Per-node values, shape(N,)or(T, N)forTframes.NaNmarks nodes without a value.highlight_fractions (
Mapping[int,float] |None) – Node identifier to highlight intensity in[0, 1]. Mutually exclusive withvalues.times (
Any) – Frame times, shape(T,); only with two-dimensionalvalues.
- Raises:
ValueError – If node identifiers repeat, an edge or the root names an unknown node,
valuesdoes not matchlen(node_ids),valuesandhighlight_fractionsare both given, ortimesdoes not match the frame count.
Examples
>>> import numpy as np >>> from braintools.visualize.morphology import TopologyGraph >>> graph = TopologyGraph( ... node_ids=(0, 1, 2), edges=((0, 1), (0, 2)), root_id=0, ... values=np.array([[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]]), ... ) >>> graph.n_frames 2 >>> graph.frame(1) array([2., 3., 4.])
- frame(index=None)[source]#
Return the
(N,)values of one frame.- Parameters:
index (
int|None) – Frame index; must be given whenvaluesis two-dimensional.- Raises:
ValueError – If
valuesis two-dimensional andindexisNone.- Return type: