Sophie

Sophie

distrib > Fedora > 13 > x86_64 > by-pkgid > 8dddad4a08f7c39782445e54a14af930 > files > 172

igraph-devel-0.5.2-5.fc12.i686.rpm

/* -*- mode: C -*-  */
/* 
   IGraph library.
   Copyright (C) 2006  Gabor Csardi <csardi@rmki.kfki.hu>
   MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary
   
   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 <igraph.h>
#include <stdlib.h>
#include <time.h>

int igraph_i_layout_merge_dla(igraph_i_layout_mergegrid_t *grid, 
			      long int actg, igraph_real_t *x, igraph_real_t *y, igraph_real_t r,
			      igraph_real_t cx, igraph_real_t cy, igraph_real_t startr, 
			      igraph_real_t killr);

int main() {
  
  /*******************/
  /* Testing the DLA */
  /*******************/
  long int nodes=10;
  igraph_i_layout_mergegrid_t grid;
  igraph_vector_t x, y, r;
  long int i;

  srand(time(0));
  
  igraph_vector_init(&x, nodes);
  igraph_vector_init(&y, nodes);
  igraph_vector_init(&r, nodes);  
  igraph_i_layout_mergegrid_init(&grid, -5, 5, 100, -5, 5, 100);

  /* radius */
  for (i=0; i<nodes; i++) {
    VECTOR(r)[i]=rand()/(double)RAND_MAX;
  }
  igraph_vector_sort(&r);

  /* place */
  VECTOR(x)[0]=0;
  VECTOR(y)[0]=0;
  igraph_i_layout_merge_place_sphere(&grid, 0, 0, VECTOR(r)[nodes-1], 0);

  for (i=1; i<nodes; i++) {
/*     fprintf(stderr, "%li ", i); */
    igraph_i_layout_merge_dla(&grid, i, 
			      igraph_vector_e_ptr(&x, i),
			      igraph_vector_e_ptr(&y, i),
			      VECTOR(r)[nodes-i-1], 0, 0, 4, 7);
    igraph_i_layout_merge_place_sphere(&grid, VECTOR(x)[i], VECTOR(y)[i], 
				       VECTOR(r)[nodes-i-1], i);
  }

/*   for (i=0; i<nodes; i++) {  */
/*     printf("%f %f\n", VECTOR(x)[i], VECTOR(y)[i]); */
/*   } */

/*   print_grid(&grid, stdout); */
  
  igraph_vector_destroy(&x);
  igraph_vector_destroy(&y);
  igraph_vector_destroy(&r);
  igraph_i_layout_mergegrid_destroy(&grid);
  return 0;
}