The complete (though untested) code for the graphener modified for the ternary case.