One way to do this is to use a combination of the graphviz dot and the new LaTeX TikZ and PGF drawing tools. Kjell Magne Fauske has an amazing gallery of what you can do using these tools together.
The most relevant demonstration for your question is pgf-snake . The image from this demo is reproduced here for completeness.

source share