use Graph::Easy;

jplindstrom on 2007-08-26T23:23:38

And the cool module of the day is Graph::Easy (live demo) by Tels++.

It's kinda like GraphViz, but it also supports various text-mode output formats.

That's very cool if you want to render a graph of, let's say an inheritance hierarchy in, let's say Emacs. Which I do.

Widen your browser window and take a look at this fairly complicated graph that it managed to deal with (ancestors of the class CatalystX::FeedMe::View::Atom (found at the bottom)).

     .................................
     :        Class::Accessor        :
     :...............................:
       ^
       |
       |
     .................................
  +> :     Class::Accessor::Fast     : <-----+
  |  :...............................:       |
  |    ^                                     |
  |    |                                     |
  |    |                                     |
  |  .................................       |
  |  :    Catalyst::AttrContainer    : ------+---------------------------+
  |  :...............................:       |                           |
  |    ^                                     |                           |
  |    |                                     |                           |
  |    |                                     |                           v
  |  .................................     .......................     ............................
  +- :        Catalyst::Base         : --> : Catalyst::Component : --> : Class::Data::Inheritable :
     :...............................:     :.....................:     :..........................:
       ^
       |
       |
     .................................
     :   Catalyst::View::Atom::XML   :
     :...............................:
       ^
       |
       |
     .................................
     : CatalystX::FeedMe::View::Atom :
     :...............................:


It can even handle groups of nodes (with bounding boxes) and things I thought would be really weird in text-only.

The graph that I display in Emacs is actually quite a bit more compact than the output above. I munged the text a bit to make it fit in the Message window (all upwards arrows are removed since that's the most common inheritance relationship).

     [ Class::Accessor               ]
  +> [ Class::Accessor::Fast         ] <-----+
  |  [ Catalyst::AttrContainer       ] ------+---------------------------+
  |    |                                     |                           v
  +- [ Catalyst::Base                ] --> [ Catalyst::Component ] --> [ Class::Data::Inheritable ]
     [ Catalyst::View::Atom::XML     ]
     [ CatalystX::FeedMe::View::Atom ]


Hopefully that's about the most complicated structure I'll have to visualize.