CouplingGraph
- class CouplingGraph(graph, num_qudits=None, remote_edges=[], default_weight=1.0, default_remote_weight=100.0, edge_weights_overrides={})[source]
Bases:
Collection[tuple[int,int]]A graph representing connections in a qudit topology.
- __init__(graph, num_qudits=None, remote_edges=[], default_weight=1.0, default_remote_weight=100.0, edge_weights_overrides={})[source]
Construct a new CouplingGraph.
- Parameters:
graph (
CouplingGraphLike) – The undirected graph edges.num_qudits (
int | None) – The number of qudits in the graph. If None, the number of qudits is inferred from the maximum seen in the edge list. (Default: None)remote_edges (
Iterable[tuple[int,int]]) – The edges that cross QPU chip boundaries. Distributed QPUs will have remote links connect them. Notes, remote edges must specified both in graph and here. (Default: [])default_weight (
float) – The default weight of an edge in the graph. (Default: 1.0)default_remote_weight (
float) – The default weight of a remote edge in the graph. (Default: 100.0)edge_weights_overrides (
Mapping[tuple[int,int],float]) – A mapping of edges to their weights. These override the defaults on a case-by-case basis. (Default: {})
Notes
The qudits are assumed to be numbered starting from 0.
- Raises:
ValueError – If num_qudits is too small for the edges in graph.
ValueError – If num_qudits is less than zero.
ValueError – If any edge in remote_edges is not in graph.
ValueError – If any edge in edge_weights_overrides is not in graph.
Methods
Calculate all pairs shortest path matrix using Floyd-Warshall.
all_to_all(num_qudits)Return a coupling graph with all qudits connected.
Return a list of individual QPU graphs.
get_induced_subgraph(location)Return the edges induced by the vertices specified in location.
get_neighbors_of(qudit)Return the qudits adjacent to qudit.
Return the adjacency list of the QPUs.
Return a mapping of QPU indices to qudit indices.
Return a mapping of qudit indices to QPU indices.
get_rooted_minimum_span(root)Connect root to every other node in the graph.
get_shortest_path_tree(source)Return shortest path from source to every node in self.
get_subgraph(location[, renumbering])Returns the sub-coupling-graph with qudits in location.
get_subgraphs_of_size(size)Find all sets of indices that form connected subgraphs on their own.
grid(num_rows, num_cols)Return a coupling graph with a grid of qubits.
Return true if the graph represents multiple connected QPUs.
is_embedded_in(graph)Check if this CouplingGraph is embedded within graph.
Return true if the graph is fully connected.
is_fully_connected_without(qudit)Return true if the graph is fully connected without qudit.
Return true if the graph is linearly connected.
is_valid_coupling_graph(coupling_graph[, ...])Return true if the coupling graph is valid.
linear(num_qudits)Return a coupling graph with nearest-neighbor connectivity.
maximal_matching([edges_to_ignore, randomize])Generate a random graph matching for the coupling graph.
Return the number of connected QPUs.
relabel_subgraph([relabeling])Renumber the vertices in graph according to the optionally provided relabeling dictionary, or relabel so that the vertices are in renumbered in least to greatest order and in the set {0,...,|V|-1}.
ring(num_qudits)Return a coupling graph with ring connectivity.
star(num_qudits)Return a coupling graph with one qudit connected to all else.