1Graph::Easy::Parser::GrUaspehrviCzo(n3t)ributed Perl DocGurmaepnht:a:tEiaosny::Parser::Graphviz(3)
2
3
4

NAME

6       Graph::Easy::Parser::Graphviz - Parse Graphviz text into Graph::Easy
7

SYNOPSIS

9               # creating a graph from a textual description
10
11               use Graph::Easy::Parser::Graphviz;
12               my $parser = Graph::Easy::Parser::Graphviz->new();
13
14               my $graph = $parser->from_text(
15                       "digraph MyGraph { \n" .
16                       "       Bonn -> \"Berlin\" \n }"
17               );
18               print $graph->as_ascii();
19
20               print $parser->from_file('mygraph.dot')->as_ascii();
21

DESCRIPTION

23       "Graph::Easy::Parser::Graphviz" parses the text format from the DOT
24       language use by Graphviz and constructs a "Graph::Easy" object from it.
25
26       The resulting object can than be used to layout and output the graph in
27       various formats.
28
29       Please see the Graphviz manual for a full description of the syntax
30       rules of the DOT language.
31
32   Output
33       The output will be a Graph::Easy object (unless overridden with
34       "use_class()"), see the documentation for Graph::Easy what you can do
35       with it.
36
37   Attributes
38       Attributes will be remapped to the proper Graph::Easy attribute names
39       and values, as much as possible.
40
41       Anything else will be converted to custom attributes starting with
42       "x-dot-".  So "ranksep: 2" will become "x-dot-ranksep: 2".
43

METHODS

45       "Graph::Easy::Parser::Graphviz" supports the same methods as its parent
46       class "Graph::Easy::Parser":
47
48   new()
49               use Graph::Easy::Parser::Graphviz;
50               my $parser = Graph::Easy::Parser::Graphviz->new();
51
52       Creates a new parser object. There are two valid parameters:
53
54               debug
55               fatal_errors
56
57       Both take either a false or a true value.
58
59               my $parser = Graph::Easy::Parser::Graphviz->new( debug => 1 );
60               $parser->from_text('digraph G { A -> B }');
61
62   reset()
63               $parser->reset();
64
65       Reset the status of the parser, clear errors etc. Automatically called
66       when you call any of the "from_XXX()" methods below.
67
68   use_class()
69               $parser->use_class('node', 'Graph::Easy::MyNode');
70
71       Override the class to be used to constructs objects while parsing.
72
73       See Graph::Easy::Parser for further information.
74
75   from_text()
76               my $graph = $parser->from_text( $text );
77
78       Create a Graph::Easy object from the textual description in $text.
79
80       Returns undef for error, you can find out what the error was with
81       error().
82
83       This method will reset any previous error, and thus the $parser object
84       can be re-used to parse different texts by just calling "from_text()"
85       multiple times.
86
87   from_file()
88               my $graph = $parser->from_file( $filename );
89               my $graph = Graph::Easy::Parser->from_file( $filename );
90
91       Creates a Graph::Easy object from the textual description in the file
92       $filename.
93
94       The second calling style will create a temporary parser object, parse
95       the file and return the resulting "Graph::Easy" object.
96
97       Returns undef for error, you can find out what the error was with
98       error() when using the first calling style.
99
100   error()
101               my $error = $parser->error();
102
103       Returns the last error, or the empty string if no error occurred.
104
105   parse_error()
106               $parser->parse_error( $msg_nr, @params);
107
108       Sets an error message from a message number and replaces embedded
109       templates like "##param1##" with the passed parameters.
110

CAVEATS

112       The parser has problems with the following things:
113
114       encoding and charset attribute
115                   The parser assumes the input to be "utf-8". Input files in
116                   <code>Latin1</code> are not parsed properly, even when they
117                   have the charset attribute set.
118
119       shape=record
120                   Nodes with shape record are only parsed properly when the
121                   label does not contain groups delimited by "{" and "}", so
122                   the following is parsed wrongly:
123
124                           node1 [ shape=record, label="A|{B|C}" ]
125
126       default shape
127                   The default shape for a node is 'rect', opposed to 'circle'
128                   as dot renders nodes.
129
130       attributes  Some attributes are not remapped properly to what
131                   Graph::Easy expects, thus losing information, either
132                   because Graph::Easy doesn't support this feature yet, or
133                   because the mapping is incomplete.
134
135                   Some attributes meant only for nodes or edges etc. might be
136                   incorrectly applied to other objects, resulting in unnec.
137                   warnings while parsing.
138
139                   Attributes not valid in the original DOT language are
140                   silently ignored by dot, but result in a warning when
141                   parsing under Graph::Easy. This helps catching all these
142                   pesky misspellings, but it's not yet possible to disable
143                   these warnings.
144
145       comments    Comments written in the source code itself are discarded.
146                   If you want to have comments on the graph, clusters, nodes
147                   or edges, use the attribute "comment".  These are correctly
148                   read in and stored, and then output into the different
149                   formats, too.
150

EXPORT

152       Exports nothing.
153

SEE ALSO

155       Graph::Easy, Graph::Reader::Dot.
156

AUTHOR

158       Copyright (C) 2005 - 2007 by Tels <http://bloodgate.com>
159
160       See the LICENSE file for information.
161
162
163
164perl v5.32.1                      2021-01-27  Graph::Easy::Parser::Graphviz(3)
Impressum