waveform_editor.dependency_graph.DependencyGraph¶
- class waveform_editor.dependency_graph.DependencyGraph¶
Bases:
objectManages dependencies between nodes (e.g., waveforms) and enforces acyclic constraints.
- __init__()¶
Methods
__init__()add_node(name, dependencies)Add a new node with specified dependencies.
check_safe_to_remove(name)Verify that a node can be removed without breaking dependencies.
check_safe_to_replace(name, dependencies)Check if replacing a node's dependencies would introduce cycles.
detect_cycles([start_node])Detect cycles in the graph, optionally starting from a specific node.
remove_node(name)Remove a node from the graph.
rename_node(old_name, new_name)Rename a node and update all dependencies referencing it.
replace_node(name, dependencies)Replace the dependencies of an existing node or add it if missing.
- add_node(name, dependencies)¶
Add a new node with specified dependencies. Validates that there are no cycles and removes node on failure.
- check_safe_to_remove(name)¶
Verify that a node can be removed without breaking dependencies.
- Parameters:
- name¶
Node name to check.
- check_safe_to_replace(name, dependencies)¶
Check if replacing a node's dependencies would introduce cycles.
-
detect_cycles(start_node=
None)¶ Detect cycles in the graph, optionally starting from a specific node. Raises RuntimeError if a circular dependency is found.
- Parameters:
- start_node=
None¶ Node to start detection from. Checks entire graph if None.
- start_node=
- replace_node(name, dependencies)¶
Replace the dependencies of an existing node or add it if missing.