summaryrefslogtreecommitdiffstats
path: root/src/lib/eina_graph.c
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-01-10 11:02:14 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-01-10 11:02:14 +0100
commitfb3483672193c2fc360d3c6e450dc051541556e5 (patch)
treee800e5621fb4bb18f162146796d565570bd00432 /src/lib/eina_graph.c
parent5e8e882c7092feaaf4a56506dbda611ed7755d28 (diff)
downloadeina_graph-fb3483672193c2fc360d3c6e450dc051541556e5.zip
eina_graph-fb3483672193c2fc360d3c6e450dc051541556e5.tar.gz
add eina_graph_dot_write()
Diffstat (limited to 'src/lib/eina_graph.c')
-rw-r--r--src/lib/eina_graph.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/eina_graph.c b/src/lib/eina_graph.c
index 4cea67f..e3bf209 100644
--- a/src/lib/eina_graph.c
+++ b/src/lib/eina_graph.c
@@ -159,3 +159,28 @@ eina_graph_edge_add(Eina_Graph *g, unsigned int v, unsigned int w)
return EINA_TRUE;
}
+
+EAPI void
+eina_graph_dot_write(Eina_Graph *g, FILE *f)
+{
+ int r;
+ char buf[32];
+ unsigned int i, j, n;
+ Eina_Array *ar;
+ _Eina_Graph * _g = (_Eina_Graph *) g;
+
+ fwrite("digraph {\n", 10, 1, f);
+
+ for (i = 0; i< _g->vertices; i++)
+ {
+ ar = _g->adjs[i];
+ n = eina_array_count_get(ar);
+ for (j = 0; j < n; j++)
+ {
+ r = snprintf(buf, 32, "%u -> %u;\n", i, eina_array_uint_nth_get(ar, j));
+ fwrite(buf, r, 1, f);
+ }
+ }
+
+ fwrite("}\n", 2, 1, f);
+}