Image_GraphViz
[ class tree: Image_GraphViz ] [ index: Image_GraphViz ] [ all elements ]

Class: Image_GraphViz

Source Location: /Image_GraphViz-1.3.0/Image/GraphViz.php

Class Overview


Interface to AT&T's GraphViz tools.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2001-2007 Dr. Volker Göbbels <vmg@arachnion.de> and Sebastian Bergmann <sb@sebastian-bergmann.de>

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 112]
Interface to AT&T's GraphViz tools.

The GraphViz class allows for the creation of and to work with directed and undirected graphs and their visualization with AT&T's GraphViz tools.

  1.  <?php
  2.  require_once 'Image/GraphViz.php';
  3.  
  4.  $graph = new Image_GraphViz();
  5.  
  6.  $graph->addNode(
  7.    'Node1',
  8.    array(
  9.      'URL'   => 'http://link1',
  10.      'label' => 'This is a label',
  11.      'shape' => 'box'
  12.    )
  13.  );
  14.  
  15.  $graph->addNode(
  16.    'Node2',
  17.    array(
  18.      'URL'      => 'http://link2',
  19.      'fontsize' => '14'
  20.    )
  21.  );
  22.  
  23.  $graph->addNode(
  24.    'Node3',
  25.    array(
  26.      'URL'      => 'http://link3',
  27.      'fontsize' => '20'
  28.    )
  29.  );
  30.  
  31.  $graph->addEdge(
  32.    array(
  33.      'Node1' => 'Node2'
  34.    ),
  35.    array(
  36.      'label' => 'Edge Label'
  37.    )
  38.  );
  39.  
  40.  $graph->addEdge(
  41.    array(
  42.      'Node1' => 'Node2'
  43.    ),
  44.    array(
  45.      'color' => 'red'
  46.    )
  47.  );
  48.  
  49.  $graph->image();
  50.  ?>



[ Top ]


Class Variables

$binPath =  ''

[line 119]

Base path to GraphViz commands

Type:   string


[ Top ]

$dotCommand =  'dot'

[line 126]

Path to GraphViz/dot command

Type:   string


[ Top ]

$graph = array('edgesFrom'  => array(),'nodes'=>array(),'attributes'=>array(),'directed'=>true,'clusters'=>array(),'subgraphs'=>array(),'name'=>'G','strict'=>true,)

[line 140]

Representation of the graph

Type:   array


[ Top ]

$neatoCommand =  'neato'

[line 133]

Path to GraphViz/neato command

Type:   string


[ Top ]

$_returnFalseOnError =  true

[line 156]

Whether to return PEAR_Error instance on failures instead of FALSE
  • Access: protected

Type:   boolean


[ Top ]



Method Detail

Image_GraphViz (Constructor)   [line 178]

Image_GraphViz Image_GraphViz( [boolean $directed = true], [array $attributes = array()], [string $name = 'G'], [boolean $strict = true], [boolean $returnError = false])

Constructor.

Setting the name of the Graph is useful for including multiple image maps on one page. If not set, the graph will be named 'G'.

  • Access: public

Parameters:

boolean   $directed     Directed (TRUE) or undirected (FALSE) graph. Note: You MUST pass a boolean, and not just an expression that evaluates to TRUE or FALSE (i.e. NULL, empty string, 0 will NOT work)
array   $attributes     Attributes of the graph
string   $name     Name of the Graph
boolean   $strict     Whether to collapse multiple edges between same nodes
boolean   $returnError     Set to TRUE to return PEAR_Error instances on failures instead of FALSE

[ Top ]

addAttributes   [line 558]

void addAttributes( array $attributes)

Adds attributes to the graph.
  • Access: public

Parameters:

array   $attributes     Attributes to be added to the graph.

[ Top ]

addCluster   [line 398]

void addCluster( string $id, array $title, [array $attributes = array()], [string $group = 'default'])

Adds a cluster to the graph.

A cluster is a subgraph with a rectangle around it.


Parameters:

string   $id     ID.
array   $title     Title.
array   $attributes     Attributes of the cluster.
string   $group     ID of group to nest cluster into

[ Top ]

addEdge   [line 481]

integer addEdge( array $edge, [array $attributes = array()], [array $ports = array()])

Adds an edge to the graph.

Examples:

  1.  $g->addEdge(array('node1' => 'node2'));
  2.  $attr = array(
  3.      'label' => '+1',
  4.      'style' => 'dashed',
  5.  );
  6.  $g->addEdge(array('node3' => 'node4')$attr);
  7.  
  8.  // With port specification
  9.  $g->addEdge(array('node5' => 'node6')$attrarray('node6' => 'portA'));
  10.  $g->addEdge(array('node7' => 'node8')nullarray('node7' => 'portC',
  11.                                                     'node8' => 'portD'));

  • Return: an edge ID that can be used with removeEdge()
  • Access: public

Parameters:

array   $edge     Start => End node of the edge.
array   $attributes     Attributes of the edge.
array   $ports     Start node => port, End node => port

[ Top ]

addNode   [line 433]

void addNode( string $name, [array $attributes = array()], [string $group = 'default'])

Adds a note to the graph.
  • Access: public

Parameters:

string   $name     Name of the node.
array   $attributes     Attributes of the node.
string   $group     Group of the node.

[ Top ]

