Perl has a module called 'Graph::Easy' which can create a diagram from a graph automatically, and can also do ASCII-output. See http://bloodgate.com/graph-demo for an interactive demo.
There is a similar Java application also: http://ditaa.sourceforge.net/
But it works in a bit different way: converts such ASCII diagrams into bitmap graphics.