|
libDAI
|
A ClusterGraph is a hypergraph with variables as nodes, and "clusters" (sets of variables) as hyperedges. More...
#include <dai/clustergraph.h>
Public Member Functions | |
Constructors and destructors | |
| ClusterGraph () | |
| Default constructor. | |
| ClusterGraph (const std::vector< VarSet > &cls) | |
| Construct from vector of VarSet 's. | |
| ClusterGraph (const FactorGraph &fg, bool onlyMaximal) | |
| Construct from a factor graph. | |
Queries | |
| const BipartiteGraph & | bipGraph () const |
| Returns a constant reference to the graph structure. | |
| size_t | nrVars () const |
| Returns number of variables. | |
| const std::vector< Var > & | vars () const |
| Returns a constant reference to the variables. | |
| const Var & | var (size_t i) const |
| Returns a constant reference to the i'th variable. | |
| size_t | nrClusters () const |
| Returns number of clusters. | |
| const std::vector< VarSet > & | clusters () const |
| Returns a constant reference to the clusters. | |
| const VarSet & | cluster (size_t I) const |
| Returns a constant reference to the I'th cluster. | |
| size_t | findVar (const Var &n) const |
| Returns the index of variable n. | |
| size_t | findCluster (const VarSet &cl) const |
| Returns the index of a cluster cl. | |
| VarSet | Delta (size_t i) const |
| Returns union of clusters that contain the i 'th variable. | |
| VarSet | delta (size_t i) const |
| Returns union of clusters that contain the i 'th (except this variable itself) | |
| bool | adj (size_t i1, size_t i2) const |
Returns true if variables with indices i1 and i2 are adjacent, i.e., both contained in the same cluster. | |
| bool | isMaximal (size_t I) const |
Returns true if cluster I is not contained in a larger cluster. | |
Operations | |
| size_t | insert (const VarSet &cl) |
| Inserts a cluster (if it does not already exist) and creates new variables, if necessary. | |
| ClusterGraph & | eraseNonMaximal () |
| Erases all clusters that are not maximal. | |
| ClusterGraph & | eraseSubsuming (size_t i) |
| Erases all clusters that contain the i 'th variable. | |
| VarSet | elimVar (size_t i) |
| Eliminates variable with index i, without deleting the variable itself. | |
Variable elimination | |
| template<class EliminationChoice > | |
| ClusterGraph | VarElim (EliminationChoice f, size_t maxStates=0) const |
| Performs Variable Elimination, keeping track of the interactions that are created along the way. | |
Private Attributes | |
| BipartiteGraph | _G |
| Stores the neighborhood structure. | |
| std::vector< Var > | _vars |
| Stores the variables corresponding to the nodes. | |
| std::vector< VarSet > | _clusters |
| Stores the clusters corresponding to the hyperedges. | |
Friends | |
Input/Ouput | |
| std::ostream & | operator<< (std::ostream &os, const ClusterGraph &cl) |
| Writes a ClusterGraph to an output stream. | |
A ClusterGraph is a hypergraph with variables as nodes, and "clusters" (sets of variables) as hyperedges.
It is implemented as a bipartite graph with variable (Var) nodes and cluster (VarSet) nodes. One may think of a ClusterGraph as a FactorGraph without the actual factor values.
| dai::ClusterGraph::ClusterGraph | ( | ) | [inline] |
Default constructor.
| dai::ClusterGraph::ClusterGraph | ( | const std::vector< VarSet > & | cls | ) |
Construct from vector of VarSet 's.
| dai::ClusterGraph::ClusterGraph | ( | const FactorGraph & | fg, |
| bool | onlyMaximal | ||
| ) |
Construct from a factor graph.
Creates cluster graph which has factors in fg as clusters if onlyMaximal == false, and only the maximal factors in fg if onlyMaximal == true.
| const BipartiteGraph& dai::ClusterGraph::bipGraph | ( | ) | const [inline] |
Returns a constant reference to the graph structure.
| size_t dai::ClusterGraph::nrVars | ( | ) | const [inline] |
Returns number of variables.
| const std::vector<Var>& dai::ClusterGraph::vars | ( | ) | const [inline] |
Returns a constant reference to the variables.
| const Var& dai::ClusterGraph::var | ( | size_t | i | ) | const [inline] |
Returns a constant reference to the i'th variable.
| size_t dai::ClusterGraph::nrClusters | ( | ) | const [inline] |
Returns number of clusters.
| const std::vector<VarSet>& dai::ClusterGraph::clusters | ( | ) | const [inline] |
Returns a constant reference to the clusters.
| const VarSet& dai::ClusterGraph::cluster | ( | size_t | I | ) | const [inline] |
Returns a constant reference to the I'th cluster.
| size_t dai::ClusterGraph::findVar | ( | const Var & | n | ) | const [inline] |
Returns the index of variable n.
| size_t dai::ClusterGraph::findCluster | ( | const VarSet & | cl | ) | const [inline] |
Returns the index of a cluster cl.
| VarSet dai::ClusterGraph::Delta | ( | size_t | i | ) | const [inline] |
Returns union of clusters that contain the i 'th variable.
| VarSet dai::ClusterGraph::delta | ( | size_t | i | ) | const [inline] |
Returns union of clusters that contain the i 'th (except this variable itself)
| bool dai::ClusterGraph::adj | ( | size_t | i1, |
| size_t | i2 | ||
| ) | const [inline] |
Returns true if variables with indices i1 and i2 are adjacent, i.e., both contained in the same cluster.
| bool dai::ClusterGraph::isMaximal | ( | size_t | I | ) | const [inline] |
Returns true if cluster I is not contained in a larger cluster.
| size_t dai::ClusterGraph::insert | ( | const VarSet & | cl | ) | [inline] |
Inserts a cluster (if it does not already exist) and creates new variables, if necessary.
| ClusterGraph& dai::ClusterGraph::eraseNonMaximal | ( | ) | [inline] |
Erases all clusters that are not maximal.
| ClusterGraph& dai::ClusterGraph::eraseSubsuming | ( | size_t | i | ) | [inline] |
Erases all clusters that contain the i 'th variable.
| VarSet dai::ClusterGraph::elimVar | ( | size_t | i | ) | [inline] |
Eliminates variable with index i, without deleting the variable itself.
| ClusterGraph dai::ClusterGraph::VarElim | ( | EliminationChoice | f, |
| size_t | maxStates = 0 |
||
| ) | const [inline] |
Performs Variable Elimination, keeping track of the interactions that are created along the way.
| EliminationChoice | should support "size_t operator()( const ClusterGraph &cl, const std::set<size_t> &remainingVars )" |
| f | function object which returns the next variable index to eliminate; for example, a dai::greedyVariableElimination object. |
| maxStates | maximum total number of states of all clusters in the output cluster graph (0 means no limit). |
| OUT_OF_MEMORY | if total number of states becomes larger than maxStates |
| std::ostream& operator<< | ( | std::ostream & | os, |
| const ClusterGraph & | cl | ||
| ) | [friend] |
Writes a ClusterGraph to an output stream.
BipartiteGraph dai::ClusterGraph::_G [private] |
Stores the neighborhood structure.
std::vector<Var> dai::ClusterGraph::_vars [private] |
Stores the variables corresponding to the nodes.
std::vector<VarSet> dai::ClusterGraph::_clusters [private] |
Stores the clusters corresponding to the hyperedges.
1.7.4