Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.

  [Sun] -- [Pear]
  [Apple] --> [Pear]
  [Pear] -- [fruit] --> [Pineapple]
  [Pear] --> [Cherry]
  [fruit] ==> [Done]
Renders to:

                +--------+
                | Cherry |
                +--------+
                  ^
                  |
                  |
  +-------+     +--------+     +-------+     +-----------+
  | Apple | --> |  Pear  | --- | fruit | --> | Pineapple |
  +-------+     +--------+     +-------+     +-----------+
                  |              H
                  |              H
                  |              v
                +--------+     +-------+
                |  Sun   |     | Done  |
                +--------+     +-------+


It's a pity that the GraphViz family of automatic graph drawing tools don't support ASCII:

  (user@air) /Users/user $ dot -Tascii

  Format: "ascii" not recognized. Use one of: bmp
  cgimage cmap cmapx cmapx_np dot eps exr fig
  gd gd2 gif gv imap imap_np ismap jp2 jpe jpeg
  jpg pct pdf pict plain plain-ext png ps ps2 psd
  sgi svg svgz tga tif tiff tk vml vmlz vrml wbmp
  x11 xdot xlib canon


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: