#include #define N 30 // Maximum number of vertices. Must be <= number of bits in an int variable. #define OPT 1 // If non-zero, perform optimizations by only checking certain sets of k added edges. int A[N][N]; // Adjacency matrix of G. int v[N]; // List of vertices in substructures. int dg[N]; // Number of cross edges meeting a vertex. int n1; // Number of vertices in first subgraph G_1 (if G = G_1\cup G_2 + ke). int nt; // Total number of vertices in graph. // Declare some simple graph types. // typedef enum {None=0,Path=1,Cycle=2,Cdag=3,Cplus2=4} gtype; // Types of graph. int minsize[]={0,1,3,4,4}; // Minimum number of vertices needed for each type. char* names[]={"","P_","C_","C^d_","C^+2_"}; // Short names of the types of graph. // Clear graph and entire adjacency matrix. // Must be called before addgraph() is used. // void cleargraph(){ int i,j; for(i=0;iN||nt<0){printf("Error: too many vertices in graph\n");exit(0);} if(t!=Path&&t!=Cycle){printf("Error: can only construct paths and cycles here\n");exit(0);} for(i=nt;i=minsize[t1]){ // No point checking if not enough vertices. if( (t1==Path) // We always have constructed a path v[v0]-v[vn-1]. ||(t1==Cycle && A[v[v0]][v[vn-1]]) // Need a closing edge for cycles. ||(t1==Cdag && A[v[v0]][v[vn-1]] && ch>((vn-v0==4)?1:2)) // Check enough chords for Cdag. Number of chords is ch-1. ||(t1==Cplus2&& A[v[v0]][v[vn-1]] && ch>2)){ // Check enough chords for Cplus2. Number of chords is ch-1. if(findr(vn,vn,bm,nr,0,t2,None))return 1; // Recursively find second subgraph. } } if(nr<=minsize[t2])return 0; // Run out of vertices. if(t1!=Path)vmax=v[v0]; else vmax=nt; // For efficiency, assume first vertex of cycle is largest. for(w=0;w2 in P_* and both ends covered. // This is used in the optimization of findbetween(). If we have found substructures for all choices of cross edges // and smaller P_*, then we can assume the cross edges meet the ends of P_* and at least every other vertex along P_* // as otherwise we would have found a counterexample with smaller P_*. // int extraedges(){ int i,c,f; c=f=0; // c=extra edges needed, f=1 if last vertex covered. for(i=n1;i=k; // Degree of j OK and enough room for remaining edges. } return 1; } // Recursive routine to find structure for all k-sets of edges between G_1 and G_2. // k = number of remining edges to add. // l = last edge added (we optimize by assuming edges are chosen in reverse order). // t1,t2 = structures of subgraph(s) to find. // nr = max number of vertices these structures can use. // If f=1 then we make sure the endvertices and at least every other vertex in the path G_2 is covered by cross edges. // Edges from vertex i=n1 are sorted by value of i+n1*(j-n1). // Routine assumes no edges originially exist between G_1 and G_2. // int findbetween(int k,int l,gtype t1,gtype t2,int nr,gtype t){ int e,i,j; if(findr(0,0,(1< "); else printf(" >= "); // Can we use all the vertices? printf("%s*",names[t1]); // Substructure to find. if(t2!=None)printf(" + %s*",names[t2]); cleargraph(); // Construct base graph without added edges. addgraph(t,v1); addgraph(t,v2); #if OPT // As an extra optimization, we can always assume one edge goes to last vertex of G_2. // (For paths: if not, then taking the redundant vertices at the end of the path G_2 // and adding them on at the beginning of G_2 can never hurt us when looking for cyclic substructures.) // For cycles we can also assume this comes from last vertex of G_1. // For paths we can only assume this comes from the second half of G_1. // Note that the largest edge in our ordering can be assumed to be this edge. j=n1+v2-1; // Last vertex of G_2. dg[j]=1; // Record cross-degree of this vertex. if(t==Path)i=v1/2; else i=v1-1; // Middle or last vertex of G_1. for(;i "); else printf(" >= "); // Can we use all the vertices. printf("%s*",names[t1]); // Substructure to find. cleargraph(); // Construct base graph without added edges. addgraph(Cycle,v1); if(findwithin(k,v1*v1,t1,None,nt-s)){ // See if substructure always exists. printf(" Yes\n");return 1; // Always succeeded. } else {printf(" No\n");return 0;} // Failed. } main(){ int n,m,k; if(sizeof(int)*8=1;m--){ for(;;k++)if(between(Path,n,m,k,Cdag,None,0))break; // Then we check the smaller m's. } printf("P_%d + P_* + %de >= C^d_* OK\n\n",n,k); // Summary statement of results. for(;;k++)if(between(Path,n,2*k-1,k,Cdag,None,1))break; // no point looking for > if not >=. for(m=2*k-2;m>=1;m--){ for(;;k++)if(between(Path,n,m,k,Cdag,None,1))break; // Check smaller m's. } printf("P_%d + P_* + %de > C^d_* OK\n\n",n,k); // Summary statement of results. } printf("Lemma 10\n"); for(m=3;m<=4;m++){ for(k=8;;k++)if(between(Cycle,4,m,k,Cycle,Cycle,1))break; printf("\n"); } for(n=4;n<=7;n++){ for(m=3;m<=n;m++)if(m+n>=8){ for(k=9;;k++)if(between(Cycle,n,m,k,Cdag,Cycle,1))break; printf("\n"); } } // This last section takes a long time to run, especially n=7. printf("Lemma 11\n"); for(n=5;n<=7;n++){ for(m=4;m<=n;m++){ for(k=13;;k++)if(between(Cycle,n,m,k,Cdag,Cdag,1))break; printf("\n"); } } printf("Finished\n"); }