class GraphViz extends Serialiser

Class to serialise an EasyRdf\Graph to GraphViz

Depends upon the GraphViz 'dot' command line tools to render images.

See http://www.graphviz.org/ for more information.

Properties

protected $prefixes from  Serialiser

Methods

addPrefix($qname)

Keep track of the prefixes used while serialising

checkSerialiseParams($format)

Check and cleanup parameters passed to serialise() method

reversePropertyCount($resource)

Protected method to get the number of reverse properties for a resource If a resource only has a single property, the number of values for that property is returned instead.

string
serialise(Graph $graph, Format|string $format, array $options = array())

Serialise an EasyRdf\Graph into a GraphViz dot document.

setDotCommand(string $cmd)

Set the path to the GraphViz 'dot' command

string
getDotCommand()

Get the path to the GraphViz 'dot' command

GraphViz
setUseLabels(bool $useLabels)

Turn on/off the option to display labels instead of URIs.

bool
getUseLabels()

Get the state of the use labels option

GraphViz
setOnlyLabelled(bool $onlyLabelled)

Turn on/off the option to only display nodes and edges with labels

bool
getOnlyLabelled()

Get the state of the only Only Labelled option

GraphViz
setAttribute(string $name, string $value)

Set an attribute on the GraphViz graph

string
getAttribute(string $name)

Get an attribute of the GraphViz graph

nodeName($entity)

Convert an EasyRdf object into a GraphViz node identifier

escape($input)

Internal function to escape a string into DOT safe syntax

escapeAttributes($array)

Internal function to escape an associate array of attributes and turns it into a DOT notation string

serialiseRow($node1, $node2 = null, $attributes = array())

Internal function to create dot syntax line for either a node or an edge

serialiseDot(Graph $graph)

Internal function to serialise an EasyRdf\Graph into a DOT formatted string

renderImage(Graph $graph, $format = 'png')

Internal function to render a graph into an image

Details

in Serialiser at line 54
protected addPrefix($qname)

Keep track of the prefixes used while serialising

Parameters

$qname

in Serialiser at line 64
protected checkSerialiseParams($format)

Check and cleanup parameters passed to serialise() method

Parameters

$format

in Serialiser at line 85
protected reversePropertyCount($resource)

Protected method to get the number of reverse properties for a resource If a resource only has a single property, the number of values for that property is returned instead.

Parameters

$resource

at line 379
string serialise(Graph $graph, Format|string $format, array $options = array())

Serialise an EasyRdf\Graph into a GraphViz dot document.

Supported output format names: dot, gif, png, svg

Parameters

Graph $graph An EasyRdf\Graph object.
Format|string $format The name of the format to convert to.
array $options

Return Value

string

Exceptions

Exception

at line 72
GraphViz setDotCommand(string $cmd)

Set the path to the GraphViz 'dot' command

Default is to search PATH for the command 'dot'.

Parameters

string $cmd The path to the 'dot' command.

Return Value

GraphViz

at line 85
string getDotCommand()

Get the path to the GraphViz 'dot' command

The default value is simply 'dot'

Return Value

string

at line 104
GraphViz setUseLabels(bool $useLabels)

Turn on/off the option to display labels instead of URIs.

When this option is turned on, then labels for resources will be displayed instead of the full URI of a resource. This makes it simpler to create friendly diagrams that non-technical people can understand.

This option is turned off by default.

Parameters

bool $useLabels A boolean value to turn labels on and off

Return Value

GraphViz

at line 115
bool getUseLabels()

Get the state of the use labels option

Return Value

bool

at line 134
GraphViz setOnlyLabelled(bool $onlyLabelled)

Turn on/off the option to only display nodes and edges with labels

When this option is turned on, then only nodes (resources and literals) and edges (properties) will only be displayed if they have a label. You can use this option, to create concise, diagrams of your data, rather than the RDF.

This option is turned off by default.

Parameters

bool $onlyLabelled A boolean value to enable/display only labelled items

Return Value

GraphViz

at line 145
bool getOnlyLabelled()

Get the state of the only Only Labelled option

Return Value

bool

at line 164
GraphViz setAttribute(string $name, string $value)

Set an attribute on the GraphViz graph

Example: $serialiser->setAttribute('rotate', 90);

See the GraphViz tool documentation for information about the available attributes.

Parameters

string $name The name of the attribute
string $value The value for the attribute

Return Value

GraphViz

at line 177
string getAttribute(string $name)

Get an attribute of the GraphViz graph

Parameters

string $name Attribute name

Return Value

string

at line 187
protected nodeName($entity)

Convert an EasyRdf object into a GraphViz node identifier

Parameters

$entity

at line 205
protected escape($input)

Internal function to escape a string into DOT safe syntax

Parameters

$input

at line 224
protected escapeAttributes($array)

Internal function to escape an associate array of attributes and turns it into a DOT notation string

Parameters

$array

at line 238
protected serialiseRow($node1, $node2 = null, $attributes = array())

Internal function to create dot syntax line for either a node or an edge

Parameters

$node1
$node2
$attributes

at line 255
protected serialiseDot(Graph $graph)

Internal function to serialise an EasyRdf\Graph into a DOT formatted string

Parameters

Graph $graph

at line 355
renderImage(Graph $graph, $format = 'png')

Internal function to render a graph into an image

Parameters

Graph $graph
$format