int generic_func(int node,int start){
	int i = node,j;
	for(j = start; j<n ;j++){
		if(trconn[i][j] == 1){
			cost_array[ca++] = trcost[i][j];
			tcost = tcost + trcost[i][j];	
			if(j == s){
				tmp_cost[tc++] = tcost;
				prevcost = cost_array[ca-1]+cost_array[ca-2];
				tcost = tcost - prevcost;
				tmp = prevcost;
				ret_node = node;
				fl = find_low_tmp_cost(tmp_cost,0,tc-1);
				return fl;
			}else{
				int cond = 0;
				cond = if_node_gvisited(j);
				if(cond == 0){
					tcost = 0;
					gf[j] = generic_func(j,0);
					gvisited[gvs++] = j;
				}else{
					tmp_cost[tc++] = tcost + gf[j];
					tcost = 0;
					if(i != node){
						tc = 0;
						tmp_cost[tc] = 0;
					}
					continue;
				}
				if(i == run_node && j == n-1){
					fl = find_low_tmp_cost(tmp_cost,0,tc-1);
					return fl;
				}
			}		
		}else if(trconn[i][j] == 0){
			if(j == n-1){
				fl = find_low_tmp_cost(tmp_cost,0,tc-1);
				return fl;
			}else{
				continue;
			}
		}
	}
	fl = find_low_tmp_cost(tmp_cost,0,tc-1);
	return fl;
}
void prepare_generic_func(int row,int start){
	int i = row,j;
	for(j=start ; j<n ; j++){
		if(trconn[i][j] == 0){
	
		}else{
			if(j == s){
				int cond;
				cond = if_node_gvisited(j);
				if(cond == 0){
					gf[j] = 0;
					gvisited[gvs++] = j;
				}
				return;
			}else{
				int cond;
				prepare_generic_func(j,1);
				node = j; 
				cond = if_node_gvisited(j);
				if(cond == 0){
					int t;
					t = generic_func(j,1);
					gf[j] = fl;
					gvisited[gvs++] = j;
				}
				ca = 0;
				cost_array[ca] = 0;
				prevcost = 0;	
				tcost = 0;	
				tc = 0;
				tmp_cost[tc] = 0;
			}	
		}
	}
	if(i == 1){
		return;
	}
}
Ejemplo n.º 3
0
static unsigned int sha_512_func(unsigned char *o, X509 *x) {
	const EVP_MD *md;
	md = EVP_sha512();
	return generic_func(o, x, md);
}