Rockbox.org home
releases
current build
extras FAQ
manual
wiki
docs index mailing lists
IRC
forums bugs
patches



Welcome | Register | Changes | Topics | Index | Search | Go
TWiki > TWiki > DirectedGraphPlugin

Directed Graph Plugin

Introduction

Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. Automatic graph drawing has many important applications in software engineering, database and web design, networking, and in visual interfaces for many other domains.

This plugin uses Graphviz's applications to create a png image of a directed graph. The graph is described in a simple text markup called "the DOT language".

Visit the Graphviz gallery to see some examples on what can be achived with this plugin and Graphviz. Full documentation is available at http://graphviz.org/Documentation.php.

DirectedGraphPlugin supports the following engines:

  • dot - makes "hierarchical" or layered drawings of directed graphs. The layout algorithm aims edges in the same direction (top to bottom, or left to right) and then attempts to avoid edge crossings and reduce edge length.
  • neato and fdp - make "spring model" layouts. neato uses the Kamada-Kawai algorithm, which is equivalent to statistical multi-dimensional scaling. fdp implements the Fruchterman-Reingold heuristic including a multigrid solver that handles larger graphs and clustered undirected graphs.
  • twopi - radial layout, after Graham Wills 97.
  • circo - circular layout, after Six and Tollis 99, Kauffman and Wiese 02. Suitable for certain diagrams of multiple cyclic structures.

Syntax Rules

Enclose the description for your directed graph within <dot> ... </dot> tags.

You can use the following parameters in the dot tag to control the rendering of your graph:

Parameter: Description: Default:
antialias="on" Enable antialising of current graph by setting this to on. off
density="300" Input parameter for the convert utility from imagemagick. 300
size="2000x1600" When antialiasing is on, this parameter controls size of rendered image (use size parameter in graph description for controlling the size of the image with antialiasing off). 800x600
map="on" Create a client side map for the generated image. This will turn any [URL="..."]; attribute in the graph description into a clickable area (see demonstration below). off
vectorformats="ps svg" The PNG file created from the graph per default is a bitmap file. If you need a vectorbased file rendering as well, you can specify ps or svg formats (will be attached to topic, visible under attachments view). none
engine="neato" Which layout engine to use for the graph: One of dot, neato, twopi, circo or fdp. dot
library="Main.GroupIcons" Which icon library topic to use for custom shapes ([shapefile] parameter). Needs to be explicitly set, also if icons are attached locally to the current graph topic. See demo below. TWiki.DirectedGraphPlugin

Sitewide default settings are set in this topic and can be overwritten for each graph. When you change a setting the graph will be re-generated.

Howto

HowtoDirectedGraphs has a basic howto on creating directed graphs using dot.

Examples

Cole's example

You type:

<dot>
digraph G {
    subgraph cluster_c0 {a0 -> a1 -> a2 -> a3}
    subgraph cluster_c1 {
        b0 -> b1 -> b2 -> b3;
        label="Group B";
    }
    x -> a0 [style=dotted];
    x -> b0;
    a1 -> a3 [style=bold, label="a1 to a3"];
    a3 -> a0;
    a0 [shape=box, fontname=Courier, fontsize=11];
    a1 [color=red];
    a3 [label="Label\nfor a3"];
    label="Cole's Example";
}
</dot> 

You get: (simulated)
graphsample.png
You get: (if installed)
digraph G { subgraph cluster_c0 {a0 -> a1 -> a2 -> a3} subgraph cluster_c1 { b0 -> b1 -> b2 -> b3; label="Group B"; } x -> a0 [style=dotted]; x -> b0; a1 -> a3 [style=bold, label="a1 to a3"]; a3 -> a0; a0 [shape=box, fontname=Courier, fontsize=11]; a1 [color=red]; a3 [label="Label\nfor a3"]; label="Cole's Example"; }

Clientside imagemap (clickable nodes and edges)

You type:

