Graph:...raphviz(3pm)

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

πŸ’– Graph:...raphviz(3pm) β€” bestie edition πŸ’–

okay so this is the manual page for Graph:...raphviz(3pm) β€” aka the Perl doc for Graph::Easy::Parser::Graphviz, straight out of the User Contributed Perl Documentation collection. sit down, grab a boba, we're parsing DOT files together πŸ§‹βœ¨


🌸 NAME 🌸

Graph::Easy::Parser::Graphviz β€” no cap, it parses Graphviz text into Graph::Easy. that's the whole job. iconic.


✨ SYNOPSIS ✨

# 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 MyGraph { \n" .
        "       Bonn -> \"Berlin\" \n }"
);
print $graph->as_ascii();

print $parser->from_file('mygraph.dot')->as_ascii();

like… three lines and you have a graph. main character behavior fr fr πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So Graph::Easy::Parser::Graphviz reads the text format from the DOT language that Graphviz uses, and builds a Graph::Easy object out of it. literally its whole personality.

Once you've got that object? You can use it to layout and output the graph in alllll kinds of formats. the range. the versatility. we love to see it 🫢

If you want the full tea on the DOT language syntax rules, go read the Graphviz manual. it's all there, bestie.

πŸŽ€ Output πŸŽ€

What you get back is a Graph::Easy object β€” unless you've overridden it with use_class(). Then go read the Graph::Easy docs to find out all the cute things you can do with it. the possibilities?? endless ✨

πŸ“ Attributes πŸ“

Attributes get remapped to the proper Graph::Easy attribute names and values, as much as possible. we try our best πŸ’–

Anything else gets converted into custom attributes that start with x-dot-. so like, ranksep: 2 becomes x-dot-ranksep: 2. slay, prefixed and preserved.


πŸ‘‘ METHODS πŸ‘‘

Graph::Easy::Parser::Graphviz supports the same methods as its parent class Graph::Easy::Parser. so you already know the vibe.

πŸ’œ new()

use Graph::Easy::Parser::Graphviz;
my $parser = Graph::Easy::Parser::Graphviz->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. pick your fighter 🌈

my $parser = Graph::Easy::Parser::Graphviz->new( debug => 1 );
$parser->from_text('digraph G { A -> B }');

🌟 reset()

$parser->reset();

Resets the status of the parser, clears errors, etc. it's the factory-reset of parsers. this gets called automatically whenever you call any of the from_XXX() methods below, so you don't even gotta think about it 🧚

πŸ’… use_class()

$parser->use_class('node', 'Graph::Easy::MyNode');

Overrides the class used to construct objects while parsing. custom classes?? we love a glow-up.

See Graph::Easy::Parser for further info, bestie.

πŸ”₯ from_text()

my $graph = $parser->from_text( $text );

Creates a Graph::Easy object from the textual description in $text.

Returns undef for error β€” and you can find out what went wrong with error(). 😭

This method resets any previous error, which means your $parser object is fully re-usable. just call from_text() multiple times, it doesn't mind. lowkey the most chill method here.

🌈 from_file()

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.

The second calling style will create a temporary parser object, parse the file, and hand you back the resulting Graph::Easy object. one-and-done energy ✨

Returns undef for error, and 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. no drama, no error πŸŽ€

⭐ 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. fill-in-the-blank but make it errors.


πŸ™ˆ CAVEATS πŸ™ˆ

ngl, the parser has some problems with the following things. read this part, it matters:

  • encoding and charset attribute β€” The parser assumes the input is utf-8. Input files in <code>Latin1</code> are not parsed properly, even when they have the charset attribute set. so like… heads up.
  • shape=record β€” Nodes with shape record are only parsed properly when the label does not contain groups delimited by { and }, so the following gets parsed wrongly:
node1 [ shape=record, label="A|{B|C}" ]
  • default shape β€” The default shape for a node is 'rect', as opposed to 'circle' the way dot renders nodes. not the same vibe, sorry.
  • attributes β€” Some attributes are not remapped properly to what Graph::Easy expects, thus losing information β€” either because Graph::Easy doesn't support that feature yet, or because the mapping is incomplete.

Some attributes meant only for nodes or edges etc. might get incorrectly applied to other objects, resulting in unnecessary warnings while parsing. 😭

Attributes not valid in the original DOT language are silently ignored by dot, but result in a warning when parsing under Graph::Easy. This helps catch all those pesky misspellings, but it's not yet possible to disable these warnings. the warnings said "we're helping" and honestly they are.

  • 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 are correctly read in and stored, and then output into the different formats too. so use the attribute, bestie, not the source comment πŸ’–

🌸 EXPORT 🌸

Exports nothing. an empty bag. zero. nada. it's giving minimalist πŸŽ€


πŸ¦‹ SEE ALSO πŸ¦‹

  • Graph::Easy
  • Graph::Reader::Dot

πŸ‘‘ AUTHOR πŸ‘‘

Copyright (C) 2005 - 2007 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, filed under Graph:...raphviz(3pm) β€” you ate that read, periodt βœ¨πŸ«ΆπŸŽ€