-
Notifications
You must be signed in to change notification settings - Fork 0
/
SSS_SAPTARSHI.c
586 lines (551 loc) · 20.1 KB
/
SSS_SAPTARSHI.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
int V = 10;
int visited[10];
int E = 18;
//TEST INSTANCES ::: ----
int G[10][10] ={{0,0,0,1,1,0,1,0,1,0},{0,0,1,0,0,1,0,1,1,1},{0,1,0,1,1,0,0,0,1,0},{1,0,1,0,0,0,0,0,1,0},{1,0,1,0,0,1,0,0,0,1},{0,1,0,0,1,0,1,0,0,0},{1,0,0,0,0,1,0,0,1,1},{0,1,0,0,0,0,0,0,0,0},{1,1,1,1,0,0,1,0,0,0},{0,1,0,0,1,0,1,0,0,0}};
//int G[10][10] = {{0,0,0,1,0,0,0,0,0,0},{0,1,1,1,1,1,0,0,0,0},{0,1,0,1,0,0,1,1,1,0},{1,1,1,0,0,0,0,0,0,0},{0,1,0,0,0,1,0,0,0,0},{0,1,0,0,1,0,0,1,0,1},{0,0,1,0,0,0,0,1,1,1},{0,0,1,0,0,1,1,0,0,0},{0,0,1,0,0,0,1,0,0,0},{0,0,0,0,0,1,1,0,0,0}};
//int G[10][10] = {{0,0,0,0,1,0,0,0,0,0},{0,0,1,1,0,0,0,0,0,0},{0,1,1,1,1,0,0,0,0,1},{0,1,1,0,0,1,1,0,0,0},{1,0,1,0,0,0,1,0,0,1},{0,0,0,1,0,0,0,1,1,0},{0,0,0,1,1,0,0,0,0,0},{0,0,0,0,0,1,0,0,0,1},{0,0,0,0,0,1,0,0,1,1},{0,0,1,0,1,0,0,1,1,0}};
//int G[10][10] = {{0,1,0,1,0,0,0,0,0,0},{1,0,0,0,0,0,0,0,0,0},{0,0,0,1,0,1,1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1,0,0,0,0,0,0},{0,1,1,0,0,1,0,0,0,0,0,0,0,1,0},{0,1,0,0,0,0,0,1,0,0,0,0,0,0,1},{0,1,0,0,0,0,1,1,0,0,0,0,0,0,0},{1,0,0,0,1,0,0,0,0,1,0,0,1,0,0},{0,1,0,0,0,0,0,0,1,0,1,0,1,0,1},{0,1,0,0,0,0,0,0,0,1,0,0,0,0,1},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,0,1,1,0,0,1,0,0},{0,0,0,1,0,1,0,0,0,0,0,0,0,0,0},{0,0,1,0,0,0,1,0,0,1,1,1,0,0,0}};
struct AdjListNode
{
int dest;
struct AdjListNode* next;
};
struct AdjList
{
struct AdjListNode *head;
};
struct Graph
{
int V;
struct AdjList* array;
};
struct AdjListNode* newAdjListNode(int dest)
{
struct AdjListNode* newNode = (struct AdjListNode*) malloc(sizeof(struct AdjListNode));
newNode->dest = dest;
newNode->next = NULL;
return newNode;
}
struct Graph* createGraph(int V)
{
struct Graph* graph = (struct Graph*) malloc(sizeof(struct Graph));
graph->V = V;
graph->array = (struct AdjList*) malloc(V * sizeof(struct AdjList));
int i,j;
for (i = 0; i < V; ++i)
graph->array[i].head = NULL;
for(i=1;i<V;i++){
for(j=0;j<i;j++){
addEdge(graph, i, j);
}
}
return graph;
}
struct EdgeList{
int startVertex;
int endVertex;
int edgeNumber;
struct EdgeList* next;
}*IN = NULL,*OUT = NULL;
struct EdgeList* newEdge(int src, int dest, int count)
{
struct EdgeList* newE = (struct EdgeList*) malloc(sizeof(struct EdgeList));
newE->startVertex = src;
newE->endVertex = dest;
newE->edgeNumber = count;
newE->next = NULL;
return newE;
}
struct EdgeList* createEdgelist(struct Graph* graph){
int i,j,c = 1;
struct EdgeList* E = (struct EdgeList*) malloc(sizeof(struct EdgeList));
struct EdgeList* temp;
for(i=0;i<graph->V;i++){
for(j=0;j<graph->V;j++){
if(G[i][j]!=0 && i<j){
if(c==1){
E->startVertex = i;
E->endVertex = j;
E->edgeNumber = c;
E->next = NULL;
temp = E;
}
else{
temp->next = newEdge(i,j,c);
temp = temp->next;
}
c++;
}
}
}
return E;
}
void printEdgelist(struct EdgeList* edge)
{
struct EdgeList* pCrawl = edge;
printf("\n Edge list:\n");
while (pCrawl)
{
printf(" %d", pCrawl->edgeNumber);
printf("\t%d,%d\n", pCrawl->startVertex, pCrawl->endVertex);
pCrawl = pCrawl->next;
}
}
void addEdge(struct Graph* graph, int src, int dest)
{
struct AdjListNode* newNode = newAdjListNode(dest);
newNode->next = graph->array[src].head;
graph->array[src].head = newNode;
newNode = newAdjListNode(src);
newNode->next = graph->array[dest].head;
graph->array[dest].head = newNode;
}
void printGraph(struct Graph* graph)
{
int v;
printf("\n Adjacency list ::\n");
for (v = 0; v < graph->V; ++v)
{
struct AdjListNode* pCrawl = graph->array[v].head;
printf("%d",v);
while (pCrawl)
{
printf("-> %d", pCrawl->dest);
pCrawl = pCrawl->next;
}
printf("\n");
}
}
void callDFS(int dfsTree[] ,struct EdgeList* EL){
int i;
for(i=0;i<V;i++)
visited[i]=0;
DFS(dfsTree,0,EL);
}
void DFS(int dfsTree[], int i,struct EdgeList* EL)
{
int j;
//printf("\n%d",i);
visited[i]=1;
for(j=0;j<V;j++)
if(!visited[j]&&G[i][j]==1)
{
struct EdgeList* pCrawl = EL;
while (pCrawl)
{ if(((pCrawl->startVertex == i) && (pCrawl->endVertex == j)) || ((pCrawl->startVertex == j) && (pCrawl->endVertex == i))){
//printf("CONNECTED EDGE IS %d\n", pCrawl->edgeNumber);
dfsTree[pCrawl->edgeNumber] = 1;
}
pCrawl = pCrawl->next;
}
DFS(dfsTree,j,EL);
}
}
int noOfEdge(){
int i,j,count =0;
for( i= 0;i < V; i++){
for(j = 0; j< V; j++){
if(G[i][j] == 1)
count++;
}
}
return count/2;
}
int fact(int num)
{
if ( num == 0 )
return 1;
return(num * fact(num - 1));
}
int numRowsFunction(int m,int n)
{
int rows=fact(m+n)/(fact(m)*fact(n));
return rows;
}
int lastOneIndexFunction(int a[],int cols)
{
int lastOneIndex = 0 , l;
for( l = cols; l > 0; l--)
{
if(a[l]==1)
{
lastOneIndex = l;
return lastOneIndex;
}
}
}
void updateDegree(int *im, int combination[V-1], int degree[V])
{
int i, j;
int NoE = noOfEdge();
for(i=0;i<V-1;i++)
{
for(j=0;j<V;j++)
{
if(*(im + j*(NoE+1) + combination[i])==1 && combination[i]!=0)
{
degree[j] = degree[j]+1;
}
if(combination[i]==0)
{
degree[j] = -1;
}
}
}
}
void deletePendantEdges(int combination[V-1], int degree[V], struct EdgeList *E)
{
int i, j, eno = 0;
struct EdgeList *e = E;
for(i=0;i<V;i++)
{
if(degree[i]==1)
{
for(j=0;j<V-1;j++)
{
eno = combination[j];
while(e)
{
if(e->edgeNumber==eno)
{
if(e->startVertex==i || e->endVertex==i)
{
combination[j] = 0;
}
break;
}
e = e->next;
}
e = E;
}
}
}
}
void updateDegreeAgain(int combinationCopy[V-1], int degree[V], struct EdgeList *E)
{
int i;
struct EdgeList *e = E;
for(i=0;i<V-1;i++)
{
if(combinationCopy[i]!=0)
{
while(e)
{
if(e->edgeNumber==combinationCopy[i])
{
degree[e->startVertex] = degree[e->startVertex]+1;
degree[e->endVertex] = degree[e->endVertex]+1;
break;
}
e = e->next;
}
e = E;
}
}
}
int treeTest(int combination[V-1], int *IM, struct EdgeList *E)
{
int i, degree[V], combinationCopy[V-1], dCounter = 0, degCounter = 0, flag = 0;
for(i=0;i<V;i++)
{
degree[i] = 0;
}
updateDegree(IM,combination,degree);
while(1)
{
for(i=0;i<V;i++)
{
if(degree[i]==1)
{
dCounter++;
}
}
if(dCounter>=2)
{
for(i=0;i<V;i++)
{
if(degree[i]>1)
{
degCounter++;
}
}
if(degCounter>=3)
{
if(dCounter>=1)
{
deletePendantEdges(combination,degree,E);
for(i=0;i<V;i++)
{
degree[i] = 0;
}
updateDegreeAgain(combination,degree,E);
dCounter = 0;
degCounter = 0;
}
else
{
flag = 0;
break;
}
}
else
{
flag = 1;
break;
}
}
else
{
flag = 0;
break;
}
}
return flag;
}
void generateGrayCode(){
int i,j,m,n,k,ro,co,u,z,t,lnx,q,rowNumbersTotal,relativeFirstIndex,CurrentRow,Zeroleft,ZeroleftOuter,cols,rowsToModify,OneLeft,highestIndexForOne;;
int treeSerialNo = 1,numZero = 0,numOne = 0,ro1 = 1,cpy1 = 0,newNumberOfZero,newNumberOfOne;
int *arr,size,*binaryarray,**mat;
int storeTreeArrayCopy[V-1];
int storeTreeArray[V-1];
int cpy2,store;
struct Graph* graph = createGraph(V);
int mt[V][E+1];
int dfsTreeSize = noOfEdge()+1;
int dfsTree[dfsTreeSize];
int dfsTreecopy[dfsTreeSize];
dfsTree[0] = -1;
// GETTING THE FIRST TREE FROM DFS AND STORING IT IN DFS TREE
for(i = 1 ; i< dfsTreeSize; i++){
dfsTree[i] = 0;
}
//printf("PRINT OF ADJACENCY LSIT OF THE GRAPH \n");
//printGraph(graph);
struct EdgeList* EL = createEdgelist(graph);
printEdgelist(EL);
callDFS(dfsTree,EL);
// PRINTING THE DFS TREE
for(i = 0 ; i< dfsTreeSize; i++){
printf(" %d ",dfsTree[i]);
}
printf("\n");
// COPYING THE DFS TREE AND COUNTING NUMBER OF 1 AND NUMBER OF 0
for(i = 0 ; i < dfsTreeSize; i++){
dfsTreecopy[i] = dfsTree[i];
if(dfsTree[i] == 0){
numZero++;
}
if(dfsTree[i] == 1){
numOne++;
}
}
// CREATING THE TREE BRANCH ARRAY( STORING INDEX OF 1) AND CHORD BRANCH ARRAY (STORING INDEX OF 0)
int treebrancharray[numOne];
int chordbrancharray[numZero];
k = 0;
for(i = 0 ; i < dfsTreeSize ; i++){
if(dfsTree[i] == 1){
treebrancharray[k] = i;
k++;
}
}
k = 0;
for(i = 0 ; i < dfsTreeSize ; i++){
if(dfsTree[i] == 0){
chordbrancharray[k] = i;
k++;
}
}
// PREPARATION FOR GENERATING GRAY CODES
size = pow(2,numZero);
arr = (int*) calloc(numZero, sizeof(int));// THIS ARRAY WILL CONTAIN THE RIGHT PART ( GRAY CODE ) OF TATM
for(i = 0; i< numZero; i++){
arr[i] = 0;
}
// FOR LOOP TO GENERATE GRAY CODE ONE BY ONE
for(u = 1; u < size; u++){
lnx = floor(log(u)/log(2))+1;
binaryarray = (int*) calloc(lnx, sizeof(int));
generateBinary(binaryarray,u,lnx);
for(z = 0; z< numZero; z++){
arr[z] = 0;
}
for(j = lnx -1, k = numZero-1 ; j >= 0; j--,k--){
arr[k] = binaryarray[j];
}
// FOR PRINTING GRAY CODES OF LENGTH n
/*for(m = 0; m < numZero; m++){
printf("%d",arr[m]);
}
printf("\n");*/
newNumberOfZero = 0;
for(t = 0; t< numZero; t++){
if( arr[t] == 1)
newNumberOfZero++;
}
newNumberOfOne = numOne - newNumberOfZero;
rowNumbersTotal = numRowsFunction(newNumberOfOne,newNumberOfZero);
cols = newNumberOfOne + newNumberOfZero;
mat = (int **)calloc(rowNumbersTotal , sizeof(int*));
for( i = 0; i < rowNumbersTotal; i++)
{
mat[i] = (int *)calloc(cols , sizeof(int));
}
for(j = 0; j < newNumberOfOne; j++)
{
CurrentRow=0;
while(CurrentRow != rowNumbersTotal)
{
relativeFirstIndex = (j==0) ? 0 : (lastOneIndexFunction(mat[CurrentRow],cols)+1);
ZeroleftOuter = newNumberOfZero - (relativeFirstIndex-j);
OneLeft = newNumberOfOne-j;
highestIndexForOne = cols-OneLeft+1;
for( m = relativeFirstIndex; m < highestIndexForOne; m++)
{
Zeroleft = (ZeroleftOuter- (m-relativeFirstIndex) <0) ? 0 : (ZeroleftOuter-m +relativeFirstIndex) ;
rowsToModify = numRowsFunction(newNumberOfOne-j-1,Zeroleft);
for(n = 0; n < rowsToModify; n++)
{
mat[n+CurrentRow][m]=1;
}
CurrentRow = CurrentRow + rowsToModify;
}
}
}
int printTreeArray[dfsTreeSize],cpy;
printTreeArray[0] = -1;
// THIS IS FOR PRINTING THE COMBINATIONS OF 0 & 1 , NOT THE TREE
/*for( ro = 0 ; ro < rowNumbersTotal ; ro++){
for( co = 0 ; co < cols ; co++){
printf("%d",mat[ro][co]) ;
}
printf("\n");
}*/
// THIS IS FOR PRINTING THE FINAL TREE AND ALSO TREE CHECKING
ro = 0;
while(ro < rowNumbersTotal){
ro1 = 1;
for( cpy = 0 ; cpy < cols ; cpy++){
printTreeArray[ro1] = mat[ro][cpy] ;
ro1++;
}
cpy1 = 0;
while(ro1 < dfsTreeSize){
printTreeArray[ro1] = arr[cpy1];
ro1++;
cpy1++;
}
// PRINTING THE FINAL COMBINATIONS
/*for(cpy = 1 ; cpy < dfsTreeSize ; cpy++){
printf(" %d ",printTreeArray[cpy]);
}
printf("\n");*/
// PRINTING THE FINAL TREES
store = 0;
for(cpy = 1 ; cpy <= numOne ; cpy++){
if(printTreeArray[cpy] == 1)
storeTreeArray[store++] = treebrancharray[cpy-1];
}
for(cpy2 = numZero -1 ; cpy2 >= 0 ; cpy2--){
if(arr[cpy2] == 1){
storeTreeArray[store++] = chordbrancharray[cpy2];
}
}
// CALL THE TREE CHECKING ALGORITHM HERE
for(q = 0; q < V-1 ; q++ ){
storeTreeArrayCopy[q] = storeTreeArray[q];
}
//int E = noOfEdge();
createIncedenceMatrix(mt,EL);
if(( treeTest(storeTreeArray,mt,EL) == 1)){
for(q = 0; q < V-1 ; q++ ){
storeTreeArray[q] = storeTreeArrayCopy[q];
}
printf(" TREE NO %d ----> ", treeSerialNo);
for(store = 0; store < V-1; store++ ){
printf(" %d ",storeTreeArray[store]);
}
treeSerialNo++;
printf("\n");
}
ro++;
}
}
}
void createIncedenceMatrix(int im[V][E+1], struct EdgeList* EL)
{
struct EdgeList* temp = EL;
int row, column, r, c, y = 0;
for(row=0;row<V;row++)
{
for(column=0;column<E+1;column++)
{
im[row][column]=0;
}
}
for(row=0;row<V;row++)
{
im[row][0] = row;
}
for(row=0;row<V;row++)
{
for(column=0;column<E+1;column++)
{
while(temp)
{
if(temp->edgeNumber==column)
{
if(temp->startVertex==row || temp->endVertex==row)
{
r = row;
c = column;
y = 1;
break;
}
}
temp = temp->next;
}
if(y==1)
{
im[r][c] = 1;
y = 0;
}
temp = EL;
}
}
/* printf("\n Incidence Matrix :\n");
for(row=0;row<V;row++)
{
for(column=0;column<E+1;column++)
{
printf(" %d ",im[row][column]);
}
printf("\n");
}*/
}
void generateBinary(int *array,int x , int lnx){
int quotient,i,j;
if(x>0){
quotient = x;
i=lnx;
while(quotient!=0){
array[i-1]= quotient % 2;
quotient = quotient / 2;
i--;
}
}
}
void main()
{
generateGrayCode();
}