*/
+/// \file
+/// \brief Defines classes Region, FRegion and RegionGraph
+/// \todo Improve documentation
+
+
#ifndef __defined_libdai_regiongraph_h
#define __defined_libdai_regiongraph_h
/// Construct Region from a VarSet and a counting number
Region(const VarSet & x, double c) : VarSet(x), _c(c) {}
-
- /// Copy constructor
- Region(const Region & x) : VarSet(x), _c(x._c) {}
-
- /// Assignment operator
- Region & operator=(const Region & x) {
- if( this != &x ) {
- VarSet::operator=(x);
- _c = x._c;
- }
- return *this;
- }
/// Provide read access to counting number
const double & c() const { return _c; }
/// Constructs FRegion from a Factor and a counting number
FRegion( const Factor & x, double c ) : Factor(x), _c(c) {}
-
- /// Copy constructor
- FRegion( const FRegion & x ) : Factor(x), _c(x._c) {}
-
- /// Assignment operator
- FRegion & operator=(const FRegion & x) {
- if( this != &x ) {
- Factor::operator=(x);
- _c = x._c;
- }
- return *this;
- }
/// Provide read access to counting number
const double & c() const { return _c; }
/// A RegionGraph is a bipartite graph consisting of outer regions (type FRegion) and inner regions (type Region)
class RegionGraph : public FactorGraph {
public:
+ /// Stores the neighborhood structure
BipartiteGraph G;
+
+ /// The outer regions (corresponding to nodes of type 1)
std::vector<FRegion> ORs;
+
+ /// The inner regions (corresponding to nodes of type 2)
std::vector<Region> IRs;
- /// Give back the OR index that corresponds to a factor index
+ /// Stores for each factor index the index of the outer region it belongs to
std::vector<size_t> fac2OR;
/// Constructs a RegionGraph from a FactorGraph, a vector of outer regions, a vector of inner regions and a vector of edges
RegionGraph( const FactorGraph &fg, const std::vector<Region> &ors, const std::vector<Region> &irs, const std::vector<std::pair<size_t,size_t> > &edges );
-
+
/// Constructs a RegionGraph from a FactorGraph and a vector of outer VarSets (CVM style)
RegionGraph( const FactorGraph &fg, const std::vector<VarSet> &cl );
- /// Copy constructor
- RegionGraph( const RegionGraph &x ) : FactorGraph(x), G(x.G), ORs(x.ORs), IRs(x.IRs), fac2OR(x.fac2OR) {}
-
- /// Assignment operator
- RegionGraph & operator=( const RegionGraph &x ) {
- if( this != &x ) {
- FactorGraph::operator=( x );
- G = x.G;
- ORs = x.ORs;
- IRs = x.IRs;
- fac2OR = x.fac2OR;
- }
- return *this;
- }
-
/// Clone *this (virtual copy constructor)
virtual RegionGraph* clone() const { return new RegionGraph(*this); }
- /// Create (virtual default constructor)
- virtual RegionGraph* create() const { return new RegionGraph(); }
-
/// Set the content of the I'th factor and make a backup of its old content if backup == true
virtual void setFactor( size_t I, const Factor &newFactor, bool backup = false ) {
- FactorGraph::setFactor( I, newFactor, backup );
- RecomputeOR( I );
+ FactorGraph::setFactor( I, newFactor, backup );
+ RecomputeOR( I );
}
/// Set the contents of all factors as specified by facs and make a backup of the old contents if backup == true
VarSet ns;
for( std::map<size_t, Factor>::const_iterator fac = facs.begin(); fac != facs.end(); fac++ )
ns |= fac->second.vars();
- RecomputeORs( ns );
+ RecomputeORs( ns );
}
/// Recompute all outer regions involving factor I
void RecomputeOR( size_t I );
- /// Send RegionGraph to output stream
+ // Friends
friend std::ostream & operator << ( std::ostream & os, const RegionGraph & rg );
};