Added topological sort of nodes for the bayesian network