/* Title: Girth and Degree inhibited graph generator file: girth.c Does: generates a graph inhibited by girth (minimum cycle size) and/or degree variance from the average, which can aid in making the graph flatter. Source: Joseph Culberson's Coloring Page http://web.cs.ualberta.ca/~joe/Coloring/index.html Author: Original Girth code by Joseph Culberson Degree inhibiting code added by Denis Papp in May, 1995 email: joe@cs.ualberta.ca dpapp@cs.ualberta.ca Compilation: C Code Inputs: several parameters describing the graph Outputs: generated graph Copyright: Joseph Culberson. Permission is granted to use and distribute freely for non-commercial purposes with appropriate attribution. Warranty: NONE! Special Instructions: Have fun! Part of: The k-colorable graph generator program. */ #include "generate.h" /*#define DEBUG */ extern void bzero(); extern void bcopy(); /* degree_check() * DESC: checks if both vertices are of acceptable degree * GIVEN: the degrees array, the 2 vertices, and the max degree delta * from the average to permit * RETURNS: true if i,j are of acceptable degree */ int degree_check(degrees,i,j,avg,delta) int *degrees,i,j,delta; float avg; { return !(degrees[i]>=avg+delta || degrees[j]>=avg+delta); } void dfsother(blocker,graph,u,pu,v,pv,girth,size) graphtype blocker,graph; int u,pu,v,pv; int girth,size; { int i; set_edge(u,v,1,blocker); if (girth>1) { for(i=0;i1) { for(i=0;i 7, this is quite inefficient. Given sparseness of such graphs it might be worthwhile choosing a data structure... */ /* degree_control_graph * DESC: generates grith and degree inhibited graph, sets edges parameter * GIVEN: graph, blocked edges matrix, number of vertices (size), * edge probability, number of partitions, * girth (minimum cycle size) * delta (max degree allowed beyond the average) * delta_max (maximum amount delta can increase to) * pointer to edges */ void degree_control_graph( graph,blocker,size,prob,part,girth,delta,delta_max,edges) graphtype graph; graphtype blocker; int size,part,girth,delta,delta_max; double prob; long *edges; { int i,j; long npair; int *queue; int qsize,wsize,initsize,next; int quit; int *degrees; int total; float avg; struct pairstr { int i,j; } *pair,temp; pair = (struct pairstr *) calloc((unsigned) 1+(size*(size-1))/2, (unsigned) sizeof(struct pairstr)); /* create all possible pairs */ npair=0; for(i=1;i=delta_max) { printf("Delta hit max.\n"); quit = 1; } else { printf("Problem: no change, increasing delta by 1\n"); delta++; } } initsize = qsize; if (qsize==0) quit=1; } #ifdef DEBUG printf("\n"); #endif } printf("Final delta: %d Edges not considered: %d\n",delta,qsize); free((char *)degrees); free((char *)pair); free((char *)queue); }