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.

From the MediaWiki Extension Distributor
Download from Special:ExtensionDistributor/GraphViz

With Composer
From MediaWiki version 1.22 onwards, GraphViz should be installed using built-in Composer support. The package name is. For instructions on how to install Composer see MediaWiki's user manual for Composer. MediaWiki versions prior to 1.22 can use Composer via Extension:ExtensionInstaller.

Once you have Composer properly installed, go to your MediaWiki installation directory and add the extension to your to your :

And then run:

Without Composer

 * 1) Download the GraphViz extension archive from GIT and extract it into your MediaWiki "/extensions/GraphViz" directory.

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:   and


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

Note: Under Linux, shell commands such as the Graphviz and mscgen executables are invoked with the limits given by $wgMaxShellTime, $wgMaxShellMemory and $wgMaxShellFileSize. If graphs or message sequence charts do not render then you may need to tune these settings for your installation.

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.

The option  makes it also possible to use GraphViz and templates and import these into a MediaWiki site. Changes to the original template will then be passed on. No option will lead to two images, in case of a change to the original, of which the older version will always be imported should the template be called.
 * 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 ).

Remark: "The link format is different from the format used in earlier versions. ( < 1.0)."

See for an example with links.

Finding graphs and message sequence charts
Pages with graphs or message sequence charts will have the "graphviz" page property set. Using Special:PagesWithProp, you can find pages that have graphs or message sequence charts. ([//en.wikipedia.org/wiki/Special:PagesWithProp?propname=graphviz&propname-other= Example query for the English Wikipedia].)

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
 digraph example1 {Hello->World}

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 example3 { 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 }

Contributions and history
See RELEASE-NOTES.md.

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)
 * Extension:Genealogy, for displaying family tree diagrams.