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.

MediaWiki 1.22+ (Composer)
From MediaWiki version 1.22 onwards GraphViz should be installed using Composer. The package name is. For instructions on how to install Composer see MediaWiki's user manual for Composer.

Once you have Composer properly installed, go to your MediaWiki installation directory and run:
 * for the latest stable version or
 * for the latest development version

For future updates call  or.

MediaWiki <1.22 (Git)

 * 1) Download the GraphViz extension archive from GIT and extract it into your MediaWiki "/extensions/GraphViz" directory.
 * 2) Update LocalSettings.php to include the following:

Common

 * 1) Update LocalSettings.php to include the following:
 * 2) Visit your wiki's Special:Version page and verify that the correct version of the GraphViz extension is installed.
 * 3) Install one of the external tools "Graphviz" or "Mscgen".
 * 4) Windows: Get your copy here: http://www.graphviz.org/Download.php or here http://www.mcternan.me.uk/mscgen/
 * 5) 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.
 * 6) Ubuntu/Debian:
 * 1) Ubuntu/Debian:


 * 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
Set configuration parameters in LocalSettings.php only if the defaults do not suit your environment. 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:

dot-language

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

mscgen-language

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:

 dot-language

 mscgen-language

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 shapefile attribute is not allowed.
 * The fontpath attribute is not allowed.

Examples
In addition to the examples below, here is a nice flickr gallery of graphviz-rendered graphs.

Example 1
 {Hello->"123!"}

Example 2
 graph EXAMPLE2 { run -- intr; intr -- runbl; runbl -- run; run -- kernel; kernel -- zombie; kernel -- sleep; kernel -- runmem; sleep -- swap; swap -- runswap; runswap -- new; runswap -- runmem; new -- runmem; sleep -- runmem; }

Example 3
 digraph G { node [shape=plaintext]; Mollusca [URL="Mollusca"]; Neomeniomorpha [URL="Neomeniomorpha"]; X1 [shape=point,label=""]; Caudofoveata [URL="Caudofoveata"]; Testaria [URL="Testaria"]; Polyplacophora [URL="Polyplacophora"]; Conchifera [URL="Conchifera"]; Tryblidiida [URL="Tryblidiida"]; Ganglioneura [URL="Ganglioneura"]; Bivalvia [URL="Bivalvia"]; X2 [shape=point,label=""]; X3 [shape=point,label=""]; Scaphopoda [URL="Scaphopoda"]; Cephalopoda [URL="Cephalopoda"]; Gastropoda [URL="Gastropoda"]; Mollusca->X1->Testaria->Conchifera->Ganglioneura->X2->Gastropoda Mollusca->Neomeniomorpha X1->Caudofoveata Testaria->Polyplacophora Conchifera->Tryblidiida Ganglioneura ->Bivalvia X2->X3->Cephalopoda X3->Scaphopoda }

Example 4
msc { a,b,c;

a->b [label="ab"]; b->c [label="bc(TRUE)"]; c=>c [label="process(1)"]; c=>c [label="process(2)"]; ...; c=>c  [label="process(n)"]; c=>c [label="process(END)"]; a<<=c [label="callback"]; ---  [label="If more to run", ID="*"]; a->a [label="next"]; a->c [label="ac"]; b<-c [label="cb(TRUE)"]; b->b [label="stalled(...)"]; a<-b [label="ab = FALSE"]; }

Contributions and history

 * Composer support was added in version 1.1.0.
 * 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)
 * support for multiple message sequence charts per page
 * security fixes
 * extensive internal documentation (doxygen format)
 * See Extension:GraphViz/v0.9 for history prior to version 1.0.

Dependencies
The GraphViz extension depends on Extension:ImageMap as of version 1.0.

The following extensions depend on the GraphViz extension:
 * Extension:SemanticResultFormats, used in conjunction with Extension:SemanticMediaWiki, bundles a number of 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)