public List<Node> findMb(String targetName){
  Node target=getVariableForName(targetName);
  List<Node> blanket=new LinkedList<>();
  boolean changed=true;
  while (changed) {
    changed=false;
    List<Node> remaining=new LinkedList<>(variables);
    remaining.removeAll(blanket);
    remaining.remove(target);
    for (    Node node : remaining) {
      if (!independenceTest.isIndependent(node,target,blanket)) {
        blanket.add(node);
        changed=true;
      }
    }
  }
  changed=true;
  while (changed) {
    changed=false;
    for (    Node node : new LinkedList<>(blanket)) {
      blanket.remove(node);
      if (independenceTest.isIndependent(node,target,blanket)) {
        changed=true;
        continue;
      }
      blanket.add(node);
    }
  }
  return blanket;
}

public List < Node > findMb ( String targetName ) { Node target = getVariableForName ( targetName ) ; List < Node > blanket = new LinkedList < > ( ) ; boolean changed = true ; while ( changed ) { changed = false ; List < Node > remaining = new LinkedList < > ( variables ) ; remaining . removeAll ( blanket ) ; remaining . remove ( target ) ; for ( Node node : remaining ) { if ( ! independenceTest . isIndependent ( node , target , blanket ) ) { blanket . add ( node ) ; changed = true ; } } } changed = true ; while ( changed ) { changed = false ; for ( Node node : new LinkedList < > ( blanket ) ) { blanket . remove ( node ) ; if ( independenceTest . isIndependent ( node , target , blanket ) ) { changed = true ; continue ; } blanket . add ( node ) ; } } return blanket ; }
finds the markov blanket of the given target .
