Extension:GraphViz

The GraphViz extension lets you create and display graphs as in-line images on wiki pages using tools from the open-source Graphviz and Mscgen projects:
 * Graphviz (short for Graph Visualization Software) is a package of open-source tools initiated by AT&T Labs Research for drawing graphs specified in DOT files.
 * Mscgen (short for MSC generator) is a software tool for drawing message sequence charts from a text source file.

Installation

 * 1) Install one of the external tools "Graphviz" or "Mscgen".
 * 2) Windows: Get your copy here: http://www.graphviz.org/Download.php or here http://www.mcternan.me.uk/mscgen/
 * 3) Unix: Same links as for windows but normally it should be pre-installed (at least graphviz - search for dot) or can be found in the package manager.
 * 4) Ubuntu/Debian:
 * 5) Download the GraphViz extension archive from GIT and extract it into your MediaWiki "/extensions/GraphViz" directory.
 * 6) Update LocalSettings.php to include the following:
 * 7) * require_once("$IP/extensions/ImageMap/ImageMap.php");
 * 8) * require_once("$IP/extensions/GraphViz/GraphViz.php");
 * 9) Visit your wiki's Special:Version page and verify that the correct version of the GraphViz extension is installed.
 * 10) Set the  parameters in LocalSettings.php if the defaults do not suit your environment.


 * Make sure that write permissions for the "$IP/images" directory are granted.
 * Make sure that internet users get read/execute access on your executables if you use server installations (especially under Windows).

Configuration
For each parameter, add the line  in your LocalSettings.php after the line

Drawing Graphs
You may define a graph in the dot language and enclose it in graphviz tags as follows:

You may define a message sequence chart in the mscgen language and enclose it in mscgen tags as follows:

When the wiki page is saved (or when you click "Show preview" after editing) an image is produced that corresponds to the DOT or mscgen text and it is shown in-line on the page. The image is also uploaded so it may be included in other pages directly.

See the for some basic graphs.

Graph Tag Attributes
Graph tag attributes may be supplied with either graphviz or mscgen as follows:

The following Extended image syntax attributes are supported as graph tag attributes: type, border, location, alignment, size, link, alt, caption.


 * SVG requires additional configuration.

Multiple Graphs Per Page
For graphviz, use unique names for each graph to display multiple graphs on the same page.

For mscgen, use the "uniquifier" tag attribute to display multiple message sequence charts on the same page.

Links
Graphs in the DOT and mscgen languages may include URLs. These follow the pattern URL="link" where "link" is governed by the ImageMap syntax:

"'All links are given in either the form Page title or description . In the latter case, the part after the pipe becomes the title attribute of the link—in most browsers, it will pop up as a tooltip when the user hovers over it; the part after the pipe also becomes the alt text for the link. If no explicit link description is given, the page title is used.'"

Additionally, external links are supported with or without square brackets. Specify external links without square brackets in order to honor DOT tooltip attributes (e.g. URL=" http://mediawiki.org ", tooltip="MediaWiki"). The MediaWiki "external link with different label" form is also supported (e.g. MediaWiki ).

See for an example with links.

Restrictions
This extension imposes the following restrictions on the DOT language input:
 * Any image attribute values are required to be the names of uploaded files.
 * Any IMG SRC attribute values in HTML-like labels are required to be the names of uploaded files.
 * The imagepath attribute is not allowed.
 * The deprecated shapefile attribute is not allowed.
 * The fontpath attribute is not allowed.

Example 3


You can see many more examples of images created with Graphviz in this Flickr gallery.

Tutorials/online samples
See here for examples of this extension in use on other wikis:
 * http://www.wikischool.de/wiki/WikiSchool:Graphviz
 * http://wiki.zum.de/Hilfe:Graphviz
 * http://www.wickle.com/wikis/index.php/Graphviz_extension (old)
 * http://www.EcoReality.org/wiki/Test:Graphviz (comments) (maintained very well)
 * http://www.nerux.org/wiki/Graphviz and http://www.nerux.org/wiki/Accueil

Contributions and history

 * In 2004 the user Coffman created an extension to MediaWiki in response to a basic need: rendering graphs online. He found the utility Graphviz in use on another wiki application, and thought about adapting it for MediaWiki (the wiki he actually used). Exploring the Graphviz tool, he discovered an incredible tool for making graphs.
 * Later on, many people improved the extension on their own or provided little bug fixes as snippets on the discussion page. This led to several functional solutions for different use cases, and to a bit of chaos.
 * In 2006 Gregory Szorc independently created his own GraphViz extension, this one called "Graphviz" (small "v"), that included some helpful features like autopruning.
 * Also in 2006, Ruud Schramp created the MscGen extension, adapting the code from the GraphViz extension to work with MscGen.
 * In 2008 Matthew Pearson created the extension GraphVizAndMSCGen, combining the code from the GraphViz with the MscGen extension.
 * In 2010 Thomas Hummel merged these and other versions, along with his own fixes, to try to create a working solution for several OSes in one file.
 * In 2011 Jeroen De Dauw uploaded the resulting code onto MediaWiki SVN.
 * In 2014, Keith Welter re-wrote the extension (creating version 1.0) to improve security, performance, documentation and ease of use. New features with version 1.0 include:
 * rendered graph images are uploaded to the wiki
 * graphs are only re-rendered when the graph source changes
 * embedded links work properly when the graph image is resized (powered by Extension:ImageMap)
 * embedded links support tooltips (powered by Extension:ImageMap)
 * DOT image attribute support
 * deterministic file clean-up (active files are retained, inactive files are deleted)
 * security fixes
 * extensive internal documentation (doxygen format)

Dependencies
The GraphViz extension depends on Extension:ImageMap.

The following extensions depend on the GraphViz extension:
 * The "Semantic Result Formats" extension is used in conjunction with the Semantic MediaWiki extension, that bundles a number of further result formats for SMW's inline queries.
 * graph format (displays connections between pages as graphs)
 * process format (displays process graphs)
 * Extension:Collaboration_Diagram (renders and visualizes a bipartite graph of any article and its editors)