29 #include "drwnTableFactor.h"
32 using namespace Eigen;
58 virtual const char *
type()
const {
return "drwnFactorGraph"; }
64 int numVariables()
const {
return (_pUniverse == NULL) ? 0 : _pUniverse->numVariables(); }
68 int numEdges()
const {
return (
int)_edges.size(); }
77 void deleteFactor(
int indx);
79 int findFactor(
const drwnClique& clique,
bool bAllowSuperset =
false)
const;
96 bool connectGraph(
const set<drwnEdge>& edges);
98 virtual bool connectGraph();
100 bool connectBetheApprox();
108 bool save(drwnXMLNode& xml)
const;
109 bool load(drwnXMLNode& xml);
113 const drwnTableFactor* operator[](
unsigned indx)
const {
return _factors[indx]; }
120 void computeSeparatorSets();
126 namespace drwnFactorGraphUtils {
const drwnVarUniversePtr & getUniverse() const
return the universe of variables for this factor graph
Definition: drwnFactorGraph.h:62
vector< drwnTableFactor * > _factors
list of factors in the model
Definition: drwnFactorGraph.h:43
drwnVarUniversePtr _pUniverse
all variables in the universe
Definition: drwnFactorGraph.h:42
virtual drwnFactorGraph * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFactorGraph.h:59
void mergeDuplicateFactors(drwnFactorGraph &graph)
Merges (log-space) factors over identical cliques. Operates inline.
Definition: drwnFactorGraph.cpp:591
vector< set< int > > variableAdjacencyList(const drwnFactorGraph &graph)
Returns the neighbours (i.e., other variables appearing in the same clique) of each variable...
Definition: drwnFactorGraph.cpp:428
drwnClique getSepSet(int eindx) const
returns the set of separator variables for edge eindx
Definition: drwnFactorGraph.h:85
drwnFactorGraph createJunctionTree(const drwnFactorGraph &graph)
Create a junction tree from a factor graph.
Definition: drwnFactorGraph.cpp:445
void writeDottyOutput(const char *filename, const drwnFactorGraph &graph)
Generate output for dotty (Graphviz)
Definition: drwnFactorGraph.cpp:407
int numVariables() const
returns the number of variables in the universe
Definition: drwnFactorGraph.h:64
Container and utility functions for factor graphs.
Definition: drwnFactorGraph.h:40
const drwnTableFactor * getFactor(int indx) const
returns the factor at index indx
Definition: drwnFactorGraph.h:75
virtual const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFactorGraph.h:58
Factor which stores the value of each assignment explicitly in table form.
Definition: drwnTableFactor.h:144
std::set< int > drwnClique
variable clique
Definition: drwnGraphUtils.h:37
std::pair< int, int > drwnEdge
directed or undirected edges
Definition: drwnGraphUtils.h:33
std::vector< int > drwnFullAssignment
defines a complete assignment to all variables in the universe
Definition: drwnVarAssignment.h:36
int numFactors() const
returns the number of factors in the graph
Definition: drwnFactorGraph.h:66
void absorbSmallFactors(drwnFactorGraph &graph, bool bIncludeUnary=true)
Absorbs smaller (log-space) factors into larger ones (operates inline). The returned graph is disconn...
Definition: drwnFactorGraph.cpp:551
Generic interface for a factor. Currently only inherited by drwnTableFactor.
Definition: drwnTableFactor.h:40
Basic datatype for holding three objects of arbitrary type. Similar to the STL pair<> class...
Definition: drwnTriplet.h:33
vector< _drwnFactorEdge > _edges
list of edges and sep-sets
Definition: drwnFactorGraph.h:46
drwnEdge getEdge(int eindx) const
returns the indices for the factors adjacent to edge eindx
Definition: drwnFactorGraph.h:83
standard Darwin object interface (cloneable and writeable)
Definition: drwnInterfaces.h:72
double removeUniformFactors(drwnFactorGraph &graph)
Removes uniform factors from the graph (returns energy of factors removed)
Definition: drwnFactorGraph.cpp:512
int numEdges() const
returns the number of (hyper-)edges in the graph
Definition: drwnFactorGraph.h:68