Exemple #1
0
void augment(Net net, path p, uint flow) 
{
	uint x = 0, y = 1;
	nodes_list nodes = net_get_nodes(net);
	edges_list edges = net_get_edges(net);

	while (y != 0) {
		x = nodes_get_ancestor(nodes, y);
		path_add_node(p, y, nodes_get_balance(nodes, y));
		
		if (nodes_get_balance(nodes, y)) {
			edges_update_flow(edges, x, y, edges_flow(edges, x, y) 
							  + flow);
			
			if(edges_flow(edges, x, y) == edges_capacity(edges, x, y)){
				nodes_del_neighb(nodes, x, 1);
			}
		}
		else {
			edges_update_flow(edges, y, x, edges_flow(edges, y, x) 
							  - flow);
			if(edges_flow(edges, y, x) == 0) {
				nodes_del_neighb(nodes, x, 0);
			}
		}
		y = x;
	}
	path_add_node(p, y, 1);
	path_update_flow(p, flow);
}
Exemple #2
0
void perfect_path_base_callback(Path * p)
{
	pathStep p1, p2;
	path_get_last_step(&p1, p);
	path_get_step_at_index(0, &p2, p);
	
	//Remove the repeated node in a cycle
	if (path_is_cycle(p)) {
		
		if (path_step_equals
		    (&p1,
		     &p2)) {
				p1.label = Undefined;
				path_remove_last(p);
				path_add_node(&p1, p);
			}
	}
	
	int n_fwd = db_node_edges_count_all_colours(p2.node, p2.orientation);
    int n_rev = db_node_edges_count_all_colours(p2.node, opposite_orientation(p2.orientation));
    
    int n_fwd_f = db_node_edges_count_all_colours(p1.node, p1.orientation);
    int n_rev_f = db_node_edges_count_all_colours(p1.node, opposite_orientation(p1.orientation));
    
        
    if (n_fwd == 0) {
        path_add_stop_reason(FIRST, PATH_FLAG_STOP_BLUNT_END, p);
    }
    if (n_fwd > 1) {
        path_add_stop_reason(FIRST, PATH_FLAG_DIVERGING_PATHS, p);
    }
    
    if (n_rev > 1) {
        path_add_stop_reason(FIRST, PATH_FLAG_CONVERGING_PATHS, p);
    }
        
	if(n_rev  > 1 && n_fwd_f > 1 ){
		path_add_stop_reason(FIRST, PATH_FLAG_IS_DOUBLE_Y,p);
	}
    
    if(n_rev_f > 1){
        path_add_stop_reason(LAST, PATH_FLAG_CONVERGING_PATHS, p);
    }
    
    if(n_fwd_f > 1){
        path_add_stop_reason(LAST, PATH_FLAG_DIVERGING_PATHS, p);
    }
	
	
}