Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

drawing (visualizing) directed graphs

by punkish (Priest)
on Jul 15, 2006 at 01:24 UTC ( #561378=perlquestion: print w/replies, xml ) Need Help??
punkish has asked for the wisdom of the Perl Monks concerning the following question:

I have a sample data structure like so --

%d = ( a => [b,c,d,], b => [a,d,], c => [b,d,e,], ); and so on...

I would like to create a directed graph (I believe I am using the term correctly) and visualize it such that...

will create a "picture" with 'a' as the origin and arrows to b, c, and d... clicking on, say, 'b' will call makeGraph('b'), and so on.

I believe I can accomplish this with Graphviz family of modules, but there are two problems with Graphviz... one, the output is pretty, how shall I say this politely, not nice. Maybe that can be adjusted with further exploration. But, more than that, it is really a static picture. Ideally I would like one of those springy network visualizations that one sees on Amazon and C|Net, etc. ( has a nice WikiBrowser that does something like this, except, in a standalone app... eventually I want this to work in a browser). I realize this would have to be done in something like Java ( comes to mind), but perhaps I can do the coding in Perl, and then send off the data to the Java applet.

In any case, I am looking for some starting directions here.

Many thanks,


when small people start casting long shadows, it is time to go to bed

Replies are listed 'Best First'.
Re: drawing (visualizing) directed graphs
by NetWallah (Abbot) on Jul 15, 2006 at 02:43 UTC
    I have tested this lightly, and Graph::Easy seems to work - it should meet your requirements. It can "Render graphs as ASCII, HTML, SVG or Graphviz".

    From the docs:

    use Graph::Easy; my $graph = Graph::Easy->new(); $graph->add_edge_once ('Bonn', 'Berlin'); print $graph->as_ascii( ); # prints: # +------+ +--------+ # | Bonn | --> | Berlin | # +------+ +--------+
    There is a tutorial,and samples, at the author's website.

         "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken

Re: drawing (visualizing) directed graphs
by lima1 (Curate) on Jul 15, 2006 at 08:30 UTC
    I evaluated a bunch of tools. I ended up using the yed editor and generating a XML file for yed in my perl scripts. yed comes with a lot of different layout modules. looks great.
Re: drawing (visualizing) directed graphs
by planetscape (Chancellor) on Jul 15, 2006 at 09:26 UTC

    Mastering Algorithms in Perl has an entire chapter (8) devoted to Graphs; you may be able to find something useful in the sample code. (The end of the chapter also has an overview of graph-related CPAN modules.)


      Mastering Algorithms in Perl has an entire chapter (8) devoted to Graphs

      but nothing about graph drawing. I don't know any open source library that produces good looking graphs - for all type of graphs, not only some special cases.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://561378]
Approved by ikegami
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2017-06-24 14:06 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (558 votes). Check out past polls.