Implement Bayesian Networks Algorithm