Efficient Inference Algorithms For Some Probabilistic Graphical Models