// Create region for 4-clique
Region fourSquare = new Region (vars, edges);
// Create 1-clique region
for (int i = 0; i < 4; i++) {
Variable var = vars[i];
Factor ptl = mdl.factorOf (var);
if (ptl != null) {
fourSquare.factors.add (ptl);
}
}
// Finally create edge regions, and connect to everyone else
for (int i = 0; i < 4; i++) {
Factor edgePtl = edges[i];
Region edgeRgn = rg.findRegion (edgePtl, true);
rg.add (fourSquare, edgeRgn);
Variable v1 = (Variable) edgeRgn.vars.get (0);
Region nodeRgn = createVarRegion (rg, mdl, v1);
edgeRgn.factors.addAll (nodeRgn.factors);
rg.add (edgeRgn, nodeRgn);
Variable v2 = (Variable) edgeRgn.vars.get (1);
nodeRgn = createVarRegion (rg, mdl, v2);
edgeRgn.factors.addAll (nodeRgn.factors);
rg.add (edgeRgn, nodeRgn);
}