1.8K Star 3K Fork 4.3K

GVPMindSpore/mindquantum

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mindquantum.algorithm.compiler.DAGCircuit.rst 1.87 KB
一键复制 编辑 原始数据 按行查看 历史
dsdsdshe 提交于 9个月前 . fix docs

mindquantum.algorithm.compiler.DAGCircuit

.. py:class:: mindquantum.algorithm.compiler.DAGCircuit(circuit: Circuit)

    量子线路的有向无环图表示(Directed acyclic graph, DAG)。

    参数:
        - **circuit** (:class:`~.core.circuit.Circuit`) - 输入的量子线路。


    .. py:method:: append_node(node: DAGNode)

        添加一个量子门 DAG 节点。

        参数:
            - **node** (:class:`~.algorithm.compiler.DAGNode`) - 想要添加的 DAG 节点。

    .. py:method:: depth()

        返回量子线路的层数。

    .. py:method:: find_all_gate_node()

        查找 :class:`~.algorithm.compiler.DAGCircuit` 图中的所有量子门节点。

        返回:
            List[:class:`~.algorithm.compiler.GateNode`],:class:`~.algorithm.compiler.DAGCircuit` 中所有 :class:`~.algorithm.compiler.GateNode` 的列表。

    .. py:method:: layering()

        将量子线路进行分层。

        返回:
            List[:class:`~.core.circuit.Circuit`],分层后的量子线路列表。

    .. py:method:: replace_node_with_dag_circuit(node: DAGNode, coming: "DAGCircuit")
        :abstractmethod:

        用一个 DAG 图来替换给定的节点。

        参数:
            - **node** (:class:`~.algorithm.compiler.DAGNode`) - 原始的节点。
            - **coming** (:class:`~.algorithm.compiler.DAGCircuit`) - 新的 DAG 图。

    .. py:method:: to_circuit()

        将 :class:`~.algorithm.compiler.DAGCircuit` 转化为量子线路。

        返回:
            :class:`~.core.circuit.Circuit` , DAG 图对应的量子线路。

    .. py:method:: topological_sort()

        执行有向无环图(DAG)的拓扑排序,并返回拓扑排序后的节点顺序。

        返回:
            List[:class:`~.algorithm.compiler.DAGNode`],拓扑排序后的节点列表。
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mindspore/mindquantum.git
git@gitee.com:mindspore/mindquantum.git
mindspore
mindquantum
mindquantum
r0.10

搜索帮助