# Include flags
INC=-I../include
# Library path flags
-LIBS=
+LIBS=-lgmpxx -lgmp
# Location of libDAI library
LIB=../lib
# Compiler
CC=g++
# Compiler flags
-CCFLAGS=-Wno-deprecated -Wall -W -Wextra -fpic -O3 -static $(INC) $(LIBS)
+CCFLAGS=-Wno-deprecated -Wall -W -Wextra -fpic -O3 -static $(INC)
all : uai2010-aie-solver
uai2010-aie-solver : uai2010-aie-solver.cpp $(LIB)/libdai.a
- $(CC) $(CCFLAGS) -o$@ $< $(LIB)/libdai.a
+ $(CC) $(CCFLAGS) -o$@ $< $(LIB)/libdai.a $(LIBS)
# CLEAN
########
}
-ClusterGraph::ClusterGraph( const FactorGraph& fg, bool onlyMaximal ) : _G( fg.bipGraph() ), _vars(), _clusters() {
+ClusterGraph::ClusterGraph( const FactorGraph& fg, bool onlyMaximal ) : _G( fg.nrVars(), 0 ), _vars(), _clusters() {
// copy variables
_vars.reserve( fg.nrVars() );
for( size_t i = 0; i < fg.nrVars(); i++ )
_vars.push_back( fg.var(i) );
- // copy clusters
- _clusters.reserve( fg.nrFactors() );
- for( size_t I = 0; I < fg.nrFactors(); I++ )
- _clusters.push_back( fg.factor(I).vars() );
-
- if( onlyMaximal )
- eraseNonMaximal();
+ if( onlyMaximal ) {
+ for( size_t I = 0; I < fg.nrFactors(); I++ )
+ if( fg.isMaximal( I ) ) {
+ _clusters.push_back( fg.factor(I).vars() );
+ size_t clind = _G.addNode2();
+ foreach( const Neighbor &i, fg.nbF(I) )
+ _G.addEdge( i, clind, true );
+ }
+ } else {
+ // copy clusters
+ _clusters.reserve( fg.nrFactors() );
+ for( size_t I = 0; I < fg.nrFactors(); I++ )
+ _clusters.push_back( fg.factor(I).vars() );
+ // copy bipartite graph
+ _G = fg.bipGraph();
+ }
}