<dot map=1>
digraph G {
    URL="http://www.twiki.org";
    Plugins [URL="http://twiki.org/cgi-bin/view/Plugins/PluginPackage"];
    DirectedGraphPlugin [URL="http://twiki.org/cgi-bin/view/Plugins/DirectedGraphPlugin"];
    Plugins -> DirectedGraphPlugin;
}
</dot>

You get: (simulated)
You get: (if installed)
digraph G { URL="http://www.twiki.org"; Plugins [URL="http://twiki.org/cgi-bin/view/Plugins/PluginPackage"]; DirectedGraphPlugin [URL="http://twiki.org/cgi-bin/view/Plugins/DirectedGraphPlugin"]; Plugins -> DirectedGraphPlugin; }
You get: (simulated, antialising on)
graphsample2_antialiased.png
You get: (if installed, antialising on)
digraph G { URL="http://www.twiki.org"; Plugins [URL="http://twiki.org/cgi-bin/view/Plugins/PluginPackage"]; DirectedGraphPlugin [URL="http://twiki.org/cgi-bin/view/Plugins/DirectedGraphPlugin"]; Plugins -> DirectedGraphPlugin; }

Usecase description / state diagram

View source of this page to see graph description.

You get: (simulated)
usecase_sample.png
You get: (if installed)
digraph G { size="7,7"; graph [rankdir="TB" label="1st Time Use/Phone Registration" fontsize=12 bgcolor="#eeeeff"]; node [shape=box fontsize=9]; edge [color=blue fontsize=8 font="Arial"];

cell_number_entry [label="Cell Number Entry"]; welcome [label="Welcome Page"]; member_name_creation [label="Member Name Creation"]; password_creation [label="Password Creation"]; member_name_unavailable [label="Member Name Unavailable"]; email_entry [label="Email Entry"]; zip_code_entry [label="Zip Code Entry"]; tos [label="TOS"]; decline_confirmation [label="Decline Confirmation"]; registration_confirmation [label="Registration Confirmation"]; member_name_entry [label="Member Name Entry"]; password_entry [label="Password Entry"]; confirm_phone_number [label="Confirm Phone Number"]; unsuccessfull_sign_in [label="Unsuccessfull Sign In"]; email_confirmation [label="Email Confirmation"]; main_menu [label="Main Menu"]; initial_screen [label="Initial Screen"]; exit_application [label="Exit the Application"];

welcome -> initial_screen [label="First Time"] initial_screen -> member_name_creation [label="Register"]; initial_screen -> member_name_entry [label="Sign In"]; member_name_creation -> password_creation [label="Valid Member Name" dir="both"]; member_name_creation -> member_name_unavailable [label="Invalid Member Name" dir="both"]; welcome -> password_creation; password_creation -> cell_number_entry [dir="both"]; member_name_entry -> password_entry [dir="both"]; cell_number_entry -> email_entry [dir="both"]; password_entry -> confirm_phone_number [label="Auth. Successful" dir="both"]; password_entry -> unsuccessfull_sign_in [label="Auth. Unsuccessful"]; email_entry -> zip_code_entry [dir="both"]; zip_code_entry -> tos [dir="both"]; confirm_phone_number -> main_menu; unsuccessfull_sign_in -> member_name_entry [label="Try Again" constraint="false"]; unsuccessfull_sign_in -> email_confirmation; tos -> decline_confirmation [label="Decline" dir="both"]; tos -> registration_confirmation [label="Accept"]; decline_confirmation -> exit_application [label="Yes"]; registration_confirmation -> main_menu [label="10 Sec/NEXT"]; }

Component architecture

This is a typical example of a component architecture drawing (This kind of graph is also easy to do in TWiki:Plugins.TWikiDrawPlugin if you like the look but you prefer to draw it manually using your mouse).

View source of this page for graph description.

