class QPanda::FindSubCircuit

Overview

#include <QCircuitOptimize.h>

class FindSubCircuit
{
public:
    // typedefs

    typedef SeqNode<T> MatchNode;
    typedef std::vector<MatchNode<T>> MatchNodeVec;
    typedef std::vector<std::pair<pOptimizerNodeInfo, MatchNodeVec<pOptimizerNodeInfo>>> MatchNodeTable;

    // construction

    FindSubCircuit(LayeredTopoSeq& topolog_sequence);

    // methods

    void sub_cir_query(LayeredTopoSeq& sub_sequence);

    bool node_match(
        const SeqNode<pOptimizerNodeInfo>& target_seq_node,
        const SeqNode<pOptimizerNodeInfo>& graph_node
        );

    bool check_angle(
        const pOptimizerNodeInfo node_1,
        const pOptimizerNodeInfo node_2
        );

    void match_layer(SeqLayer<pOptimizerNodeInfo>& sub_seq_layer, const size_t match_layer, std::vector<LayeredTopoSeq>& sub_graph_vec);

    void merge_sub_graph_vec(
        std::vector<LayeredTopoSeq>& sub_graph_vec,
        const size_t match_layer,
        LayeredTopoSeq& target_sub_sequence
        );

    void clean_sub_graph_vec(std::vector<LayeredTopoSeq>& sub_graph_vec, LayeredTopoSeq& target_sub_sequence);
    void merge_topolog_sequence(LayeredTopoSeq& src_seq, LayeredTopoSeq& dst_seq);
    const std::vector<LayeredTopoSeq>& get_sub_graph_vec();
    void clear();
};

Detailed Documentation

Methods

void sub_cir_query(LayeredTopoSeq& sub_sequence)

Query the subgraph and store the query results in query_Result.

Parameters:

LayeredTopoSeq&

store the query results

Returns:

void match_layer(
    SeqLayer<pOptimizerNodeInfo>& sub_seq_layer,
    const size_t match_layer,
    std::vector<LayeredTopoSeq>& sub_graph_vec
    )

Layer matching: matching and combining the nodes of each layer of the sub graph.

Parameters:

SeqLayer<pOptimizerNodeInfo>&

the target matching sub-seq-layer

const

size_t the current matching layer

std::vector<LayeredTopoSeq>&

sub-graph vector

Returns:

void merge_sub_graph_vec(
    std::vector<LayeredTopoSeq>& sub_graph_vec,
    const size_t match_layer,
    LayeredTopoSeq& target_sub_sequence
    )

Merge incomplete subgraphs Implementation method: get the node set of the next layer of each subgraph of the matching subgraph set. If the node set of the next layer of the two subgraphs has duplicate elements, merge the two subgraphs.

Parameters:

std::vector<LayeredTopoSeq>&

the sub graph vector

const

size_t the target layer

LayeredTopoSeq&

the target sub-sequence

Returns:

void clean_sub_graph_vec(std::vector<LayeredTopoSeq>& sub_graph_vec, LayeredTopoSeq& target_sub_sequence)

Clean up the result set of matching subgraphs and delete the wrong matches.

Parameters:

std::vector<LayeredTopoSeq>&

the result set of matching subgraphs

LayeredTopoSeq&

the target sub-sequence

Returns:

void merge_topolog_sequence(LayeredTopoSeq& src_seq, LayeredTopoSeq& dst_seq)

merge sub-graph: merging src_seq into dst_seq by layer

Parameters:

LayeredTopoSeq&

the src_seq

LayeredTopoSeq&

dst_seq

Returns: