/* -*- mode: C -*- */ /* IGraph library. Copyright (C) 2006-2012 Gabor Csardi 334 Harvard st, Cambridge MA, 02139 USA This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include igraph_t g; static Evas *e; static Eina_List *objs = NULL; int _count = 0; static Eina_Bool _start(void *d __UNUSED__); static void _del(void *data __UNUSED__, Efx_Map_Data *emd __UNUSED__, Evas_Object *r); static void _center(void *data __UNUSED__, Efx_Map_Data *emd __UNUSED__, Evas_Object *r); static void _create(void *data __UNUSED__, Efx_Map_Data *emd __UNUSED__, Evas_Object *r); static Efx_End_Cb callbacks[4][6] = { {_create, _create, _create, _center, NULL, _del}, {NULL, NULL, _center, NULL, NULL, _del}, {NULL, _center, NULL, NULL, NULL, _del}, {_center, NULL, NULL, NULL, NULL, _del} }; static Evas_Point points[] = { {-100, -100}, {550, -100}, {-100, 550}, {550, 550} }; static Evas_Object * _rect_create(void) { Evas_Object *r; r = evas_object_rectangle_add(e); objs = eina_list_append(objs, r); switch (eina_list_count(objs)) { case 1: evas_object_color_set(r, 255, 0, 0, 255); break; case 2: evas_object_color_set(r, 0, 255, 0, 255); break; case 3: evas_object_color_set(r, 0, 0, 255, 255); break; default: evas_object_color_set(r, 0, 0, 0, 255); } evas_object_resize(r, 72, 72); evas_object_move(r, 25, 25); evas_object_show(r); return r; } static void _del(void *data __UNUSED__, Efx_Map_Data *emd __UNUSED__, Evas_Object *r) { objs = eina_list_remove_list(objs, objs); evas_object_del(r); if (objs) return; ecore_timer_add(1.0, (Ecore_Task_Cb)_start, NULL); } static void _center(void *data __UNUSED__, Efx_Map_Data *emd __UNUSED__, Evas_Object *r) { efx_rotate(r, EFX_EFFECT_SPEED_LINEAR, 360, NULL, 1.5, NULL, NULL); } static void _create(void *data __UNUSED__, Efx_Map_Data *emd __UNUSED__, Evas_Object *r) { r = rect_create(); efx_queue_append(r, EFX_EFFECT_SPEED_ACCELERATE, EFX_QUEUED_EFFECT(EFX_EFFECT_MOVE(350, 25)), 1.0, callbacks[eina_list_count(objs) - 1][0], NULL); if (eina_list_count(objs) < 4) efx_queue_append(r, EFX_EFFECT_SPEED_DECELERATE, EFX_QUEUED_EFFECT(EFX_EFFECT_MOVE(350, 350)), 1.0, callbacks[eina_list_count(objs) - 1][1], NULL); if (eina_list_count(objs) < 3) efx_queue_append(r, EFX_EFFECT_SPEED_ACCELERATE, EFX_QUEUED_EFFECT(EFX_EFFECT_MOVE(25, 350)), 1.0, callbacks[eina_list_count(objs) - 1][2], NULL); if (eina_list_count(objs) < 2) efx_queue_append(r, EFX_EFFECT_SPEED_DECELERATE, EFX_QUEUED_EFFECT(EFX_EFFECT_MOVE(25, 25)), 1.0, callbacks[eina_list_count(objs) - 1][3], NULL); efx_queue_append(r, EFX_EFFECT_SPEED_DECELERATE, EFX_QUEUED_EFFECT(EFX_EFFECT_MOVE(203, 203)), 1.5, callbacks[eina_list_count(objs) - 1][4], NULL); efx_queue_append(r, EFX_EFFECT_SPEED_ACCELERATE, EFX_QUEUED_EFFECT(EFX_EFFECT_MOVE(points[eina_list_count(objs) - 1].x, points[eina_list_count(objs) - 1].y)), 1.0, callbacks[eina_list_count(objs) - 1][5], NULL); efx_queue_run(r); } static Eina_Bool _start(void *d __UNUSED__) { _create(NULL, NULL, NULL); _insert_node(); _g_layout(); return EINA_FALSE; } static void _end(Ecore_Evas *ee __UNUSED__) { ecore_main_loop_quit(); } void _insert_node(void) { Evas_Object *r; r = _rect_create(); printf("[-] add one edges\n"); igraph_add_vertices(&g, 1, 0); igraph_add_edge(&g, 4, 6 + _count); ETEAN(&g, "weight", 2, 100.0); _count++; } void _g_layout(void) { igraph_vector_t v; igraph_matrix_t coords; printf("[-] apply layout\n"); igraph_matrix_init(&coords, 0, 0); igraph_layout_reingold_tilford(&g, &coords, IGRAPH_IN, 0, 0); printf("[-] check edges\n"); printf("edge count: %d\n", igraph_ecount(&g)); igraph_vector_init(&v, igraph_ecount(&g)); igraph_get_edgelist(&g, &v, 0); print_vector(&v, stdout); printf("[-] show vertices\n"); n=igraph_vcount(&g); for (i=0; i