parse_gm_formula function

Parse graphical model formula