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

Class: Image_GraphViz

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

Class Overview


Interface to AT&T's GraphViz tools.


Author(s):

Version:

  • Release: 1.3.0RC1

Copyright:

  • Copyright &copy; 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 109]
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 116]

Base path to GraphViz commands

Type:   string


[ Top ]

$dotCommand =  'dot'

[line 123]

Path to GraphViz/dot command

Type:   string


[ Top ]

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

[line 137]

Representation of the graph

Type:   array


[ Top ]

$neatoCommand =  'neato'

[line 130]

Path to GraphViz/neato command

Type:   string


[ Top ]



Method Detail

Image_GraphViz (Constructor)   [line 162]

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

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

[ Top ]

addAttributes   [line 460]

void addAttributes( array $attributes)

Add attributes to the graph.
  • Access: public

Parameters:

array   $attributes     Attributes to be added to the graph.

[ Top ]

addCluster   [line 318]

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

Add a cluster to the graph.
  • Access: public

Parameters:

string   $id     ID.
array   $title     Title.
array   $attributes     Attributes of the cluster.

[ Top ]

addEdge   [line 381]

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

Add 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   $ports     Start node => port, End node => port
array   $edge     Start => End node of the edge.
array   $attributes     Attributes of the edge.

[ Top ]

addNode   [line 334]

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

Add 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 ]

fetch   [line 228]

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

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

Parameters:

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

[ Top ]

image   [line 180]

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

Output image of the graph in a given format.
  • Access: public

Parameters:

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

[ Top ]

load   [line 582]

void load( string $file)

Load graph from file.
  • Access: public

Parameters:

string   $file     File to load graph from.

[ Top ]

parse   [line 649]

string parse( )

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

[ Top ]

removeEdge   [line 430]

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

Remove an edge from the graph.
  • Access: public

Parameters:

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

[ Top ]

removeNode   [line 349]

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

Remove a node from the graph.

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

  • Access: public

Parameters:

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

[ Top ]

renderDotFile   [line 278]

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

Render a given dot file into another format.
  • Return: True if the file was saved, false otherwise.
  • Access: public

Parameters:

string   $command     "dot" or "neato"
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.

[ Top ]

save   [line 625]

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

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

Parameters:

string   $file     File to save the graph to.

[ Top ]

saveParsedGraph   [line 762]

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

Save GraphViz markup to file.
  • Return: File to which the GraphViz markup was written, FALSE on failure.
  • Access: public

Parameters:

string   $file     File to write the GraphViz markup to.

[ Top ]

setAttributes   [line 478]

void setAttributes( array $attributes)

Set attributes of the graph.
  • Access: public

Parameters:

array   $attributes     Attributes to be set for the graph.

[ Top ]

setDirected   [line 567]

void setDirected( boolean $directed)

Set 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 526]

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 495]

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     

[ Top ]


Documentation generated on Mon, 19 Nov 2007 02:30:09 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.