User:Hummel-riegel/GraphViz

This page is under construction Attention: This Extension is currently work in progress - The code may be functional but I don't give any guarantees Please visit the Extensions Extension:Graphviz oder Extension:GraphVizAndMSCGen for the actual code that I want to improve here.

Feel free to add your own stuff or to modifiy this page!

= Extension:GraphViz =

Graphviz is a program/language that allows the creation of numerous types of graphs. This extension allows the embedding of graphviz markup in MediaWiki pages and generates inline images to display. Mscgen is a small program that parses Message Sequence Chart descriptions. Unlike Graphviz, this program does no clever layout operations or spline routing as this is not needed.

Automatic graph drawing has many important applications in software engineering, database and web design, networking, and in visual interfaces for many other domains. You can use the provided language (e.g. dot) and create graphs with that within the wiki. There are also some other extensions that provide other intefaces for individual solutions.

Contributions
In 2004 the User Coffman created an extension to mediawiki in response to a basic need : Render Graphs online. He found the utility Graphviz on another wiki, and thought about adopting it to mediawiki (the wiki he actually used). Exploring the Graphviz tool he discovered an incredible tool to making Graphs. Later on many people improved the extension on their own or provided little bugfixes as snippets on the dicussion page. This led to several functional solutions for different use cases and to a bit of chaos. Now (Fall 2010) I, (Thomas Hummel), tried to merge the most common solutions so that we finally have another working solution for several OSes in one file. As I am not that well known to PHP so there might be several long-winded or impractical lines in the code - feel free to send me your improvements or comments (Discussion-Page, Message or whatever). I started with the "improved version" from an unknown Coder and tried to fix some things on my own and then include parts of the code of other "improvements". Good sources were for example Extension:GraphVizAndMSCGen by Matthewpearson.

Graphviz

 * 1) First of all 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 preinstalled (at least graphviz - search for dot) or can be found in the package manager.
 * 4) Then Copy the Code found here /Graphviz.php into a file called Graphviz.php and and place it in  .  ##Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
 * 5) On Ubuntu 10.10 an earlier version of the Graphviz-Extension has been added to the default (see also Manual:Running_MediaWiki_on_Ubuntu) - although this is a very old version, so you'd better replace it with the one provided /Graphviz.php here.
 * 6) Make sure that write permissions for the "$IP/images" directory are granted.
 * 7) Add these lines to LocalSettings.php:
 * Windows Default: "C:/Programme/ATT/Graphviz/bin/" (without dot.exe)
 * Other Platform : "/usr/bin/" or "/usr/local/bin/" (where the dot binary is)

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

If haven't tested this actually, so there might be some mistakes.

Differences to previous versions
The varable $dotCommand that points only to the dot executable is replaced (like in GraphVizAndMSCGen) with $execPath that lets you choose between several renderers.

Configuration Parameters
There are some additional configuration parameters that help you to define a basic behaviour 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.

Each of these parameters beside the execPath and mscgenPath can be changed for each individual graph created. They are used in the LocalSettings.php only for the default behaviour of all graphs in this wiki.

missing: name, border, position, renderer, ....

Drawing Graphs
Basically you only need to write your Graph in the dot language (or any other supported language by Graphviz or MscGen) and put it into  or.

Examples
http://www.wikischool.de/wiki/WikiSchool:Graphviz http://wiki.zum.de/Hilfe:Graphviz

Code
/Graphviz.php

Development
Since I'm not a very experienced developter it would be nice if some "experts" could review the code or improve it on some edges.

I'm also happy if you'd notify me about bugs or problems you have (e.g. on the Discussion page).

Important points

 * Check for Security Leaks

Things that should be done

 * Provide this on a svn-Server?
 * Change the old version on the ubuntu default extensions package

Alternatives
If you don't like this extension there are some others that I find remarkable (although I tried to put the main functionality of all of them into this extenstion).
 * I don't know how good this acutally works but it seems well coded
 * Extension:Graph This Extension lets you draw ASCII-Art, SVG, and Graphviz-Images without(?) the use of the Graphviz-Tool
 * Extension:FreeMind uses the FreeMind-Tool to draw graphs
 * Extension:Semantic_Graph also uses the FreeMind-Tool to draw (as an alternative to the

Projects based on this extenstion

 * 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.
 * Extension:Semantic Result Formats/graph_format (displays connections between pages (as graph)
 * Extension:Semantic Result Formats/process_format (displays process graphs)