iqm.qrisp_iqm.passes.default_pass_manager.shift_graph_edges

iqm.qrisp_iqm.passes.default_pass_manager.shift_graph_edges#

iqm.qrisp_iqm.passes.default_pass_manager.shift_graph_edges(edges: list[tuple[int, int]], removed_nodes: list[int], removed_edges: list[tuple[int, int]] | None = None) → list[tuple[int, int]]#

Removes specified edges and nodes from a graph, then shifts the indices of the remaining nodes.

Parameters:
  • edges (list of tuple of int) – List of edges in the graph, where each edge is represented as a tuple (a, b) with node indices.

  • removed_nodes (list of int) – List of node indices to be removed from the graph.

  • removed_edges (list of tuple of int or None, optional) – List of edges to be removed from the graph before processing node removals and shifts. Each edge should be a tuple (a, b), using the initial node indices. Default is None (no additional edges removed).

Returns:

new_edges – List of edges for the updated graph after specified edges and nodes have been removed, with all node indices shifted so that remaining indices are contiguous from 0 to n - k - 1, where k is the number of removed nodes.

Return type:

list of tuple of int

Notes

  • All edges in removed_edges are eliminated from the initial edge list before node removal and index shifting.

  • Edges connected to any removed node are omitted.

  • After removal, all node indices greater than the removed nodes are decreased by the number of removed nodes with lower index, to ensure contiguous numbering from 0 upwards.