/* +==================================+ | Random Graph Generation Software | +==================================+ This source code is (c) Copyright 2001 by Christopher R. Palmer and J. Gregory Steffan. It may be freely redistributed and included in other packages provided this copyright notice is included. Version 1.0 January 12, 2001 - Initial public release ---------------------------------------------------------------------- Using the 'PLODD' generator: ==================== This file is the entire distribution. Compile it with your favorite C compiler and you can then run the program as follows: plodd where n is the number of nodes in the graph, and alpha and beta are as defined in the paper (cited below). Example values are alpha=0.811392, beta=3 Note that the authors did not do an extensive study on the impact of different values of alpha and beta. You likely want to choose them to produce a desired slope for your log-log plots. For more information please see the paper that describes this graph generation algorithm. A citation appears at the end of this document. Output format: ============== The output is an n x n adjacency matrix where a '1' indicates the existence of an edge, and a '0' indicates the absence of an edge. More Information / Etc: ======================= The paper that describes this work is: Christopher R. Palmer and J. Gregory Steffan, Generating Network Topologies that Obey Power Laws, IEEE Globecom 2000, San Francisco, CA, November 2000. http://www.cs.cmu.edu/~crpalmer/pubs.html/globecom2000.ps please cite it when referring to this graph generation software. Further information, bug reports, etc. may be sent to: steffan@eecg.toronto.edu crpalmer@cs.cmu.edu ------------------------------------------------------------------ */ #include #include #include #include #include #define MAX2(x,y)(((x) > (y)) ? (x) : (y)) #define MIN2(x,y)(((x) < (y)) ? (x) : (y)) #define TRUE 1 #define FALSE 0 typedef unsigned boolean; double ALPHA; double BETA; double M; int N; int num_ones; unsigned **adj; unsigned *out_deg; double get_rand(){ return ((double)random())/(double)(RAND_MAX+1.0); } int get_count(double m){ return ceil(pow(ALPHA,m)); } void compute_adjacency(){ int i,j,k; int r,c; int v = 0; int inf_loop_ctr; boolean breakout; for (k=0;k<(num_ones/2);k++){ /* get random starting position */ r = floor(get_rand() * N); c = floor(get_rand() * N); breakout = FALSE; /* search until a one is placed */ for (i=0;i \n"); exit(1); } srandom(time(NULL)); N = atoi(argv[1]); ALPHA = strtod(argv[2],NULL); BETA = strtod(argv[3],NULL); adj = malloc(sizeof(unsigned *)*N); out_deg = malloc(sizeof(unsigned)*N); init_adj(); assign_out_deg(); #if 0 print_out_deg(); #endif #if 0 scramble_out_deg(); #endif compute_num_ones(); compute_adjacency(); add_random_edges(); #if 0 symmetrize_adjacency(); #endif print_adjacency(); #if 0 dumppgm("out.pgm"); #endif }