magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2002 > January > Programming with Perl  

Generating Clickable Graphs

By Randal L. Schwartz

In this column nearly a year ago, I used the GraphViz program (at www.research.att.com/sw/tools/graphviz) to generate a nice graph to illustrate the flow of users through a Web site. I was recently contracted by a client to complete a similar task. However, as an added requirement, each node on the display had to be clickable, to further refine the query in progress. Not only that, but performing the query and running GraphViz eats up a bit of CPU, so I wanted to cache the picture for a given query result so that others could share it.

Hence, I have a query that generates links. I generate a picture with those links using GraphViz, along with a client side image map that lets me click on the nodes represented in that picture to select a particular node. The image gets written into a cache created with the Cache:FileCache module from the CPAN, indexed by a session number, and referenced in the HTML image map. The session number is computed from the links, so a given link list will reuse the imagemap and image computations if a prior computation has been performed recently enough.

Sound tough? Nope. It's a mere hundred lines of code or so, as illustrated in Listing 1. For this example, I'm not actually performing the query, just simulating it. A textarea form field lets me enter to/from pairs directly. This lets me play around with the rendering logic independent of the query logic, so I can see what some typical images would look and act like.<>




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2