package com.github.vangj.jbayes.inf.exact.graph.pptc.blocks;

import com.github.vangj.jbayes.inf.exact.graph.Dag;
import com.github.vangj.jbayes.inf.exact.graph.pptc.JoinTree;

import static com.github.vangj.jbayes.inf.exact.graph.pptc.blocks.Initialization.*;
import static com.github.vangj.jbayes.inf.exact.graph.pptc.blocks.Propagation.*;
import static com.github.vangj.jbayes.inf.exact.graph.pptc.blocks.Moralize.*;
import static com.github.vangj.jbayes.inf.exact.graph.pptc.blocks.Triangulate.*;
import static com.github.vangj.jbayes.inf.exact.graph.pptc.blocks.Transform.*;

public class InferenceControl implements JoinTree.Listener {

  public static JoinTree apply(Dag dag) {
    JoinTree joinTree = propagate(initialization(transform(triangulate(moralize(dag)))))
        .setListener(new InferenceControl());
    return joinTree;
  }
  @Override
  public void evidenceRetracted(JoinTree joinTree) {
    initialization(joinTree);
    propagate(joinTree);
  }

  @Override
  public void evidenceUpdated(JoinTree joinTree) {
    propagate(joinTree);
  }

  @Override
  public void evidenceNoChange(JoinTree joinTree) {
    //do nothing
  }
}

@@ -574,16 +574,65 @@
 orm.*;%0A%0A
+/**%0A * Controls inference based on evidence.%0A */%0A
 public c
@@ -685,16 +685,133 @@
 ener %7B%0A%0A
+  /**%0A   * Creates a join tree from a DAG with inference enabled.%0A   * @param dag DAG.%0A   * @return Join tree.%0A   */%0A
   public
@@ -1000,20 +1000,21 @@
 inTree;%0A
-
   %7D%0A
+%0A
   @Overr

add javadocs