DagCircuit
QuICT.core.circuit.dag_circuit.DAGNode ¶
The node in DAG Circuit, represent a quantum gate in circuit.
Parameters:
-
id(int) –The unique identity, usually be the quantum gates' index
-
gate(BasicGate) –The quantum gate
-
successors(list, default:None) –The successors for nodes. Defaults to [].
-
predecessors(list, default:None) –The predecessors for nodes. Defaults to [].
Source code in QuICT/core/circuit/dag_circuit.py
append_pred ¶
QuICT.core.circuit.DAGCircuit ¶
The DAG Circuit using networkx.DiGraph()
The nodes in the graph represented the quantum gates, and the edges means the two quantum gates is non-commutation. In other words, a directed edge between node A with quantum gate GA and node B with quantum gate GB, the quantum gate GA does not commute with GB.
The nodes in the graph have the following attributes: 'name', 'gate', 'cargs', 'targs', 'qargs', 'successors', 'predecessors'.
Reference
[1] Iten, R., Moyard, R., Metger, T., Sutter, D. and Woerner, S., 2020. Exact and practical pattern matching for quantum circuit optimization. https://arxiv.org/abs/1909.05270
Parameters:
-
circuit(Circuit) –The quantum circuit.
Source code in QuICT/core/circuit/dag_circuit.py
__getitem__ ¶
to fit the slice operator, overloaded this function.
get a smaller qureg/qubit from this circuit
Parameters:
-
item(int/slice)–slice passed in.
Return: Qubit/Qureg: the result or slice
Source code in QuICT/core/circuit/dag_circuit.py
add_edge ¶
Add a directed edge to DAG.
Parameters:
-
u(int)–start node
-
v(int)–end node
add_node ¶
Add a node into DAG.
Parameters:
-
node(DAGNode) –The DAG Node
Source code in QuICT/core/circuit/dag_circuit.py
all_predecessors ¶
Return all predecessors (direct and indirect) of start.
start can be a node id (int) or many node ids (Iterable).
Parameters:
-
start(int/Iterable)–the start node(s)
Returns:
-
set(Set[int]) –set of predecessors
Source code in QuICT/core/circuit/dag_circuit.py
all_successors ¶
Return all successors (direct and indirect) of start.
Parameters:
-
start(int/Iterable)–the start node(s)
Returns:
-
Set[int]–Set[int]: set of successors
Source code in QuICT/core/circuit/dag_circuit.py
draw ¶
Draw a DAG circuit, save as jpg file.
Parameters:
-
layout(layout, default:shell_layout) –The networkx.layout. Defaults to nx.shell_layout.
Source code in QuICT/core/circuit/dag_circuit.py
edges ¶
get_node ¶
Get DAG node's data.
Parameters:
-
node_id(int) –the unique identity for node
in_edges ¶
Get all in-edges of node with given node id.
Parameters:
-
node_id(int) –the unique identity for node
nodes ¶
out_edges ¶
Get all out-edges of node with given node id.
Parameters:
-
node_id(int) –the unique identity for node