* * Rending a graph to an image will only work if you have the * GraphViz 'dot' command installed. * * @package EasyRdf * @copyright Copyright (c) 2012-2013 Nicholas J Humfrey * @license http://unlicense.org/ */ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/'); require_once "EasyRdf.php"; require_once "html_tag_helpers.php"; $formats = array('PNG' => 'png', 'GIF' => 'gif', 'SVG' => 'svg'); $format = EasyRdf_Format::getFormat(isset($_REQUEST['format']) ? $_REQUEST['format'] : 'png'); // Construct a graph of three people $graph = new EasyRdf_Graph(); $graph->set('foaf:knows', 'rdfs:label', 'knows'); $bob = $graph->resource('http://www.example.com/bob', 'foaf:Person'); $alice = $graph->resource('http://www.example.com/alice', 'foaf:Person'); $carol = $graph->resource('http://www.example.com/carol', 'foaf:Person'); $bob->set('foaf:name', 'Bob'); $alice->set('foaf:name', 'Alice'); $carol->set('foaf:name', 'Carol'); $bob->add('foaf:knows', $alice); $bob->add('foaf:knows', $carol); $alice->add('foaf:knows', $bob); $alice->add('foaf:knows', $carol); // Create a GraphViz serialiser $gv = new EasyRdf_Serialiser_GraphViz(); $gv->setUseLabels(isset($_REQUEST['ul'])); $gv->setOnlyLabelled(isset($_REQUEST['ol'])); // If this is a request for the image, just render it and exit