package yi.stat.gm.bp;

import java.util.*;

/**
 * BPApplication defines the call back functions of BP application which will be
 * invoked by Belief Propagation algorithm
 */

public interface BPApplication {

  /**
   * The data_term function: \psi(x_i, y_i)
   * @param node_id
   * @return
   */
  double[] getDataTerm(int node_id);

  /**
   * The neighborhood_term: \phi(x_i, x_j), or
   * p(condition_node_id|conditional_on_node_id)
   */
  double[] getNeighborhoodTerm(int node_from, int node_to);

  /**
   * Return the node number of the graphical model.  For example, the node id
   * will be from 0
   * @return
   */
  int[] getNodeIDs();

  /**
   * Return the neighboring node list of each node
   * @param node_id
   * @return
   */
  int[][] getFromNeighborIDs();

  /**
   * Return the neighboring variable node list of each node
   * @param node_id
   * @return
   */
  int[][] getToNeighborIDs();

  /**
   * Return the possible values (counts) of a node.  Eg. in matting, the
   * possible value of alpha can be 2, 4, 8, and etc
   * @return
   */
  int getPossibleValues();
}