replace_nodes_with_one_node¶
- samplomatic.graph_utils.replace_nodes_with_one_node(graph: PyDiGraph[T, S], node_idxs: Iterable[int], new_node: T) int[source]¶
Replace given nodes with a single node, preserving all outward/inward edges.
- Parameters:
graph – The graph to mutate.
node_idxs – The connected nodes to replace.
new_node – The node to replace them with.
- Returns:
The index of the new node in the graph.