opto.trace.nodes.Graph#
- class Graph[source]#
Graph is a registry of all the nodes, forming a Directed Acyclic Graph (DAG).
- _nodes#
An instance-level attribute, which is a defaultdict of lists, used as a lookup table to find nodes by name.
- Type:
defaultdict
Notes
The Graph class manages and organizes nodes in a Directed Acyclic Graph (DAG). It provides methods to register nodes, clear the graph, retrieve nodes by name, and identify root nodes. The register method assumes that elements in _nodes are never removed, which is important for maintaining the integrity of node names.
Initialize the Graph object.
The initialization sets up the _nodes attribute as a defaultdict of lists to store nodes by their names.
Attributes
Get all root nodes in the graph.
Methods
clear
()Remove all nodes from the graph.
get
(name)Retrieve a node from the graph by its name.
register
(node)Add a node to the graph.
- __init__()[source]#
Initialize the Graph object.
The initialization sets up the _nodes attribute as a defaultdict of lists to store nodes by their names.
- __new__(**kwargs)#