You get: (simulated)
sample_component_architecture.png
You get: (if installed)
digraph G { graph [rankdir=LR, size="9.5,2.5"] subgraph cluster_0 { graph [label=User] edge [style=dashed] browser [label="WWW\nbrowser" URL="http://www.mozilla.org/"] svgplugin [label="SVG Plugin" URL="http://www.adobe.com/svg/viewer/install/old.html"] pdfplugin [label="PDF Plugin" URL="http://www.adobe.com/support/downloads/product.jsp?product=10&platform=unix"] svgplugin -> browser svgplugin -> browser [dir=back] pdfplugin -> browser pdfplugin -> browser [dir=back] { graph [rank=same] pngpage [label=PNG shape=box URL="/cgi-bin/webdot/webdot/demo.dot.dot.png"] svgpage [label=SVGZ shape=box URL="/cgi-bin/webdot/webdot/demo.dot.dot.svgz"] pdfpage [label=PDF shape=box URL="/cgi-bin/webdot/webdot/demo.dot.dot.pdf"] } pngpage -> browser [dir=none style=dotted] svgpage -> svgplugin [dir=none style=dotted] pdfpage -> pdfplugin [dir=none style=dotted] } subgraph cluster_1 { graph [label="Server 1"] httpd1 [label=httpd URL="http://httpd.apache.org/"] webdot [label="/cgi-bin/webdot" style=filled fillcolor=yellow color=black URL="/webdot/"] } subgraph cluster_2 { graph [label="Server 2"] httpd2 [label=httpd URL="http://httpd.apache.org/"] "demo.dot" [shape=box URL="/webdot/demo.dot"] httpd2 -> "demo.dot" [dir=none style=dotted] } browser -> httpd1 -> webdot -> httpd2 browser -> httpd1 -> webdot -> httpd2 [dir=back] }

Simple LAN setup (custom icons / shapefiles)

This type of graph can also easily be extended, for instance making network nodes clickable, pointing to asset databases or similar.

View source of this page for graph description.

You get: (simulated)
sample_simple_lan_setup.png
You get: (if installed)
digraph G { edge [arrowhead=none color=blue]; node [fontcolor=blue color=white];

Workstation [shapefile="Sun_Workstation.png"]; Printer [shapefile="Printer.png"]; Internet [shapefile="Cloud-Filled.png"]; Router [shapefile="Wireless_Router.png"]; Switch [shapefile="Workgroup_Switch.png"]; Laptop [shapefile="Laptop.png"];

Workstation -> Switch; Printer -> Switch; Switch -> Router; Router -> Internet; Laptop -> Router [style=dotted]; }

DirectedGraphPlugin Global Settings

  • One line description, shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Embed directed graphs in TWiki topics (using the Graphviz package)

  • Layout engine to use per default. Can be one of dot, neato, twopi, circo, fdp
    • Set ENGINE = dot

  • Antialias option. If set to on the plugin will use the convert binary from the imagemagick package to pretty print graphs. This option should not be used with clientside maps as pixel dimensions are usually altered in this process and therefore the "hot spot" locations will not match the generated image. With antialising off, rendering size is controlled by dot (can be effected by an eventual size parameter in the digraph description), with antialising on you set the final image size in pixels explicitly with the size parameter. (If you must use an image map with this option, take care manually that the two generated pixel sizes match).
    • Set ANTIALIAS = off

  • Default density (dpi) for antialias option. 300 dpi should be sufficient for most purposes (if your graphs look blurred at large image sizes try using a higher value).
    • Set DENSITY = 300

  • Default image size (pixels, widthxheight) for antialias option (keeps aspect ratio; enlarges until max of one of the dimensions is reached).
    • Set SIZE = 800x600

  • Additional vector formats to create per default. Displayed version is always PNG, others are attached. Options are ps and svg (comma separated). The ps format is useful to have handy if you are later converting your document to LaTeX or other typesetting / publication utility. The svg format has inline clickable map if used.
    • Set VECTORFORMATS = none

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: The following instructions are for the administrator who installs the plugin on the server where TWiki is running.

  • Install the Graphviz package
  • Install required web fonts
    • Install the ImageMagick package
  • Install the Perl module Digest::MD5
  • Download the ZIP file from the Plugin web (see below)
  • Unzip DirectedGraphPlugin.zip in your twiki installation directory.

