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

Class: Image_GraphViz

Source Location: /Image_GraphViz-1.2.0/GraphViz.php

Class Overview


Interface to AT&T's GraphViz tools.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • Copyright &copy; 2001-2006 Dr. Volker Göbbels <vmg@arachnion.de> and Sebastian Bergmann <sb@sebastian-bergmann.de>

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

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

The GraphViz class allows for the creation of and the 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

$dotCommand =  'dot'

[line 109]

Path to GraphViz/dot command

Type:   string


[ Top ]

$graph =

[line 123]

Representation of the graph

Type:   array


[ Top ]

$neatoCommand =  'neato'

[line 116]

Path to GraphViz/neato command

Type:   string


[ Top ]



Method Detail

Image_GraphViz (Constructor)   [line 136]

Image_GraphViz Image_GraphViz( [boolean $directed = TRUE], [array $attributes = array()], [string $name = NULL])

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.
array   $attributes     Attributes of the graph
string   $name     Name of the Graph

[ Top ]

addAttributes   [line 363]

void addAttributes( array $attributes)

Add attributes to the graph.
  • Access: public

Parameters:

array   $attributes     Attributes to be added to the graph.

[ Top ]

addCluster   [line 261]

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

void addEdge( array $edge, [array $attributes = array()])

Add an edge to the graph.

Caveat! This cannot handle multiple identical edges. If you use non-numeric IDs for the nodes, this will not do (too much) harm. For numeric IDs the array_merge() that is used will change the keys when merging arrays, leading to new nodes appearing in the graph.

  • Access: public

Parameters:

array   $edge     Start and End node of the edge.
array   $attributes     Attributes of the edge.

[ Top ]

addNode   [line 275]

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

string fetch( [string $format = 'svg'])

Return image (data) of the graph in a given format.
  • Return: The image (data) created by GraphViz.
  • 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.

[ Top ]

image   [line 150]

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

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

Parameters:

string   $format     Format of the output image. This may be one of the formats supported by GraphViz.

[ Top ]

load   [line 405]

void load( string $file)

Load graph from file.
  • Access: public

Parameters:

string   $file     File to load graph from.

[ Top ]

parse   [line 443]

string parse( )

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

[ Top ]

removeEdge   [line 340]

void removeEdge( array $edge)

Remove an edge from the graph.
  • Access: public

Parameters:

array   $edge     Start and End node of the edge to be removed.

[ Top ]

removeNode   [line 286]

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

Remove a node from the graph.
  • Access: public

Parameters:

Name   $name     of the node to be removed.

[ Top ]

renderDotFile   [line 234]

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

Render a given dot file into another format.
  • Return: True if the file was saved, false 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.

[ Top ]

save   [line 419]

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

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

void setAttributes( array $attributes)

Set attributes of the graph.
  • Access: public

Parameters:

array   $attributes     Attributes to be set for the graph.

[ Top ]

setDirected   [line 392]

void setDirected( boolean $directed)

Set directed/undirected flag for the graph.
  • Access: public

Parameters:

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

[ Top ]


Documentation generated on Thu, 11 May 2006 04:33:40 -0400 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.