-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBalKDecomp.h
58 lines (40 loc) · 1.57 KB
/
BalKDecomp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Models the algorithm det-k-decomp.
//
//////////////////////////////////////////////////////////////////////
#if !defined(CLS_BalKDecomp)
#define CLS_BalKDecomp
#include <unordered_map>
#include "Globals.h"
#include "Decomp.h"
class Hypertree;
class Subedges;
class BalKDecomp :
public Decomp
{
private:
static list<HypergraphSharedPtr> sFailedHg;
static unordered_map<HypergraphSharedPtr, HypertreeSharedPtr> sSuccHg;
int MyRecLevel;
std::unique_ptr<Subedges> MySubedges;
HypertreeSharedPtr decomp(const HyperedgeVector &HEdges);
list<HypertreeSharedPtr> decompose(const SeparatorSharedPtr &Sep, const SuperedgeSharedPtr &Sup, const vector<DecompComponent> &Parts);
HyperedgeVector getNeighborEdges(const HyperedgeVector &Edges) const;
bool isBalanced(const vector<DecompComponent> &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<typename T>
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