Graph::Easy::Parser::Graphviz - Parse graphviz text into Graph::Easy
# creating a graph from a textual description use Graph::Easy::Parser::Graphviz; my $parser = Graph::Easy::Parser::Graphviz->new(); my $graph = $parser->from_text( "digraph Graph {\" . ' Bonn -> "Berlin"' . "\n}\n" ); ); print $graph->as_ascii(); print $parser->from_file('mygraph.dot')->as_ascii();
Graph::Easy::Parser::Graphviz parses the text format from graphviz and constructs a Graph::Easy object from it.
Graph::Easy::Parser::Graphviz
Graph::Easy
The resulting object can than be used to layout and output the graph.
Please see the Grapviz manual for a full description of the syntax rules.
The output will be a Graph::Easy object (unless overrriden with use_class()), see the documentation for Graph::Easy what you can do with it.
use_class()
Graph::Easy::Parser::Graphviz supports the same methods that its parent class Graph::Easy::Parser:
Graph::Easy::Parser
use Graph::Easy::Parser::Graphviz; my $parser = Graph::Easy::Parser::Graphviz->new();
Creates a new parser object. The only valid parameter is debug, when set to true it will enable debug output to STDERR:
my $parser = Graph::Easy::Parser::Graphviz->new( debug => 1 ); $parser->from_text('digraph G { A -> B }');
$parser->reset();
Reset the status of the parser, clear errors etc. Automatically called when you call any of the from_XXX() methods below.
from_XXX()
$parser->use_class('node', 'Graph::Easy::MyNode');
Override the class to be used to constructs objects while parsing.
See Graph::Easy::Parser for further information.
my $graph = $parser->from_text( $text );
Create a Graph::Easy object from the textual description in $text.
$text
Returns undef for error, you can find out what the error was with error().
This method will reset any previous error, and thus the $parser object can be re-used to parse different texts by just calling from_text() multiple times.
$parser
from_text()
my $graph = $parser->from_file( $filename ); my $graph = Graph::Easy::Parser->from_file( $filename );
Creates a Graph::Easy object from the textual description in the file $filename.
$filename
The second calling style will create a temporary parser object, parse the file and return the resulting Graph::Easy object.
Returns undef for error, you can find out what the error was with error() when using the first calling style.
my $error = $parser->error();
Returns the last error, or the empty string if no error occured.
$parser->parse_error( $msg_nr, @params);
Sets an error message from a message number and replaces embedded templates like ##param1## with the passed parameters.
##param1##
Exports nothing.
Graph::Easy.
Copyright (C) 2005 - 2006 by Tels http://bloodgate.com
See the LICENSE file for information.
To install Graph::Easy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::Easy
CPAN shell
perl -MCPAN -e shell install Graph::Easy
For more information on module installation, please visit the detailed CPAN module installation guide.