this version makes the output format work for graphs with only vertices or auto-referencing vertices