Graph:...r::VCG(3pm)
π Graph::Easy::Parser::VCG π
okay bestie, so this page lives in the User Contributed Perl Documentation section of your manual (you know, the 3pm girlies), and it's all about Graph::Easy::Parser::VCG. Let's get into it, no cap. π¦
β¨ NAME β¨
Graph::Easy::Parser::VCG β Parse VCG or GDL text into Graph::Easy
πΈ SYNOPSIS πΈ
# creating a graph from a textual description
use Graph::Easy::Parser::VCG;
my $parser = Graph::Easy::Parser::VCG->new();
my $graph = $parser->from_text(
"graph: { \n" .
" node: { title: "Bonn" }\n" .
" node: { title: "Berlin" }\n" .
" edge: { sourcename: "Bonn" targetname: "Berlin" }\n" .
"}\n"
);
print $graph->as_ascii();
print $parser->from_file('mygraph.vcg')->as_ascii();
π DESCRIPTION π
So Graph::Easy::Parser::VCG is the parser that reads the text format from VCG or GDL (that's Graph Description Language, periodt) β the same flavor of stuff tools like GCC and AiSee use β and it builds a Graph::Easy object out of it. Like, it literally takes that text and turns it into a whole graph object. β¨
And once you've got that object? You can layout it, and output the graph in all sorts of different formats. the way that works is genuinely iconic.
π Output
The output is gonna be a Graph::Easy object (unless you go and override it with use_class(), bestie), so go read the Graph::Easy docs to see everything you can do with it.
π Attributes
Attributes get remapped to the proper Graph::Easy attribute names and values, as much as possible. We try, okay?
Anything that doesn't get remapped? It becomes a custom attribute starting with x-vcg-. So dirty_edge_labels: yes turns into x-vcg-dirty_edge_labels: yes. Cute, right?
π METHODS π
Graph::Easy::Parser::VCG supports the exact same methods as its parent class Graph::Easy::Parser:
π new()
use Graph::Easy::Parser::VCG;
my $parser = Graph::Easy::Parser::VCG->new();
Creates a brand new parser object. There are two valid parameters:
debug
fatal_errors
Both of them take either a false or a true value. That's it, that's the whole menu.
my $parser = Graph::Easy::Parser::VCG->new( debug => 1 );
$parser->from_text('graph: { }');
π reset()
$parser->reset();
Resets the status of the parser, clears errors, etc. It gets called automatically whenever you call any of the from_XXX() methods below. so you never have to worry about it, she handles herself.
π use_class()
$parser->use_class('node', 'Graph::Easy::MyNode');
Override the class that gets used to construct objects while parsing. main character energy for your own custom classes.
See Graph::Easy::Parser for further information.
π from_text()
my $graph = $parser->from_text( $text );
Creates a Graph::Easy object from the textual description sitting in $text.
Returns undef on error β and you can find out what the error was with error().
This method resets any previous error, so the $parser object can totally be re-used to parse different texts by just calling from_text() multiple times. recycle, reuse, slay. β»οΈ
π from_file()
my $graph = $parser->from_file( $filename );
my $graph = Graph::Easy::Parser::VCG->from_file( $filename );
Creates a Graph::Easy object from the textual description in the file $filename.
The second calling style creates a temporary parser object, parses the file, and hands you back the resulting Graph::Easy object. no setup required, we love a shortcut.
Returns undef on error β you can find out what the error was with error() when you're using the first calling style.
π error()
my $error = $parser->error();
Returns the last error, or the empty string if nothing went wrong. π«Ά
π parse_error()
$parser->parse_error( $msg_nr, @params);
Sets an error message from a message number, and replaces embedded templates like ##param1## with the parameters you passed in. madlibs but make it errors.
π CAVEATS π
ngl, the parser has problems with the following things. listen up:
- attributes β Some attributes are not remapped properly to what
Graph::Easyexpects, so information gets lost. Either becauseGraph::Easydoesn't support that feature yet, or because the mapping is incomplete. it's giving incomplete, bestie. - comments β Comments written in the source code itself are discarded. If you want comments on the graph, clusters, nodes or edges, use the attribute
comment. Those get correctly read in and stored, and then output into the different formats too. so usecomment, not the sneaky source comments. π
π§ EXPORT π§
Exports nothing. empty hands, clean conscience.
π₯ SEE ALSO π₯
Graph::Easy, Graph::Write::VCG.
π AUTHOR π
Copyright (C) 2005 - 2008 by Tels <http://bloodgate.com>
See the LICENSE file for information.
and that's the whole page, bestie!! this was perl v5.36.0, dated 2022-11-20 β so yeah, it's a little vintage, but vintage is just iconic with a birthday, fr fr. go parse something cute πβ¨π
π¦ where this page comes from
- debian bookworm: libgraph-easy-perl 0.76-3 Β· GPL-2.0-or-later
- debian trixie: libgraph-easy-perl 0.76-3 Β· GPL-2.0-or-later
- ubuntu noble: libgraph-easy-perl 0.76-3 Β· GPL-2.0-or-later
- ubuntu resolute: libgraph-easy-perl 0.76-3 Β· GPL-2.0-or-later
- ubuntu stonking: libgraph-easy-perl 0.76-3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms