Skip to content


#   class Graph(networkx.classes.graph.Graph):

Contains a collection of nodes and edges. This class inherits from networkx.Graph. For further methods, please check the networkx documentation.

See Graph.__init__ for more details.

A small usage example:

graph = skeleton.add_graph("a graph")
node_1 = graph.add_node(position=(0, 0, 0), comment="node 1")
node_2 = graph.add_node(position=(100, 100, 100), comment="node 2")

graph.add_edge(node_1, node_2)
#   Graph( name: str, group:, skeleton: webknossos.skeleton.skeleton.Skeleton, color: Union[Tuple[float, float, float, float], NoneType] = None, enforced_id: Union[int, NoneType] = None )

To create a graph, it is recommended to use Skeleton.add_graph or Group.add_graph. That way, the newly created graph is automatically attached as a child to the object the method was called on.

#   id: int

Read-only property.

#   def get_node_positions(self) -> numpy.ndarray:

Returns an numpy array with the positions of all nodes of this graph.

#   def get_node_by_id(self, node_id: int) -> webknossos.skeleton.node.Node:

Returns the node in this graph with the requested id.

#   def add_node( self, position: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], comment: Union[str, NoneType] = None, radius: Union[float, NoneType] = None, rotation: Union[Tuple[float, float, float], NoneType] = None, inVp: Union[int, NoneType] = None, inMag: Union[int, NoneType] = None, bitDepth: Union[int, NoneType] = None, interpolation: Union[bool, NoneType] = None, time: Union[int, NoneType] = None, is_branchpoint: bool = False, branchpoint_time: Union[int, NoneType] = None, _enforced_id: Union[int, NoneType] = None ) -> webknossos.skeleton.node.Node:

Adds a node to the graph. Apart from the mandatory position parameter, there are several optional parameters which can be used to encode additional information. For example, the comment will be shown by the webKnossos UI.

#   def get_max_node_id(self) -> int:

Returns the highest node id.

Back to top