Class representing a graph; this may be a main graph but also a subgraph.

In case of a subgraph: When the name of the subgraph is prefixed with cluster then the contents of this graph will be grouped and a border will be added. Otherwise it is used as logical container to place defaults in.

category phpDocumentor
package GraphViz
author Mike van Riel
copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
license MIT
link http://phpdoc.org

 Methods

Magic method to provide a getter/setter to add attributes on the Graph.

__call(string $name, \mixed[] $arguments) : \phpDocumentor_GraphViz_Attribute[] | \phpDocumentor_GraphViz_Graph | null

Using this method we make sure that we support any attribute without too much hassle. If the name for this method does not start with get or set we return null.

Set methods return this graph (fluent interface) whilst get methods return the attribute value.

Parameters

$name

string

Name of the method including get/set

$arguments

\mixed[]

The arguments, should be 1: the value

Returns

Returns the requested node by its name.

__get(string $name) : \phpDocumentor_GraphViz_Node

see \phpDocumentor_GraphViz_Graph::setNode()

Parameters

$name

string

The name of the node to retrieve.

Returns

Sets a node using a custom name.

__set(string $name, \phpDocumentor_GraphViz_Node $value) : void

see \phpDocumentor_GraphViz_Graph::setNode()

Parameters

$name

string

Name of the node.

$value

\phpDocumentor_GraphViz_Node

Node to set on the given name.

Generates a DOT file for use with GraphViz.

__toString() : string

GraphViz is not used in this method; it is safe to call it even without GraphViz installed.

Returns

string

Adds a subgraph to this graph; automatically changes the type to subgraph.

addGraph(phpDocumentor_GraphViz_Graph $graph) : \phpDocumentor_GraphViz_Graph

Please note that an index is maintained using the name of the subgraph. Thus if you have 2 subgraphs with the same name that the first will be overwritten by the latter.

see \phpDocumentor_GraphViz_Graph::create()

Parameters

$graph

\phpDocumentor_GraphViz_Graph

The graph to add onto this graph as subgraph.

Returns

Factory method to instantiate a Graph so that you can use fluent coding to chain everything.

create(string $name, bool $directional) : \phpDocumentor_GraphViz_Graph

Parameters

$name

string

The name for this graph.

$directional

bool

Whether this is a directed or undirected graph.

Returns

Exports this graph to a generated image.

export(string $type, string $filename) : \phpDocumentor_GraphViz_Graph

This is the only method that actually requires GraphViz.

uses \GraphViz/dot
link http://www.graphviz.org/content/output-formats

Parameters

$type

string

The type to export to; see the link above for a list of supported types.

$filename

string

The path to write to.

Exceptions

\phpDocumentor_GraphViz_Exception if an error occurred in GraphViz.

Returns

Finds a node in this graph or any of its subgraphs.

findNode(string $name) : \phpDocumentor_GraphViz_Node

Parameters

$name

string

Name of the node to find.

Returns

Returns the subgraph with a given name.

getGraph(string $name) : \phpDocumentor_GraphViz_Graph

Parameters

$name

string

Name of the requested graph.

Returns

Returns the name for this Graph.

getName() : string

Returns

string

Returns the type of this Graph.

getType() : string

Returns

string

Checks whether a graph with a certain name already exists.

hasGraph(string $name) : bool

Parameters

$name

string

Name of the graph to find.

Returns

bool

Sets the name for this graph.

setName(string $name) : \phpDocumentor_GraphViz_Graph

If this is a subgraph you can prefix the name with cluster to group all contained nodes and add a border.

Parameters

$name

string

The new name for this graph.

Returns

Sets a node in the $nodes array; uses the name of the node as index.

setNode(phpDocumentor_GraphViz_Node $node) : \phpDocumentor_GraphViz_Graph

Nodes can be retrieved by retrieving the property with the same name. Thus 'node1' can be retrieved by invoking: $graph->node1

see \phpDocumentor_GraphViz_Node::create()

Parameters

$node

\phpDocumentor_GraphViz_Node

The node to set onto this Graph.

Returns

Sets the type for this graph.

setType(string $type) : \phpDocumentor_GraphViz_Graph

Parameters

$type

string

Must be either "digraph", "graph" or "subgraph".

Exceptions

\InvalidArgumentException if $type is not "digraph", "graph" or "subgraph".

Returns

 Properties

 

A list of attributes for this Graph

$attributes : \phpDocumentor_GraphViz_Attribute[]

 

A list of edges / arrows for this Graph

$edges : \phpDocumentor_GraphViz_Edge[]

 

A list of subgraphs for this Graph

$graphs : \phpDocumentor_GraphViz_Graph[]

 

Name of this graph

$name : string

 

A list of nodes for this Graph

$nodes : \phpDocumentor_GraphViz_Node[]

 

Type of this graph; may be digraph, graph or subgraph

$type : string