// Models the algorithm det-k-decomp. // ////////////////////////////////////////////////////////////////////// #if !defined(CLS_BalKDecomp) #define CLS_BalKDecomp #include #include "Globals.h" #include "Decomp.h" class Hypertree; class Subedges; class BalKDecomp : public Decomp { private: static list sFailedHg; static unordered_map sSuccHg; int MyRecLevel; std::unique_ptr MySubedges; HypertreeSharedPtr decomp(const HyperedgeVector &HEdges); list decompose(const SeparatorSharedPtr &Sep, const SuperedgeSharedPtr &Sup, const vector &Parts); HyperedgeVector getNeighborEdges(const HyperedgeVector &Edges) const; bool isBalanced(const vector &Parts, int CompSize); void expandHTree(const HypertreeSharedPtr &HTree); // Finds or constructs a hypergraph from a list of edges and a superedge // Returns false if hypergraph is in sFailedHg template bool getHypergraph(HypergraphSharedPtr &Hg, bool &Succ, const T &Part, const SuperedgeSharedPtr &Sup = nullptr) const; public: static int MyMaxRecursion; static HypergraphSharedPtr MyBaseGraph; BalKDecomp(const HypergraphSharedPtr &HGraph, int k, int RecLevel = 0); virtual ~BalKDecomp(); // Constructs a hypertree decomposition of width at most MyK (if it exists) virtual HypertreeSharedPtr buildHypertree(); static void init(const HypergraphSharedPtr &BaseGraph, int MaxRecursion = 0) { MyMaxRecursion = MaxRecursion; MyBaseGraph = BaseGraph; } }; #endif