/*****************************************************************************/ int FileToABU(int *A, int *B, char *NAME) /* Search file */ { FILE *F; char TITLF[]=DataFile; char CH,*S,GrStr[NN]; int H,I,K,N=0,Nnodes,Nlinks, *P,*Q; if ((F=fopen(TITLF,"r"))==NULL) {printf("Cannot find file %s\n",TITLF); return 0;} /************* list input-datas already in file ***********/ CH=(char)fgetc(F); LP2: while ((!feof(F)) && (CH != '[')) CH=(char)fgetc(F); /* find next [ */ if (!feof(F)) { N++; printf("%d ",N); while (CH != ']') {putchar(CH); CH=(char)fgetc(F);} puts("]\n"); goto LP2; } INX: puts("Input number before the selected data-input (zero to abort):"); scanf("%d",&K); getchar(); if (!K) {fclose(F); return 0;} if ((K<0) || (K>N)) {printf("Number must be between 1 and %d\n",N); goto INX;} rewind(F); CH = (char)fgetc(F); for (I=1; INnodes) Nnodes=H; S++; LP: /* neighbors of H */ /* puts("LP"); */ if (*S==',') S++; while (*S==' ') S++; if (*S=='(') goto NEWCLUSTER; /* no more neighbors of H */ if (*S==']') goto DBL; if (*S=='#') goto LP; K=0; while ((*S>='0') && (*S<='9')) {K = 10*K + *S-48; S++;} if (!K) { /* H is isolated, no neighbors */ while ((*S==' ') || (*S==',')) S++; if (*S==']') goto DBL; /* H is last node */ if (*S=='(') goto NEWCLUSTER; /* H not last node */ } if (K>Nnodes) Nnodes=K; *Q=K; *P=H; P++; Q++; Nlinks++; /* H stored in A[], K stored in B[] */ /* printf("Nlinks=%d *S=%c CNT=%d\n",Nlinks,*S,CNT); */ /* puts("EndLP"); */ goto LP; DBL: /* *S = ']' */ for (K=1; K<=Nlinks; K++) {*P = B[K]; *Q = A[K]; P++; Q++;} *P=*Q=0; A[0]=2*Nlinks; B[0]=Nnodes; SORTABU(A,B); return A[0]; } /*****************************************************************************/