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

Class: Image_GraphViz

Source Location: /Image_GraphViz-1.1.0/GraphViz.php

Class Overview


Interface to AT&T's GraphViz tools.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 88]
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 94]

Path to GraphViz/dot command

Type:   string


[ Top ]

$graph =

[line 108]

Representation of the graph

Type:   array


[ Top ]

$neatoCommand =  'neato'

[line 101]

Path to GraphViz/neato command

Type:   string


[ Top ]



Method Detail

Image_GraphViz (Constructor)   [line 121]

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

void addAttributes( array $attributes)

Add attributes to the graph.
  • Access: public

Parameters:

array   $attributes   —  Attributes to be added to the graph.

[ Top ]

addCluster   [line 214]

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

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

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

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

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

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

void load( string $file)

Load graph from file.
  • Access: public

Parameters:

string   $file   —  File to load graph from.

[ Top ]

parse   [line 386]

string parse( )

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

[ Top ]

removeEdge   [line 289]

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

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

Remove a node from the graph.
  • Access: public

Parameters:

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

[ Top ]

save   [line 363]

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

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

void setAttributes( array $attributes)

Set attributes of the graph.
  • Access: public

Parameters:

array   $attributes   —  Attributes to be set for the graph.

[ Top ]

setDirected   [line 338]

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 Mon, 11 Mar 2019 14:14:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.