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

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

Initialize a graph with edges, name, or graph attributes.


incoming_graph_data : input graph (optional, default: None) Data to initialize graph. If None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a NumPy matrix or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph.

attr : keyword arguments, optional (default= no attributes) Attributes to add to graph as key=value pairs.

See Also



>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G = nx.Graph(name="my graph")
>>> e = [(1, 2), (2, 3), (3, 4)]  # list of edges
>>> G = nx.Graph(e)

Arbitrary graph attribute pairs (key=value) may be assigned

>>> G = nx.Graph(e, day="Friday")
>>> G.graph
{'day': 'Friday'}
#   id: int
#   def get_node_positions(self) -> numpy.ndarray:
#   def get_node_by_id(self, node_id: int) -> webknossos.skeleton.node.Node:
#   def add_node( self, position: Tuple[float, float, float], 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:

Add a single node node_for_adding and update node attributes.


node_for_adding : node A node can be any hashable Python object except None. attr : keyword arguments, optional Set or change node attributes using key=value.

See Also



>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_node(1)
>>> G.add_node("Hello")
>>> K3 = nx.Graph([(0, 1), (1, 2), (2, 0)])
>>> G.add_node(K3)
>>> G.number_of_nodes()

Use keywords set/change node attributes:

>>> G.add_node(1, size=10)
>>> G.add_node(3, weight=0.4, UTM=("13S", 382871, 3972649))


A hashable object is one that can be used as a key in a Python dictionary. This includes strings, numbers, tuples of strings and numbers, etc.

On many platforms hashable items also include mutables such as NetworkX Graphs, though one should be careful that the hash doesn't change on mutables.

#   def get_max_node_id(self) -> int:
Back to top