/* Title: clique driven graph generator file: clique.c Does: inputs the user for an amount of variously-sized cliques and places those cliques randomly in the graph. A fair number of cliques is required since multiple cliques may share multiple vertices and there is no guarantee all vertices will be chosen Source: Joseph Culberson's Coloring Page http://web.cs.ualberta.ca/~joe/Coloring/index.html Author: Denis Papp email: dpapp@cs.ualberta.ca Compilation: C Code 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 */ #ifdef DEBUG int degree[MAX_NR_VERTICES]; #endif /* clique() * DESC: clique generator. Increments in the given edges parameter * GIVEN: the graph, size of the clique, permutation of vertices, * list of first vertex of each color class, order, * number of partitions, pointer to number of edges */ void clique(graph,size,perm,firstv,order,parts,edges,size_weighted) graphtype graph; int size,*firstv,order,parts; int perm[MAX_NR_VERTICES]; long *edges; int size_weighted; { int i,j,k,t; int maxweight; int chosen[parts]; int class[parts]; for (i=0;iorder) parts = order; firstv = (int *) calloc((unsigned)parts+1,sizeof(int)); /* get a list of vertices sorted by color */ for (i=0;ifirstv[num]; j--) perm[j] = perm[j-1]; perm[firstv[num]] = i; /* shift over the other classes starting places */ for (j=num+1;j<=parts;j++) firstv[j]++; } #ifdef DEBUG for (i=0;i<=order;i++) printf("%d ",colors[perm[i]]); printf("\n"); for (i=0;i<=parts;i++) printf("%d ",firstv[i]); printf("\n"); #endif printf( "Enter (# size) pair for cliques to generate, terminate with 0,0.\n"); do { scanf("%d %d",&num,&size); printf("%d %d",num,size); if (size>1 && size<=parts) { for (i=0;iparts) printf("Illegal clique size\n"); } while (num>0 || size>0); printf("Assigned %ld edges\n",*edges); #ifdef DEBUG for (i=0;i