Extension:Semantic Graph

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
Semantic Graphs

Release status: beta

Implementation Parser function
Description An extension which depends on Semantic MediaWiki and Semantic Forms, that generates graphs and trees based on semantic and non semantic wiki structures
Author(s) Rob Challen (Rjchallentalk)
Latest version 0.9.0 (2011-06-02)
MediaWiki 1.13+
Database changes No
License GPL v2+
Download sourceforge.net
Example semanticgraph.sourceforge.net
if anyone has a web accessible wiki they are happy to host this on then let me know ...

Translate the Semantic Graph extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

Prerequisites[edit | edit source]

  • Tested against MW 1.13
  • Semantic MediaWiki 1.4.0, issues with most 1.6 version of SMW
  • Semantic Forms 1.3.7

You must have a working graphviz installation (see: http://www.graphviz.org/)

If your path to dot (which you can find by the command 'which dot') is not /usr/bin/dot then you will extra steps during configuration (see below)

Installations Steps[edit | edit source]

Get the files from https://sourceforge.net/projects/semanticgraph/
1) extract the files into the extensions directory of your MediaWiki e.g: tar -xvf SemanticGraph.tar.gz <wiki home>/extensions/SemanticGraph

2) Download the freemind applet jar file from: http://surfnet.dl.sourceforge.net/sourceforge/freemind/freemind-browser-0_7_1.zip

extract the file "freemind.jar" and put it in the directory: <wiki home>/extensions/SemanticGraph/libs where <wiki home> is the install path of your MediaWiki.

(this file is actually included in the download above so this step is not necessary)

3) Download the hypergraph applet and graph document type declaration from

wget http://hypergraph.sourceforge.net/hyperapplet.jar
wget http://hypergraph.sourceforge.net/GraphXML.dtd

and put it in the directory: <wiki home>/images/hypergraph (you may need to create this) where $IP is the install path of your mediawiki. ensuring that the apache user (e.g. www-data or apache) has write access to the <wiki home>/images/hypergraph directory e.g.:

chown www-data:www-data $IP/images/hypergraph

NOTE: If upacking from the sourceforge packages: Hypergraph is a bit funny in that it has to be in the same directory as the output graph file which is <wiki home>/images/hypergraph so you need to move (or symbolic link) the two files hypergraph.jar & graph.dtd from "<wiki home>/extensions/SemanticGraph/libs" to the "<wiki home>/images/hypergraph" so that the generated graph and the applet files are all in the same place. Assuming you are running debian, and you have write access to the apache directory, the sequence of commands would be:

 mkdir <wiki home>/images/hypergraph
 chown www-data:www-data <wiki home>/images/hypergraph 
 cp <wiki home>/extensions/SemanticGraph/libs/hypergraph.jar <wiki home>/images/hypergraph
 cp <wiki home>/extensions/SemanticGraph/libs/GraphXML.dtd <wiki home>/images/hypergraph

Taking care to correctly substitute you wiki directory filepath for <wiki home> I think for other distros the apache username is different (www or apache)...

4) put the following line in your $IP/LocalSettings.php: require_once('<wiki home>/extensions/SemanticGraph/includes/SemanticGraph2.php');

5) relaxing mimetype checking and allowing mm files to be uploaded: see Manual:Configuring file uploads basically add the following to your LocalSettings.php: $wgFileExtensions[] = 'mm'; $wgVerifyMimeType = false;

Extra LocalSettings.php configuration[edit | edit source]

the extension defines the settings object $wgSemanticGraphSettings. There are a number of useful things you can change here by including the following lines in your LocalSettings.php e.g.:

        $wgSemanticGraphSettings->dotCommand = '/path/to/dot';       
        $wgSemanticGraphSettings->neatoCommand = '/path/to/neato';
        $wgSemanticGraphSettings->mmAppletPath = 'http://URL/to/freemind.jar';
        $wgSemanticGraphSettings->maxToDispUnfolded = 10; //when displaying a 
                // freemind map by default any branch with more than 10 items starts folded
                // this can be overridden by the fold=none|level1|level2|level3|large option

Those with MS operating systems will probably need to do something to these path variables

Usage[edit | edit source]

There are 4 parser functions provided by the extension. They are:

  • {{#smm:...}} - generated mindmap tree from semantic network, category tree or wiki links
  • {{#sgraph:...}} - generated dot network graph
  • {{#shypergraph:...}} - generated hypergraph graph
  • {{#mm2:...}} display an uploaded mind map with dynamic linking to the wiki.

All of them have similar syntax which can be displayed inline by doing e.g. {{#smm:help}} Tree functions generally require a single root resource to be specified, network graph functions can have a comma seperated list.

It should be possible to use the output of a {{#ask..}} query as the definition of a resource list for a graph if you specify the 'format=template' and 'link=none' option in the query.

Known Issues[edit | edit source]

  • colouring of the graphs is not yet implemented.
  • ideally the functions should be integrated with the semantic result formats. There are subtle differences though in that this will iteratively perform semantic network browsing, and this will also do non semantic (e.g. category and wiki link maps). Also this integrates functionally with semantic forms extensions
  • the querying is done quite inefficiently at the moment especially for semantic networks.
  • caching is not managed at all.
  • hypergraphing could only be done through a nasty hack using iframes as the applet does not like to be in a different directory from its data files. Clicking on hypergraph hyperlinks results in the target being opened in the iframe rather that the enclosing page, which is not ideal.

See also[edit | edit source]

  • Extension:GraphViz - the initial starting point for this. mostly rewritten for my specific purposes.
  • Extension:FreeMind - I reduced this to fit my very narrow needs. The flash browser does not seem to support opening links so I have stuck to the applet.
  • Extension:Semantic Result Formats - similar extension with better integration with the SMW query mechanism but fewer different graph types. Will try and move towards this in the future.
  • http://hypergraph.sourceforge.net/ the hypergraphing applet project, it seems to have been quiet for a while.