Plugin zip content:

File: Description:
data/TWiki/DirectedGraphPlugin.txt Plugin topic
data/TWiki/DirectedGraphPlugin.txt,v Plugin topic repository
lib/TWiki/Plugins/DirectedGraphPlugin.pm Plugin Perl module
pub/TWiki/DirectedGraphPlugin/graphsample.png sample image
pub/TWiki/DirectedGraphPlugin/graphsample2.png sample image

Dependencies:

Package: Description:
Graphviz dot Preprocessor for drawing directed graphs
ImageMagick Postprocessor for antialising rendered graphs (optional)
Digest::MD5 MD5 Perl module
Web fonts Fonts required for dot's png creations
  • Customize paths to executables to your environment (in DirectedGraphPlugin.pm set $enginePath, $dotHelperPath, $execCmd, $antialiasCmd to correct paths for your environment)
  • (Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.

To install the web fonts, download this rpm and run the command rpm --install webfonts-1.0-5.noarch.rpm (Red Hat only).

Plugin Info

Plugin Author: TWiki:Main/ColeBeck
Plugin Version: 16 Apr 2006 (V1.220)
Change History:  
12 Jun 2006: Optional antialias parameter added (using ImageMagick). Support for custom icons (shapefiles) added. Support for five layout engines added. Support for attaching vectorbased renderings added. -- TWiki:Main.SteffenPoulsen
16 Apr 2006: Minor fix for areamap (Firefox compatibility) -- TWiki:Main.SteffenPoulsen
12 Apr 2006: Incorporated Sandbox security mechanism -- TWiki:Main.SteffenPoulsen
24 Oct 2005: Incorporated areamap patch (TWiki:Main.MagnusLewisSmith) -- TWiki:Main.JoanTouzet
13 Apr 2005: Added clientside maps functionality; correctly finds pub directory
25 Mar 2005: Cleaner code
01 Jul 2004: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.024
CPAN Dependencies: CPAN:Digest::MD5
Other Dependencies: Graphviz (from http://www.graphviz.org/) and ImageMagick (from http://www.imagemagick.org/). ImageMagick is optional and needed only for creating antialiased graphs.
Perl Version: 5.005
TWiki:Plugins/Benchmark: GoodStyle 100%, FormattedSearch 100%, DirectedGraphPlugin 100%
Plugin Home: http://twiki.org/cgi-bin/view/Plugins/DirectedGraphPlugin
Feedback: http://twiki.org/cgi-bin/view/Plugins/DirectedGraphPluginDev
Appraisal: http://twiki.org/cgi-bin/view/Plugins/DirectedGraphPluginAppraisal

Related Topics: TWikiPreferences, TWikiPlugins

-- TWiki:Main.ColeBeck - 01 Jul 2004

Attachment Action Size Date Who Comment
png Cloud-Filled.png manage 8.4 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png Laptop.png manage 7.2 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png Printer.png manage 7.6 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png Sun_Workstation.png manage 6.1 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png Wireless_Router.png manage 7.6 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png Workgroup_Switch.png manage 6.5 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png graphsample.png manage 5.1 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png graphsample2.png manage 1.3 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png graphsample2_antialiased.png manage 12.3 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png sample_component_architecture.png manage 50.7 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png sample_simple_lan_setup.png manage 27.4 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script
png usecase_sample.png manage 106.7 K 19 Jul 2006 - 14:07 TWikiAdminGroup Saved by install script

r4 - 20 Jul 2006 - 15:45:54 - BjornStenberg
Edit | View raw | Attach | Ref-By | History: r4 < r3 < r2 < r1 | More | Refresh cache

Copyright © 1999-2008 by the contributing authors.