Exemplo n.º 1
0
Vertex*
intermediate_cycle_ATTLC(char gtype, const Graph& g) {
	tcwbool_ATTLC found_cycle = FALS;
	Vertex* v;

	Vis_v_ticket vt = Vertex::get_vis_v_ticket();
	Set_of_p<Vertex> spv = g.vertices();
	Set_of_piter<Vertex> vset_iter(spv);
	Vertex* next_v;
	while (next_v = vset_iter.next()) {
		if (!next_v->visited(vt)) {
			next_v->set_visited(vt);
			stat_v_pset.insert(next_v); 
			if (cycle_v(gtype, next_v, 2, &v, g, vt)) {
				found_cycle = TRU;
				break;
			}
			else
				stat_v_pset.remove_all(); //clear for next try
		}
	}
	stat_v_pset.remove_all(); //clear 
	reset_visited(vt, (Set_of_p<Vertex>&)g.vertices());
	Vertex::free_vis_v_ticket(vt);
	return(found_cycle ? v : 0);
}
Exemplo n.º 2
0
void tiernan(int start_node, int end_node){
	int k,i,j,ckt=0;
	//p[0] = 0;
	
	for(i = start_node; i<end_node; i++){
		visited_cnt = 0;
		ckt = 0;
		k = 0;
		//printf("Current i: %d\t Current k: %d\n",i,k);
		p[0] = i;
		

		while(1){
			if((j=path_extension(k)) > -1){
				k=k+1;
				p[k] = g[p[k-1]].edge[j];
				if(k == 1){
					add_to_visited(p[k]);
				}
			}
			else{
				if(belongs_toG(k) && length_of_circuit()!=2){ //circuit confirmation
					if(check_in_visited()){
						print_circuit();//circuit is reported
						ckt++;
					}
				}
				if(k == 0){	//vertex closure
				//	printf("For i: %d, Circuits: %d\n",i+1,ckt);
					break;
				}
				else{
					
					set_H(k,0);
					set_H(k,1);
					p[k] = -1;
					k--;				
				//	if(k < 5)
					//printf("Current K in Else: %d\n",k);
				}
			}
			
		}
		reset_H();
		reset_visited();

	}
}
Exemplo n.º 3
0
int
intermediate_cycle_v_ATTLC(char gtype, const Graph& g, const Vertex* v) {
	tcwbool_ATTLC found_cycle = FALS;
	Vertex* vp;

	if (v) {
		Vis_v_ticket vt = Vertex::get_vis_v_ticket();
		((Vertex*)v)->set_visited(vt);
		stat_v_pset.insert((Vertex*)v);
		found_cycle = cycle_v(gtype, v, 1, &vp, g, vt);
		reset_visited(vt, (Set_of_p<Vertex>&)g.vertices());
		Vertex::free_vis_v_ticket(vt);
		stat_v_pset.remove_all(); //clear
	}
	return(found_cycle);
}
Exemplo n.º 4
0
/* cycle(e) pseudocode:
	if e is encountered twice while in dfs, a cycle exists.
	This is the same as evaluating whether e's source is visited twice.
*/
int
intermediate_cycle_e_ATTLC(char gtype, const Graph& g, const Edge* e) {
	tcwbool_ATTLC found_cycle = FALS;
	Vertex* v;
	
	if (e) {
		Vis_v_ticket vt = Vertex::get_vis_v_ticket();
		(e->src())->set_visited(vt); //arbitrary for 'u' but consistent
					// with cycle_e
		stat_v_pset.insert(e->src());
		found_cycle = cycle_e(gtype, e, 1, &v, g, vt);
		reset_visited(vt, (Set_of_p<Vertex>&)g.vertices());
		Vertex::free_vis_v_ticket(vt);
		stat_v_pset.remove_all(); //clear
	}
	return(found_cycle);
}
Exemplo n.º 5
0
/* returns list of edges in cycle, including e if other edges in the list*/
List_of_p<Edge>
intermediate_cycle_list_e_ATTLC(char gtype, const Graph& g, const Edge* e) {
	List_of_p<Edge> e_list; 		/*e_list collects the cycle */

	if (e) {
		orig_source = e->src(); //doesn't matter which end we choose for 'u'
		Vis_v_ticket vt = Vertex::get_vis_v_ticket();
		orig_source->set_visited(vt);
		cycle_sub(gtype, e, e_list, g, vt);
		reset_visited(vt, (Set_of_p<Vertex>&)g.vertices());
		Vertex::free_vis_v_ticket(vt);
		if (e_list.length() != 0) {
			// e_list.reset(0);  /*position ptr to head of list for insert */
			// e_list.insert_next(e); //insert start e
			e_list.unget(e);
		}
		// e_list.reset(0);
	}
	return(e_list);
}
Exemplo n.º 6
0
void print_longest_substring_unrepeated(){
		int i=0,local_max_length=0,last_index=0;
		 while(str[i]!='\0'){
		  if(!visited[str[i]]){
			 local_max_length++;
			if(max_length<local_max_length)
			 max_length=local_max_length;




			 last_index=i;
			 visited[str[i]]=1;


		  }
			else{

				//Reset visited array to zero
				reset_visited();
				//Reset local_max_length
				 local_max_length=1;
				 visited[str[i]]=1;
			}


			i++;


		 }









}
Exemplo n.º 7
0
void grid_segment::reset_cell(grid_cell::ptr cell)
{
    cell->set_label(0);
    cell->set_approx_label(0);
    reset_visited(cell);
}