Fix edge selection in codegen