Skip to main content
IBM Quantum Platform

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

GitHub

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.

Was this page helpful?
Report a bug, typo, or request content on GitHub.