addSubgraph   [line 416]

void addSubgraph( string $id, array $title, [array $attributes = array()], [string $group = 'default'])

Adds a subgraph to the graph.
  • Access: public

Parameters:

string   $id     ID.
array   $title     Title.
array   $attributes     Attributes of the cluster.
string   $group     ID of group to nest subgraph into

[ Top ]

fetch   [line 294]

string fetch( [string $format = 'svg'], [string $command = null])

Returns image (data) of the graph in a given format.
  • Return: The image (data) created by GraphViz, FALSE or PEAR_Error on error
  • Since: Method available since Release 1.1.0
  • Access: public

Parameters:

string   $format     Format of the output image. This may be one of the formats supported by GraphViz.
string   $command     "dot" or "neato"

[ Top ]

image   [line 201]

boolean image( [string $format = 'svg'], [string $command = null])

Outputs image of the graph in a given format

This methods send HTTP headers

  • Return: TRUE on success, FALSE or PEAR_Error otherwise
  • Access: public

Parameters:

string   $format     Format of the output image. This may be one of the formats supported by GraphViz.
string   $command     "dot" or "neato"

[ Top ]

load   [line 677]

void load( string $file)

Loads a graph from a file in Image_GraphViz format
  • Access: public

Parameters:

string   $file     File to load graph from.

[ Top ]

parse   [line 820]

string parse( )

Parses the graph into GraphViz markup.
  • Return: GraphViz markup
  • Access: public

[ Top ]

removeEdge   [line 528]

void removeEdge( array $edge, [integer $id = null])

Removes an edge from the graph.
  • Access: public

Parameters:

array   $edge     Start and End node of the edge to be removed.
integer   $id     specific edge ID (only usefull when multiple edges exist between the same 2 nodes)

[ Top ]

removeNode   [line 449]

void removeNode( string $name, [string $group = 'default'])

Removes a node from the graph.

This method doesn't remove edges associated with the node.

  • Access: public

Parameters:

string   $name     Name of the node to be removed.
string   $group     Group of the node.

[ Top ]

renderDotFile   [line 341]

boolean renderDotFile( string $dotfile, string $outputfile, [string $format = 'svg'], [string $command = null])

Renders a given dot file into a given format.
  • Return: TRUE if the file was saved, FALSE or PEAR_Error otherwise.
  • Access: public

Parameters:

string   $dotfile     The absolute path of the dot file to use.
string   $outputfile     The absolute path of the file to save to.
string   $format     Format of the output image. This may be one of the formats supported by GraphViz.
string   $command     "dot" or "neato"

[ Top ]

save   [line 726]

string save( [string $file = ''])

Save graph to file in Image_GraphViz format

This saves the serialized version of the instance, not the rendered graph.

  • Return: File the graph was saved to, FALSE or PEAR_Error on failure.
  • Access: public

Parameters:

string   $file     File to save the graph to.

[ Top ]

saveParsedGraph   [line 999]

string saveParsedGraph( [string $file = ''])

Saves GraphViz markup to file (in DOT language)
  • Return: File to which the GraphViz markup was written, FALSE or or PEAR_Error on failure.
  • Access: public

Parameters:

string   $file     File to write the GraphViz markup to.

[ Top ]

setAttributes   [line 573]

void setAttributes( array $attributes)

Sets attributes of the graph.
  • Access: public

Parameters:

array   $attributes     Attributes to be set for the graph.

[ Top ]

setDirected   [line 662]

void setDirected( boolean $directed)

Sets directed/undirected flag for the graph.

Note: You MUST pass a boolean, and not just an expression that evaluates to TRUE or FALSE (i.e. NULL, empty string, 0 will not work)

  • Access: public

Parameters:

boolean   $directed     Directed (TRUE) or undirected (FALSE) graph.

[ Top ]

_escape   [line 621]

string _escape( string $input, [boolean $html = false])

Returns a safe "ID" in DOT syntax
  • Access: protected

Parameters:

string   $input     string to use as "ID"
boolean   $html     whether to attempt detecting HTML-like content

[ Top ]

_escapeArray   [line 590]

array _escapeArray( array $input)

Escapes an (attribute) array

Detects if an attribute is <html>, contains double-quotes, etc...

  • Return: input escaped
  • Access: protected

Parameters:

array   $input     input to escape

[ Top ]

_getGroups   [line 778]

array _getGroups( )

Returns a list of cluster/subgraph IDs
  • Access: protected

[ Top ]

_getSubgraphs   [line 756]

array _getSubgraphs( string $parent)

Returns a list of sub-groups for a given parent group
  • Return: list of group IDs
  • Access: protected

Parameters:

string   $parent     Group ID

[ Top ]

_getTopGraphs   [line 791]

array _getTopGraphs( )

Returns a list of top groups
  • Access: protected

[ Top ]

_nodes   [line 906]

string _nodes( array $nodes, string $indent)

Output nodes
  • Return: output
  • Access: protected

Parameters:

array   $nodes     nodes list
string   $indent     space indentation

[ Top ]

_subgraph   [line 933]

string _subgraph( $group, &$indent)

Generates output for a group
  • Return: output
  • Access: protected

Parameters:

   $group     
   &$indent     

[ Top ]


Documentation generated on Sun, 24 Oct 2010 06:30:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.