Sorry, but the yEd Software License Agreement explicitly forbids what you are trying to do. See section 1. License Condition: "The Software may not be used as part of an automated process."
However, it is possible to use yFiles for Java, the commercial Java class library upon which yEd is based, for this purpose.