algos/pre_post_recursion.c
int isAcyclic(struct node *adj[],struct order *vals,int NV) {
	int i=0;
	int pre_u,pre_v,post_u,post_v;
	struct node *t;
	for(i=1;i<=NV;i++) {
		t=adj[i];
		pre_u=vals[i].pre;
		post_u=vals[i].post;
		pre_v=vals[t->V].pre;
		post_v=vals[t->V].post;
		while(t->next != t) {
//			printf("Checking nodes %d and %d\n",i,t->V);
//			printf("u:(%d,%d) \t v:(%u,%u)\n",pre_u,post_u,pre_v,post_v);
			//the condition for a back edge
			if(pre_v< pre_u && post_u < post_v) {
//				printf("Back edge found. Graph is cyclic.\n");
				return 0;
			}
			t=t->next;
			pre_v=vals[t->V].pre;
			post_v=vals[t->V].post;
		}
	}
	return 1;	
}
//using pre,post ordering, determine whether there is a back edge
using pre,post ordering, determine whether there is a back edge
using pre post ordering determine whether there is a back edge
int isAcyclic(struct node *adj[],struct order *vals,int NV) {
	int i=0;
	int pre_u,pre_v,post_u,post_v;
	struct node *t;
	for(i=1;i<=NV;i++) {
		t=adj[i];
		pre_u=vals[i].pre;
		post_u=vals[i].post;
		pre_v=vals[t->V].pre;
		post_v=vals[t->V].post;
		while(t->next != t) {
			if(pre_v< pre_u && post_u < post_v) {
				return 0;
			}
			t=t->next;
			pre_v=vals[t->V].pre;
			post_v=vals[t->V].post;
		}
	}
	return 1;	
}
int isAcyclic ( struct node * adj [ ] , struct order * vals , int NV ) { int i = 0 ; int pre_u , pre_v , post_u , post_v ; struct node * t ; for ( i = 1 ; i <= NV ; i ++ ) { t = adj [ i ] ; pre_u = vals [ i ] . pre ; post_u = vals [ i ] . post ; pre_v = vals [ t -> V ] . pre ; post_v = vals [ t -> V ] . post ; while ( t -> next != t ) { if ( pre_v < pre_u && post_u < post_v ) { return 0 ; } t = t -> next ; pre_v = vals [ t -> V ] . pre ; post_v = vals [ t -> V ] . post ; } } return 1 ; }
using pre,post ordering, determine whether there is a back edge
using pre post ordering determine whether there is a back edge
//			printf("Checking nodes %d and %d\n",i,t->V); //			printf("u:(%d,%d) \t v:(%u,%u)\n",pre_u,post_u,pre_v,post_v); //the condition for a back edge //				printf("Back edge found. Graph is cyclic.\n");