Some renamings in ElimGraph
This commit is contained in:
parent
ba79d2e422
commit
ea49b517e8
@ -15,15 +15,15 @@ ElimGraph::ElimGraph (const std::vector<Factor*>& factors)
|
||||
if (factors[i]) {
|
||||
const VarIds& args = factors[i]->arguments();
|
||||
for (size_t j = 0; j < args.size() - 1; j++) {
|
||||
EgNode* n1 = getEgNode (args[j]);
|
||||
EGNode* n1 = getEGNode (args[j]);
|
||||
if (!n1) {
|
||||
n1 = new EgNode (args[j], factors[i]->range (j));
|
||||
n1 = new EGNode (args[j], factors[i]->range (j));
|
||||
addNode (n1);
|
||||
}
|
||||
for (size_t k = j + 1; k < args.size(); k++) {
|
||||
EgNode* n2 = getEgNode (args[k]);
|
||||
EGNode* n2 = getEGNode (args[k]);
|
||||
if (!n2) {
|
||||
n2 = new EgNode (args[k], factors[i]->range (k));
|
||||
n2 = new EGNode (args[k], factors[i]->range (k));
|
||||
addNode (n2);
|
||||
}
|
||||
if (!neighbors (n1, n2)) {
|
||||
@ -31,8 +31,8 @@ ElimGraph::ElimGraph (const std::vector<Factor*>& factors)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.size() == 1 && !getEgNode (args[0])) {
|
||||
addNode (new EgNode (args[0], factors[i]->range (0)));
|
||||
if (args.size() == 1 && !getEGNode (args[0])) {
|
||||
addNode (new EGNode (args[0], factors[i]->range (0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ ElimGraph::getEliminatingOrder (const VarIds& excludedVids)
|
||||
}
|
||||
size_t nrVarsToEliminate = nodes_.size() - excludedVids.size();
|
||||
for (size_t i = 0; i < nrVarsToEliminate; i++) {
|
||||
EgNode* node = getLowestCostNode();
|
||||
EGNode* node = getLowestCostNode();
|
||||
unmarked_.remove (node);
|
||||
const EGNeighs& neighs = node->neighbors();
|
||||
for (size_t j = 0; j < neighs.size(); j++) {
|
||||
@ -109,7 +109,7 @@ ElimGraph::exportToGraphViz (
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < highlightVarIds.size(); i++) {
|
||||
EgNode* node =getEgNode (highlightVarIds[i]);
|
||||
EGNode* node =getEGNode (highlightVarIds[i]);
|
||||
if (node) {
|
||||
out << '"' << node->label() << '"' ;
|
||||
out << " [shape=box3d]" << std::endl;
|
||||
@ -156,7 +156,7 @@ ElimGraph::getEliminationOrder (
|
||||
|
||||
|
||||
void
|
||||
ElimGraph::addNode (EgNode* n)
|
||||
ElimGraph::addNode (EGNode* n)
|
||||
{
|
||||
nodes_.push_back (n);
|
||||
n->setIndex (nodes_.size() - 1);
|
||||
@ -165,20 +165,20 @@ ElimGraph::addNode (EgNode* n)
|
||||
|
||||
|
||||
|
||||
EgNode*
|
||||
ElimGraph::getEgNode (VarId vid) const
|
||||
EGNode*
|
||||
ElimGraph::getEGNode (VarId vid) const
|
||||
{
|
||||
std::unordered_map<VarId, EgNode*>::const_iterator it;
|
||||
std::unordered_map<VarId, EGNode*>::const_iterator it;
|
||||
it = varMap_.find (vid);
|
||||
return (it != varMap_.end()) ? it->second : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EgNode*
|
||||
EGNode*
|
||||
ElimGraph::getLowestCostNode (void) const
|
||||
{
|
||||
EgNode* bestNode = 0;
|
||||
EGNode* bestNode = 0;
|
||||
unsigned minCost = Util::maxUnsigned();
|
||||
EGNeighs::const_iterator it;
|
||||
switch (elimHeuristic_) {
|
||||
@ -228,7 +228,7 @@ ElimGraph::getLowestCostNode (void) const
|
||||
|
||||
|
||||
void
|
||||
ElimGraph::connectAllNeighbors (const EgNode* n)
|
||||
ElimGraph::connectAllNeighbors (const EGNode* n)
|
||||
{
|
||||
const EGNeighs& neighs = n->neighbors();
|
||||
if (neighs.size() > 0) {
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
namespace Horus {
|
||||
|
||||
class EgNode;
|
||||
class EGNode;
|
||||
|
||||
typedef TinySet<EgNode*> EGNeighs;
|
||||
typedef TinySet<EGNode*> EGNeighs;
|
||||
|
||||
|
||||
enum ElimHeuristic {
|
||||
@ -27,15 +27,15 @@ enum ElimHeuristic {
|
||||
};
|
||||
|
||||
|
||||
class EgNode : public Var {
|
||||
class EGNode : public Var {
|
||||
public:
|
||||
EgNode (VarId vid, unsigned range) : Var (vid, range) { }
|
||||
EGNode (VarId vid, unsigned range) : Var (vid, range) { }
|
||||
|
||||
void addNeighbor (EgNode* n) { neighs_.insert (n); }
|
||||
void addNeighbor (EGNode* n) { neighs_.insert (n); }
|
||||
|
||||
void removeNeighbor (EgNode* n) { neighs_.remove (n); }
|
||||
void removeNeighbor (EGNode* n) { neighs_.remove (n); }
|
||||
|
||||
bool isNeighbor (EgNode* n) const { return neighs_.contains (n); }
|
||||
bool isNeighbor (EGNode* n) const { return neighs_.contains (n); }
|
||||
|
||||
const EGNeighs& neighbors (void) const { return neighs_; }
|
||||
|
||||
@ -64,29 +64,29 @@ class ElimGraph {
|
||||
static void setElimHeuristic (ElimHeuristic eh) { elimHeuristic_ = eh; }
|
||||
|
||||
private:
|
||||
void addEdge (EgNode* n1, EgNode* n2);
|
||||
void addEdge (EGNode* n1, EGNode* n2);
|
||||
|
||||
unsigned getNeighborsCost (const EgNode* n) const;
|
||||
unsigned getNeighborsCost (const EGNode* n) const;
|
||||
|
||||
unsigned getWeightCost (const EgNode* n) const;
|
||||
unsigned getWeightCost (const EGNode* n) const;
|
||||
|
||||
unsigned getFillCost (const EgNode* n) const;
|
||||
unsigned getFillCost (const EGNode* n) const;
|
||||
|
||||
unsigned getWeightedFillCost (const EgNode* n) const;
|
||||
unsigned getWeightedFillCost (const EGNode* n) const;
|
||||
|
||||
bool neighbors (EgNode* n1, EgNode* n2) const;
|
||||
bool neighbors (EGNode* n1, EGNode* n2) const;
|
||||
|
||||
void addNode (EgNode*);
|
||||
void addNode (EGNode*);
|
||||
|
||||
EgNode* getEgNode (VarId) const;
|
||||
EGNode* getEGNode (VarId) const;
|
||||
|
||||
EgNode* getLowestCostNode (void) const;
|
||||
EGNode* getLowestCostNode (void) const;
|
||||
|
||||
void connectAllNeighbors (const EgNode*);
|
||||
void connectAllNeighbors (const EGNode*);
|
||||
|
||||
std::vector<EgNode*> nodes_;
|
||||
TinySet<EgNode*> unmarked_;
|
||||
std::unordered_map<VarId, EgNode*> varMap_;
|
||||
std::vector<EGNode*> nodes_;
|
||||
EGNeighs unmarked_;
|
||||
std::unordered_map<VarId, EGNode*> varMap_;
|
||||
|
||||
static ElimHeuristic elimHeuristic_;
|
||||
|
||||
@ -96,7 +96,7 @@ class ElimGraph {
|
||||
|
||||
|
||||
inline void
|
||||
ElimGraph::addEdge (EgNode* n1, EgNode* n2)
|
||||
ElimGraph::addEdge (EGNode* n1, EGNode* n2)
|
||||
{
|
||||
assert (n1 != n2);
|
||||
n1->addNeighbor (n2);
|
||||
@ -106,7 +106,7 @@ ElimGraph::addEdge (EgNode* n1, EgNode* n2)
|
||||
|
||||
|
||||
inline unsigned
|
||||
ElimGraph::getNeighborsCost (const EgNode* n) const
|
||||
ElimGraph::getNeighborsCost (const EGNode* n) const
|
||||
{
|
||||
return n->neighbors().size();
|
||||
}
|
||||
@ -114,7 +114,7 @@ ElimGraph::getNeighborsCost (const EgNode* n) const
|
||||
|
||||
|
||||
inline unsigned
|
||||
ElimGraph::getWeightCost (const EgNode* n) const
|
||||
ElimGraph::getWeightCost (const EGNode* n) const
|
||||
{
|
||||
unsigned cost = 1;
|
||||
const EGNeighs& neighs = n->neighbors();
|
||||
@ -127,7 +127,7 @@ ElimGraph::getWeightCost (const EgNode* n) const
|
||||
|
||||
|
||||
inline unsigned
|
||||
ElimGraph::getFillCost (const EgNode* n) const
|
||||
ElimGraph::getFillCost (const EGNode* n) const
|
||||
{
|
||||
unsigned cost = 0;
|
||||
const EGNeighs& neighs = n->neighbors();
|
||||
@ -146,7 +146,7 @@ ElimGraph::getFillCost (const EgNode* n) const
|
||||
|
||||
|
||||
inline unsigned
|
||||
ElimGraph::getWeightedFillCost (const EgNode* n) const
|
||||
ElimGraph::getWeightedFillCost (const EGNode* n) const
|
||||
{
|
||||
unsigned cost = 0;
|
||||
const EGNeighs& neighs = n->neighbors();
|
||||
@ -165,7 +165,7 @@ ElimGraph::getWeightedFillCost (const EgNode* n) const
|
||||
|
||||
|
||||
inline bool
|
||||
ElimGraph::neighbors (EgNode* n1, EgNode* n2) const
|
||||
ElimGraph::neighbors (EGNode* n1, EGNode* n2) const
|
||||
{
|
||||
return n1->isNeighbor (n2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user