rastoboy has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm trying to decipher some extremely large datastructures (specifically in cPanel's EasyApache code) for my own edification, and I've been experimenting with GraphViz::Data::Structure and GraphViz::Data::Grapher (as per this awesome post http://www.perlmonks.org/?node_id=481745), and from my initial tests either one would be just a terrific help in comprehending this monster. Also it's really cool.

However, I'm having trouble figuring out how to get these modules to do this in an intelligible fashion.

For example, with *::Structure I get this 5 meg png:

http://singularityfps.com/images/output_structure.png

As you can see, it's kinda squashed. Is there any way to control that? I don't see anything on the cpan documenation on either module to try to manipulate the way it draws the diagram.

I did get a 5 meg postscript that looks a heck of a lot better (setting my pagesize to 10000 x 10000 pt in Ghostview enables one to see part of it) but even it has some pretty dense areas, and of course it's quite difficult to view because it's so large:

http://singularityfps.com/images/output_structure.ps

Lastly with Grapher when I feed it the main object reference in the same way, I get this wonderfully helpful diagram:

http://singularityfps.com/images/output_grapher.png

Again I can't see what I'm doing wrong from the docs.

Any input, specific or general, would be greatly appreciated! I'm a novice to this sort of programming.

Replies are listed 'Best First'.
Re: Visualizing very large datastructures
by james2vegas (Chaplain) on Aug 22, 2009 at 09:28 UTC
    Normally I would use GraphViz by itself, and pass it options as to how to draw nodes and connectors, but GraphViz::Data::Grapher doesn't expose those options.

    Reading the code here is a horribly hackish way to pass GraphViz options to GraphViz::Data::Grapher:

    use strict; use warnings; use GraphViz; use GraphViz::Data::Grapher; my %othergraphvizopts = ( compress => 1 ); my $structure = [ 'a', 'b', 'c', { hi => 'there' } ]; my $g = GraphViz->new(sort => 1, %othergraphvizopts); GraphViz::Data::Grapher::_init($g, $structure); print $g->as_png;

    That is a horrible hack, but should work.

    The compress => 1 is just an example, consult GraphViz->new for options. The sort => 1 is from GraphViz::Data::Dumper's new

    If you use GraphViz::Data::Structure, it seems like a decent alternative, supports a more concise graph and also lets you pass in options directly to the underlying GraphViz object or use a pre-constructed GraphViz object, no hack needed.

    use GraphViz; use GraphViz::Data::Structure; my %othergraphvizopts = ( compress => 1 ); my $structure = [ 'a', 'b', 'c', { hi => 'there' } ]; my $g = GraphViz->new(%othergraphvizopts); my $g1 = GraphViz::Data::Structure->new($structure, GraphViz => $g); print $g->as_png;
Re: Visualizing very large datastructures
by spx2 (Deacon) on Aug 23, 2009 at 06:38 UTC
    Out of curiosity, how long did GraphViz take to render that ? I had the same problem you mention, you may want to check out this node. You can't really fit all that data on your screen so there are other ways of displaying it, check out InfoVis Toolkit for Javascript here.