Add a writer to DOT format.
minor optimizations
Maintain the invariant of graph vertices collection length.