Graph:...r::VCG(3pm)

πŸ“¦
version 0.76 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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::Easy expects, so information gets lost. Either because Graph::Easy doesn'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 use comment, 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 πŸ’–βœ¨πŸŽ€