4 * Copyright (C) 2009 Martin Olsson
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Martin Olsson <martin@minimum.se>
24 [CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "graphviz/gvc.h")]
28 * Low-level initialization function for the graphviz library, used only if
29 * you need to explicitly control the sizes of graph, node and edge objects.
31 * Note: It's not necessary to call initlib() if you already called aginit()
32 * because aginit() makes a call to aginitlib() internally.
34 [CCode (cname = "aginitlib", cheader_filename="gvc.h")]
35 public void initlib ( size_t graphinfo, size_t nodeinfo, size_t edgeinfo);
38 * You must call aginit() before using the graphviz API. However, note that
39 * both gvContext() and gvParseArgs() will call aginit() internally if necessary.
40 * It's safe to call aginit() multiple times.
42 * For more information of Graphviz initialization, see documention at:
43 * http://graphviz.org/pdf/libguide.pdf
45 [CCode (cname = "aginit")]
48 [CCode (cprefix = "")]
49 public enum GraphKind {
57 [CCode (cname = "agerrlevel_t", cheader_filename = "gvc.h", cprefix = "")]
58 public enum ErrorLevel {
66 [CCode (cname = "GVC_t", free_function = "gvFreeContext")]
67 public class Context {
68 [CCode (cname = "gvContext")]
71 [CCode (cname = "gvParseArgs")]
72 public int parse_args ( [CCode (array_length_pos = 0.9)] string[] argv );
74 [CCode (cname = "gvLayout")]
75 public int layout (Graph graph, [CCode (type = "char*")] string layout_engine);
77 [CCode (cname = "gvFreeLayout")]
78 public int free_layout (Graph graph);
80 [CCode (cname = "gvRender")]
81 public int render (Graph graph, [CCode (type = "char*")] string file_type, GLib.FileStream? file);
83 [CCode (cname = "gvRenderFilename")]
84 public int render_filename (Graph graph, [CCode (type = "char*")] string file_type, [CCode (type = "char*")] string filename);
86 [CCode (cname = "gvLayoutJobs")]
87 public int layout_jobs (Graph graph);
89 [CCode (cname = "gvRenderJobs")]
90 public int render_jobs (Graph graph);
92 [CCode (cname = "gvRenderData")]
93 public int render_data (Graph graph, [CCode (type = "char*")] string file_type, [CCode (type = "char**")] out uint8[] output_data);
97 [CCode (cname = "Agnode_t", ref_function = "", unref_function = "", free_function = "")]
99 [CCode (cname = "name")]
102 [CCode (cname = "agget")]
103 public unowned string? get ([CCode (type = "char*")] string attribute_name);
105 [CCode (cname = "agset")]
106 public void set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value);
108 [CCode (cname = "agsafeset")]
109 public void safe_set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value, [CCode (type = "char*")] string? default_value);
113 [CCode (cname = "Agedge_t", ref_function = "", unref_function = "", free_function = "")]
115 [CCode (cname = "agget")]
116 public unowned string? get ([CCode (type = "char*")] string attribute_name);
118 [CCode (cname = "agset")]
119 public int set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value);
121 [CCode (cname = "agsafeset")]
122 public int safe_set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value, [CCode (type = "char*")] string? default_value);
126 [CCode (cname = "Agraph_t", free_function = "agclose")]
128 [CCode (cname = "agopen")]
129 public Graph ([CCode (type = "char*")] string graph_name, GraphKind kind);
131 [CCode (cname = "agread")]
132 public static Graph read (GLib.FileStream file);
134 [CCode (cname = "agmemread")]
135 public static Graph read_string (string str);
137 [CCode (cname = "agnode")]
138 public Node create_node ([CCode (type = "char*")] string node_name);
140 [CCode (cname = "agedge")]
141 public Edge create_edge (Node from, Node to);
143 /** Note: name set to "null" creates an anonymous subgraph. */
144 [CCode (cname = "agsubg")]
145 public unowned Graph create_subgraph ([CCode (type = "char*")] string? name);
147 [CCode (cname = "agfindsubg")]
148 public Graph find_subgraph ([CCode (type = "char*")] string name);
150 [CCode (cname = "agidsubg")]
151 public Graph create_subgraph_id (ulong id);
153 [CCode (cname = "agfstsubg")]
154 public Graph get_first_subgraph ();
156 [CCode (cname = "agnxtsubg")]
157 public Graph get_next_subgraph ();
159 [CCode (cname = "agparent")]
160 public Graph get_parent_graph ();
162 /** Note: agclose() is also allowed for subgraphs and has the same effect as agdelsubg(). */
163 [CCode (cname = "agdelsubg")]
164 public int delete_subgraph (Graph subgraph);
166 [CCode (cname = "agfindnode")]
167 public Node? find_node ([CCode (type = "char*")] string node_name);
169 [CCode (cname = "agfstnode")]
170 public Node? get_first_node ();
172 [CCode (cname = "agnxtnode")]
173 public Node? get_next_node (Node node);
175 [CCode (cname = "agget")]
176 public unowned string? get ([CCode (type = "char*")] string attribute_name);
178 [CCode (cname = "agset")]
179 public int set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value);
181 [CCode (cname = "agsafeset")]
182 public int safe_set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value, [CCode (type = "char*")] string? default_value);
184 [CCode (cname = "AG_IS_DIRECTED")]
185 public bool is_directed ();
187 [CCode (cname = "AG_IS_STRICT")]
188 public bool is_strict ();
193 * Graphviz has this concept of "referenced counted strings" to save memory.
194 * In addition, there is a special type of string in Graphviz called an "HTML string".
195 * More information about graphviz "HTML strings" can be found at:
196 * http://www.graphviz.org/doc/info/shapes.html#html
197 * And also near the end of page 9 in: http://graphviz.org/pdf/libguide.pdf
199 [CCode (cname = "char", copy_function = "agdupstr_html", free_function = "agstrfree")]
200 public class HtmlString : string {
201 [CCode (cname = "agstrdup_html")]
202 public HtmlString (string markup);
205 [CCode(cprefix = "ag")]
207 [CCode (cname = "agerrno")]
208 public static ErrorLevel errno;
210 [CCode (cname = "agerr")]
211 public static int error (ErrorLevel level, string fmt, ...);
213 [CCode (cname = "agerrors")]
214 public static int errors ();
216 [CCode (cname = "agseterr")]
217 public static void set_error (ErrorLevel err);
219 [CCode (cname = "aglasterr")]
220 public static string? last_error ();
222 [CCode (cname = "agerrorf")]
223 public static void errorf (string format, ...);
225 [CCode (cname = "agwarningf")]
226 void warningf (string fmt, ...);