as_topology_graph

as_topology_graph#

class braintools.visualize.morphology.as_topology_graph(obj)[source]#

Return obj as TopologyGraph.

Parameters:

obj (Any) – The graph itself, or an object whose __topology_data__() method returns it (for example a simulator’s solver-node tree).

Raises:

TypeError – If obj is neither, or its __topology_data__() does not return TopologyGraph.

Return type:

TopologyGraph

Examples

>>> from braintools.visualize.morphology import TopologyGraph, as_topology_graph
>>> graph = TopologyGraph(node_ids=(0, 1), edges=((0, 1),), root_id=0)
>>> as_topology_graph(graph) is graph
True