Discrete factor and its operations in Probabilistic Graphical Models