#ifndef HORUS_ELIMGRAPH_H #define HORUS_ELIMGRAPH_H #include "unordered_map" #include "FactorGraph.h" #include "Horus.h" using namespace std; enum ElimHeuristic { MIN_NEIGHBORS, MIN_WEIGHT, MIN_FILL, WEIGHTED_MIN_FILL }; class EgNode : public Var { public: EgNode (VarId vid, unsigned range) : Var (vid, range) { } void addNeighbor (EgNode* n) { neighs_.push_back (n); } const vector& neighbors (void) const { return neighs_; } private: vector neighs_; }; class ElimGraph { public: ElimGraph (const vector&); // TODO ~ElimGraph (void); VarIds getEliminatingOrder (const VarIds&); void print (void) const; void exportToGraphViz (const char*, bool = true, const VarIds& = VarIds()) const; static VarIds getEliminationOrder (const vector, VarIds); static void setEliminationHeuristic (ElimHeuristic h) { elimHeuristic_ = h; } static ElimHeuristic getEliminationHeuristic (void) { return elimHeuristic_; } private: void addEdge (EgNode* n1, EgNode* n2) { assert (n1 != n2); n1->addNeighbor (n2); n2->addNeighbor (n1); } void addNode (EgNode*); EgNode* getEgNode (VarId) const; EgNode* getLowestCostNode (void) const; unsigned getNeighborsCost (const EgNode*) const; unsigned getWeightCost (const EgNode*) const; unsigned getFillCost (const EgNode*) const; unsigned getWeightedFillCost (const EgNode*) const; void connectAllNeighbors (const EgNode*); bool neighbors (const EgNode*, const EgNode*) const; vector nodes_; vector marked_; unordered_map varMap_; static ElimHeuristic elimHeuristic_; }; #endif // HORUS_ELIMGRAPH_H