opto.trace.nodes.Graph.register

Contents

opto.trace.nodes.Graph.register#

Graph.register(node)[source]#

Add a node to the graph.

Parameters:

node – The node object to be registered in the graph.

Notes

The register function should only be called after the node has been properly initialized and its name has been set. The function assumes that elements in the _nodes dictionary never get removed. After checking that the input is a Node and its name has the right format, the function splits the name of the node into the name variable and the identifier. The function then checks if there are any name scopes defined in the NAME_SCOPES list. If the length of the list is greater than 0, the name is prefixed with the last scope in the list followed by a “/”. This allows for scoping of node names. Finally, the function adds the node to the _nodes dictionary using the modified name as the key. The _name attribute of the node is set to the modified name followed by the index of the node in the list of nodes with the same name.