def __init__( self, device_graph: Optional[UndirectedHypergraph] = None, crosstalk_graph: Optional[UndirectedHypergraph] = None, ) -> None: """Inits UndirectedGraphDevice. Args: device_graph: An undirected hypergraph whose vertices correspond to qubits and whose edges determine allowable operations and their durations. crosstalk_graph: An undirected hypergraph whose vertices are edges of device_graph and whose edges give simultaneity constraints thereon. Raises: TypeError: If the crosstalk graph is not a valid crosstalk graph. """ if device_graph is None: device_graph = UndirectedHypergraph() if not is_undirected_device_graph(device_graph): raise TypeError(f'not is_undirected_device_graph({device_graph})') if crosstalk_graph is None: crosstalk_graph = UndirectedHypergraph() if not is_crosstalk_graph(crosstalk_graph): raise TypeError(f'not is_crosstalk_graph({crosstalk_graph})') self.device_graph = device_graph self.crosstalk_graph = crosstalk_graph
def uniform_undirected_graph_device( edges: Iterable[Iterable[ops.Qid]], edge_label: Optional[UndirectedGraphDeviceEdge] = None ) -> UndirectedGraphDevice: """An undirected graph device all of whose edges are the same. Args: edges: The edges. edge_label: The label to apply to all edges. Defaults to None. """ labelled_edges = {frozenset(edge): edge_label for edge in edges} # type: Dict[Iterable[Hashable], Any] device_graph = UndirectedHypergraph(labelled_edges=labelled_edges) return UndirectedGraphDevice(device_graph=device_graph)