toMAG function

Convert DAG to MAG.