/* gcc gegl-destroy-graph.c $(pkg-config --cflags --libs gegl-0.3) */

#include <gegl.h>

gint
main (void)
{
  GeglColor *white;
  GeglNode *crop;
  GeglNode *graph;
  GeglNode *graph2;
  GeglNode *input;
  GeglNode *output;
  GeglNode *pixelize;
  GeglNode *src;

  gegl_init (NULL, NULL);

  white = gegl_color_new ("white");

  graph = gegl_node_new ();
  src = gegl_node_new_child (graph,
                             "operation", "gegl:color",
                             "value", white,
                             NULL);
  crop = gegl_node_new_child (graph,
                              "operation", "gegl:crop",
                              "height", 1024.0,
                              "width", 1024.0,
                              NULL);

  graph2 = gegl_node_new ();
  gegl_node_add_child (graph, graph2);
  pixelize = gegl_node_new_child (graph2,
                                  "operation", "gegl:pixelize",
                                  NULL);
  input = gegl_node_get_input_proxy (graph2, "input");
  output = gegl_node_get_output_proxy (graph2, "output");
  gegl_node_link_many (input, pixelize, output, NULL);
  g_object_ref (output);
  g_object_ref (pixelize);

  gegl_node_link_many (src, crop, graph2, NULL);
  gegl_node_process (output);

  g_object_unref (graph);
  g_object_unref (graph2);
  g_object_unref (pixelize);
  g_object_unref (output);
  g_object_unref (white);
  gegl_exit ();

  return 0;
}
