waveform_editor.dependency_graph.DependencyGraph

class waveform_editor.dependency_graph.DependencyGraph

Bases: object

Manages 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.

Parameters:
name

The name of the node.

dependencies

Set of new dependencies for the node.

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.

Parameters:
name

Node name to check.

dependencies

Set of new dependencies for the node.

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.

remove_node(name)

Remove a node from the graph.

Parameters:
name

Node name to remove.

rename_node(old_name, new_name)

Rename a node and update all dependencies referencing it.

Parameters:
old_name

Name of the existing node.

new_name

New node name.

Returns:

Names of nodes that depended on the renamed node.

replace_node(name, dependencies)

Replace the dependencies of an existing node or add it if missing.

Parameters:
name

The name of the node.

dependencies

Set of new dependencies for the node.


Last update: 2026-05-21