Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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...

makeGraph('a');
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. (www.touchgraph.com 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 (www.processing.org 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

Comment on drawing (visualizing) directed graphs
Select or Download Code
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.)

    HTH,

    planetscape
      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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://561378]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2015-07-31 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls