public BCInference(int[][] cases,int[] nodeDimension){
  this.cases=cases;
  this.nodeDimension=nodeDimension;
  this.numberOfNodes=nodeDimension.length - 2;
  this.numberOfCases=cases.length - 1;
  this.maxCases=numberOfCases;
  this.maxNodes=numberOfNodes;
  this.maxValues=findMaxValue(nodeDimension);
  this.maxLogFact=(2 * maxCases) + maxValues;
  this.scoreFn=1;
  this.logfact=new double[maxLogFact + 1];
  int[] _nodeDimension=Arrays.copyOf(nodeDimension,nodeDimension.length);
  Arrays.sort(_nodeDimension);
  int g1=_nodeDimension[_nodeDimension.length - 1];
  int g2=_nodeDimension[_nodeDimension.length - 2];
  maxCells=maxParents * g1 * g2* maxCases;
  this.parents=new int[maxNodes + 2][maxParents + 1];
  this.countsTree=new int[maxCells + 1];
  this.counts=new int[maxCells + 1];
  this.scores=new double[maxCases + 1][4];
}

public BCInference ( int [ ] [ ] cases , int [ ] nodeDimension ) { this . cases = cases ; this . nodeDimension = nodeDimension ; this . numberOfNodes = nodeDimension . length - 2 ; this . numberOfCases = cases . length - 1 ; this . maxCases = numberOfCases ; this . maxNodes = numberOfNodes ; this . maxValues = findMaxValue ( nodeDimension ) ; this . maxLogFact = ( 2 * maxCases ) + maxValues ; this . scoreFn = 1 ; this . logfact = new double [ maxLogFact + 1 ] ; int [ ] _nodeDimension = Arrays . copyOf ( nodeDimension , nodeDimension . length ) ; Arrays . sort ( _nodeDimension ) ; int g1 = _nodeDimension [ _nodeDimension . length - 1 ] ; int g2 = _nodeDimension [ _nodeDimension . length - 2 ] ; maxCells = maxParents * g1 * g2 * maxCases ; this . parents = new int [ maxNodes + 2 ] [ maxParents + 1 ] ; this . countsTree = new int [ maxCells + 1 ] ; this . counts = new int [ maxCells + 1 ] ; this . scores = new double [ maxCases + 1 ] [ 4 ] ; }
cases is a two - dimensional array dataset . if the dataset is m x n , the size of the two - dimensional array is ( m + 2 ) x ( n + 2 ) . in other words , the size of the array is always 2 more of the number of data . likewise , if the data for nodedimension is n then the size of the array is n + 2 . < p / > the case array index starts from 1 ( not zero ) to numberofcases . the nodedimension array index start from 1 ( not zero ) to numberofnodes . < p / > nodedimension array contains values denote the number of discrete values that node can have ( e . g . , 2 for a binary variable ) .
