*/
Operation findBestArcToReverse(BayesNet bayesNet, Instances instances, Operation oBestOperation) throws Exception {
int nNrOfAtts = instances.numAttributes();
// find best arc to reverse
for (int iNode = 0; iNode < nNrOfAtts; iNode++) {
ParentSet parentSet = bayesNet.getParentSet(iNode);
for (int iParent = 0; iParent < parentSet.getNrOfParents(); iParent++) {
int iTail = parentSet.getParent(iParent);
// is reversal allowed?
if (reverseArcMakesSense(bayesNet, instances, iNode, iTail) &&
bayesNet.getParentSet(iTail).getNrOfParents() < m_nMaxNrOfParents) {
// go check if reversal results in the best step forward
Operation oOperation = new Operation(parentSet.getParent(iParent), iNode, Operation.OPERATION_REVERSE);
double fScore = calcScoreWithReversedParent(oOperation.m_nHead, oOperation.m_nTail);
if (fScore > oBestOperation.m_fScore) {
if (isNotTabu(oOperation)) {
oBestOperation = oOperation;
oBestOperation.m_fScore = fScore;