Note
This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.
partition_edges¶
- partition_edges(graph, distance, edge_subset=None, node_subset=None)[source]¶
Partition graph edges into groups with minimum distance between edges in each group.
Partitions the edges in the graph into groups, such that in each group the minimum distance (one plus number of edges in the shortest path) between edges is at least distance.
Note that “distance 1” for edges means that the two edges share a qubit. So two edges that are next to each other but do not share a qubit (they have qubits that are distance 1 apart) are distance 2 apart. For example, to partition into groups of edges with adjacent qubits, distance should be set to 2.
Returns a list of list of pairs of integers, i.e., a list of groups of edges.
If node_subset is not None then the partitioning contains only edges where both nodes belong to node_subset. If edge_subset is not None then the partitioning contains only edges that belong to edge_subset. It is not allowed to set both node_subset and edge_subset to values different from None.
- Parameters:
graph (PyGraph) – A rustworkx.PyGraph instance
distance (int) – Minimum distance between edges in the same group
edge_subset (list | None) – Optional subset of edges to partition
node_subset (list | None) – Optional subset of nodes; only edges between these nodes are included
- Returns:
List of groups of edges (qubit pairs)
- Raises:
ValueError – If both edge_subset and node_subset are specified
- Return type:
list
Note
This uses a greedy graph coloring algorithm on the line graph. It may not produce the optimal partitioning, but it’s simple and fast.