Probabilistic Graphical Models and Algorithms for