gv_php3
Graph manipulation in php
Usage
#!/usr/bin/php
<?
include('libgv-php5/gv.php');
?>
Usage
Introduction
gv_php is a dynamically loaded extension for php that provides access to the graph facilities of graphviz.
Commands
- New graphs
- New empty graph
-
graph_handle
gv::graph(name);
graph_handlegv::digraph(name);
graph_handlegv::strictgraph(name);
graph_handlegv::strictdigraph(name);
- New graph from a dot-syntax string or file
-
graph_handle
gv::readstring(string);
graph_handlegv::read(filename);
graph_handlegv::read(channel);
- Add new subgraph to existing graph
-
graph_handle
gv::graph(graph_handle, name);
- New nodes
- Add new node to existing graph
-
node_handle
gv::node(graph_handle, name);
- New edges
- Add new edge between existing nodes
-
edge_handle
gv::edge(tail_node_handle, head_node_handle);
- Add a new edge between an existing tail node, and a named head node which will be induced in the graph if it doesn't already exist
-
edge_handle
gv::edge(tail_node_handle, head_name);
- Add a new edge between an existing head node, and a named tail node which will be induced in the graph if it doesn't already exist
-
edge_handle
gv::edge(tail_name, head_node_handle);
- Add a new edge between named tail and head nodes which will be induced in the graph if they don't already exist
-
edge_handle
gv::edge(graph_handle, tail_name, head_name);
- Setting attribute values
- Set value of named attribute of graph/node/edge - creating attribute if necessary
-
string
gv::setv(graph_handle, attr_name, attr_value);
stringgv::setv(node_handle, attr_name, attr_value);
stringgv::setv(edge_handle, attr_name, attr_value);
- Set value of existing attribute of graph/node/edge (using attribute handle)
-
string
gv::setv(graph_handle, attr_handle, attr_value);
stringgv::setv(node_handle, attr_handle, attr_value);
stringgv::setv(edge_handle, attr_handle, attr_value);
- Getting attribute values
- Get value of named attribute of graph/node/edge
-
string
gv::getv(graph_handle, attr_name);
stringgv::getv(node_handle, attr_name);
stringgv::getv(edge_handle, attr_name);
- Get value of attribute of graph/node/edge (using attribute handle)
-
string
gv::getv(graph_handle, attr_handle);
stringgv::getv(node_handle, attr_handle);
stringgv::getv(edge_handle, attr_handle);
- Obtain names from handles
-
string
gv::nameof(graph_handle);
stringgv::nameof(node_handle);
stringgv::nameof(attr_handle);
- Find handles from names
-
graph_handle
gv::findsubg(graph_handle, name);
node_handlegv::findnode(graph_handle, name);
edge_handlegv::findedge(tail_node_handle, head_node_handle);
attribute_handlegv::findattr(graph_handle, name);
attribute_handlegv::findattr(node_handle, name);
attribute_handlegv::findattr(edge_handle, name);
- Misc graph navigators returning handles
-
node_handle
gv::headof(edge_handle);
node_handlegv::tailof(edge_handle);
graph_handlegv::graphof(graph_handle);
graph_handlegv::graphof(edge_handle);
graph_handlegv::graphof(node_handle);
graph_handlegv::rootof(graph_handle);
- Obtain handles of proto node/edge for setting default attribute values
-
node_handle
gv::protonode(graph_handle);
edge_handlegv::protoedge(graph_handle);
Iterators
- Iteration termination tests
-
bool
gv::ok(graph_handle);
boolgv::ok(node_handle);
boolgv::ok(edge_handle);
boolgv::ok(attr_handle);
- Iterate over subgraphs of a graph
-
graph_handle
gv::firstsubg(graph_handle);
graph_handlegv::nextsubg(graph_handle, subgraph_handle);
- Iterate over supergraphs of a graph (obscure and rarely useful)
-
graph_handle
gv::firstsupg(graph_handle);
graph_handlegv::nextsupg(graph_handle, subgraph_handle);
- Iterate over edges of a graph
-
edge_handle
gv::firstedge(graph_handle);
edge_handlegv::nextedge(graph_handle, edge_handle);
- Iterate over outedges of a graph
-
edge_handle
gv::firstout(graph_handle);
edge_handlegv::nextout(graph_handle, edge_handle);
- Iterate over edges of a node
-
edge_handle
gv::firstedge(node_handle);
edge_handlegv::nextedge(node_handle, edge_handle);
- Iterate over out-edges of a node
-
edge_handle
gv::firstout(node_handle);
edge_handlegv::nextout(node_handle, edge_handle);
- Iterate over head nodes reachable from out-edges of a node
-
node_handle
gv::firsthead(node_handle);
node_handlegv::nexthead(node_handle, head_node_handle);
- Iterate over in-edges of a graph
-
edge_handle
gv::firstin(graph_handle);
edge_handlegv::nextin(node_handle, edge_handle);
- Iterate over in-edges of a node
-
edge_handle
gv::firstin(node_handle);
edge_handlegv::nextin(graph_handle, edge_handle);
- Iterate over tail nodes reachable from in-edges of a node
-
node_handle
gv::firsttail(node_handle);
node_handlegv::nexttail(node_handle, tail_node_handle);
- Iterate over nodes of a graph
-
node_handle
gv::firstnode(graph_handle);
node_handlegv::nextnode(graph_handle, node_handle);
- Iterate over nodes of an edge
-
node_handle
gv::firstnode(edge_handle);
node_handlegv::nextnode(edge_handle, node_handle);
- Iterate over attributes of a graph
-
attribute_handle
gv::firstattr(graph_handle);
attribute_handlegv::nextattr(graph_handle, attr_handle);
- Iterate over attributes of an edge
-
attribute_handle
gv::firstattr(edge_handle);
attribute_handlegv::nextattr(edge_handle, attr_handle);
- Iterate over attributes of a node
-
attribute_handle
gv::firstattr(node_handle);
attribute_handlegv::nextattr(node_handle, attr_handle);
- Remove graph objects
-
bool
gv::rm(graph_handle);
boolgv::rm(node_handle);
boolgv::rm(edge_handle);
Layout
- Annotate a graph with layout attributes and values using a specific layout engine
-
bool
gv::layout(graph_handle, engine);
Render
- Render a layout into attributes of the graph
-
bool
gv::render(graph_handle);
- Render a layout in a specific format
-
bool
gv::render(graph_handle, format);
boolgv::render(graph_handle, format, filename);
boolgv::render(graph_handle, format, channel);
stringgv::renderdata(graph_handle, format);
- Writing graph back to file
-
bool
gv::write(graph_handle, filename);
boolgv::write(graph_handle, channel);
Keywords
graph, dot, neato, fdp, circo, twopi, php.