Commit 78f2e9b4 authored by Federico Ciuffardi's avatar Federico Ciuffardi
Browse files

collapsed working, without keeping local mins

parent 34b3bcf2
......@@ -215,9 +215,9 @@ struct collapsedGraph : genericGraph<graph> {
// get
pos get_uncollapsed_neighbor(pos p, pos dir) {
for (p += dir; !is_uncollapsed(p); p += dir){
cout<<p<<endl;
//cout<<p<<endl;
if(!is_elem(full_graph, p)){
cout<<"warning: "<<p<<endl;
//cout<<"warning: "<<p<<endl;
exit(1);
}
}
......@@ -228,7 +228,7 @@ struct collapsedGraph : genericGraph<graph> {
// from: a---------b
// to: a----p----b
void uncollapse(pos p) {
cout<<"uncollapsing p "<<p<<endl;
//cout<<"uncollapsing p "<<p<<endl;
super::add_v(p);
// check for neighbors
......@@ -245,10 +245,10 @@ struct collapsedGraph : genericGraph<graph> {
// if p and the "neighbor of the neighbor of p" have the same dir and sense
if (angle(p - n) == angle(nn - n)) {
super::erase_e(n, nn);
super::add_e(n, p);
break;
}
}
super::add_e(n, p);
super::add_e(p, n);
}
}
......@@ -256,7 +256,7 @@ struct collapsedGraph : genericGraph<graph> {
// TODO
void collapse(pos p) {
cout<<"collapsing p "<<p<<endl;
//cout<<"collapsing p "<<p<<endl;
AdjacencyIterator it, it_end;
boost::tie(it, it_end) = super::neighbors(p);
......@@ -267,7 +267,6 @@ struct collapsedGraph : genericGraph<graph> {
super::add_e(n1, n2);
super::add_e(n2, n1);
super::erase_v(p);
cout<<"SE COLAPSO P: "<<p<<endl;
}
// uncollapse all collapsed of neighbors p
......@@ -277,7 +276,7 @@ struct collapsedGraph : genericGraph<graph> {
pos_set adj = all_adj(p);
for (auto it = adj.begin(); it != adj.end(); it++) {
pos n = *it;
if (is_collapsed(n) && (force || is_uncollapsable(p))) {
if (is_collapsed(n) && (force || is_uncollapsable(n))) {
uncollapse(n);
}
}
......@@ -297,7 +296,10 @@ struct collapsedGraph : genericGraph<graph> {
// Los vecinos de los vecinos de un nodo p, que se agrega o se remueve no van a colapsarse o descolapsarse. Solo los vecinos del grafo full.
void erase_v(pos p) {
cout<<"ENTRO AL ERASE V CON P: "<<p<<endl;
if (!is_elem(full_graph, p)) {
return;
}
//cout<<"ENTRO AL ERASE V CON P: "<<p<<endl;
// 0. erase from uncollapsed
full_graph.erase(p);
......@@ -319,10 +321,6 @@ struct collapsedGraph : genericGraph<graph> {
// if p and the "neighbor of the neighbor of p" have the same dir and sense
if (angle(p - n) == angle(nn - n)) {
super::erase_e(n, nn);
// if is not adj of p, i have to delete nn->n
if(adj_p.find(nn) == adj_p.end()){
super::erase_e(nn, n);
}
break;
}
}
......@@ -338,7 +336,7 @@ struct collapsedGraph : genericGraph<graph> {
}
void add_v(pos p) {
cout<<"ENTRO AL ADD V CON P: "<<p<<endl;
//cout<<"ENTRO AL ADD V CON P: "<<p<<endl;
if (is_elem(full_graph, p)) {
/// update local min
/*if(is_local_min[p]){
......@@ -355,15 +353,15 @@ struct collapsedGraph : genericGraph<graph> {
// TODO may not be true (adding an aleardy added)
// 0. uncolloapse collapsed neighbors of p
cout<<"PASO 0 CON P: "<<p<<endl;
//cout<<"PASO 0 CON P: "<<p<<endl;
uncollapse_neighbors(p, true);
// 1. add to uncollapsed
cout<<"PASO 1 CON P: "<<p<<endl;
//cout<<"PASO 1 CON P: "<<p<<endl;
full_graph.insert(p);
// 2. connect all the neighbors of p (already done in step 1)
cout<<"PASO 2 CON P: "<<p<<endl;
//cout<<"PASO 2 CON P: "<<p<<endl;
super::add_v(p);
pos_set adj = full_neighbors(p);
......@@ -374,14 +372,14 @@ struct collapsedGraph : genericGraph<graph> {
}
// 3. collapse p if possible
cout<<"PASO 3 CON P: "<<p<<endl;
//cout<<"PASO 3 CON P: "<<p<<endl;
if(is_collapsable(p)){
collapse(p);
}
// 4. collapse neighbors of p if possible
cout<<"PASO 4 CON P: "<<p<<endl;
//cout<<"PASO 4 CON P: "<<p<<endl;
collapse_neighbors(p);
}
......
......@@ -273,14 +273,14 @@ void GVDIC::update_frontiers(vector<pos> unk_to_notunk) {
}
}
}
cout << "know_neighbors" << endl;
print_property(know_neighbors, gt);
cout << "frontiers" << endl;
print_property(frontiers, gt);
cout << "frontier_to_true" << endl;
print_property(frontier_to_true, gt);
cout << "frontier_to_false" << endl;
print_property(frontier_to_false, gt);
//cout << "know_neighbors" << endl;
//print_property(know_neighbors, gt);
//cout << "frontiers" << endl;
//print_property(frontiers, gt);
//cout << "frontier_to_true" << endl;
//print_property(frontier_to_true, gt);
//cout << "frontier_to_false" << endl;
//print_property(frontier_to_false, gt);
}
void GVDIC::set_consistent_borders(vector<pos> unk_to_free) {
......
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment