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.

Graphviz
sudo aptitude install graphviz graphviz-dev (test from Ubuntu 12.04 LTS)
 * 1) First, you need at least one of the external tools "Graphviz" or "Mscgen" that renders your graph.
 * 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:
 * 1) Then obtain the Graphviz extension code by downloading a snapshot or from GIT

cd extensions git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/GraphViz.git


 * 1) and then put it in your MediaWiki "/extensions/GraphViz" directory.
 * 2) Ubuntu 10.10 comes with an earlier version of the GraphViz extension pre-installed - this is a very old version, though, so you'd be better off replacing it.
 * 3) Add these lines to LocalSettings.php:
 * Windows Default: "C:/Program Files/Graphviz/bin/" (without dot.exe) or "C:\\Program Files\\Graphviz\\bin\\"
 * Other Platform : "/usr/bin/" or "/usr/local/bin/" (where the dot binary is)


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

MscGen
The same procedure as with Graphviz - the path to MscGen has to be provided in LocalSettings.php:

Configuration
There are some additional configuration parameters that help you to define a basic behavior of the extension. If you don't use these parameters they contain a default value that leads to a (hopefully) good usage of the extension. For each parameter add the line  in your LocalSettings.php after the  -line.

You don't need to set these values if everything works fine for you. They are used in the LocalSettings.php only for the default behavior of all graphs in this wiki. Some parameters can be set for each individual graph (see or ).

Drawing Graphs
Write your Graph in the dot language or mscgen language and put it into  or. See the for some basic graphs.

Multiple Graphs
This extension supports multiple graphs on one wiki page.

If you name the pictures by the graph names (named='named'), simply give the graphs different names. That means that the following two graphs can be put together on on page.

The mscgen language does not support graph names. Therefore, the "uniquifier" tag parameter may be used to distinguish one message sequence chart from another.

Wiki-links
In dot you can define a URL for each node. This is normally done before defining the graph. See for an example with Wiki-links.

In case you need an external URL, write this:

And for an internal link in your wiki, write this:

That's all.

Wiki styling
In case you want to put some kind of structure into your page you can use some image attributes as for any other image (in the style of regular MediaWiki syntax), like here: Extended image syntax).

The attributes are used like HTML attributes (e.g. ).

Renderer
This extension can handle two applications for graph-drawing: Graphviz and Mscgen. Graphviz comes with several rendering engines and Mscgen has its own. For Graphviz, different renderers are ideal depending on the use case. More information on the renderers for each application can be found on their respective websites.

You can define a renderer as the default (see ), or set it in an individual graph with an attribute (-> ).

Image types
Graphviz and Mscgen can produce a huge amount of different image types (see more on their websites). The GraphViz extension supports only some of them: Note: To display vector-graphics you have to configure your wiki installation properly (-> SVG)
 * Graphviz: bmp, gif, jpg, jpeg, png, svg, svgz
 * Mscgen: png, svg

You can define an image type as default (-> ) or add it to the individual graph with an attribute (-> ).

Examples
For a start you can try these Examples:

Example 1

Example 2

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 to leverage the ImageMap extension and to improve security, performance, documentation and ease of use.

Projects that rely on this 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)