//-------------------------------------------------------- //update graph "G" when delete edge "te" from graph void change_graph_as_del_edge(leda_edge& te, GRAPH<int, int>& G) { leda_node source_node=G.source(te); leda_node target_node=G.target(te); leda_edge e; //connect source node with sink if the node's outdegree ==1 if(G.outdeg(source_node)==1){ e=G.new_edge(source_node, G.last_node()); G.assign(e, G[te]); } //connect target node with source if the node's indegree ==1 if(G.indeg(target_node)==1){ e=G.new_edge(G.first_node(), target_node); G.assign(e, 0); } //delete original edge G.del_edge(te); }
void Hv_Matrix::update_matrix(int i, int j, char x, GRAPH<int, int>& G, leda_edge& e) { leda_edge old_e; if(i < j) { if(x=='H') { if(triangle_matrix[i][j-i-1].direction!=H){ //delete old edge in the graph old_e=triangle_matrix[i][j-i-1].ed; G.del_edge(old_e); //update matrix triangle_matrix[i][j-i-1].direction=H; triangle_matrix[i][j-i-1].ed=e; } else{ cout<<"update matrix error of h edge <"<<i<<"," <<j<<">"<<endl; exit(0); } } else if(x=='V') { if(triangle_matrix[i][j-i-1].direction!=V) { //delete old edge in the graph old_e=triangle_matrix[i][j-i-1].ed; G.del_edge(old_e); //update matrix triangle_matrix[i][j-i-1].direction=V; triangle_matrix[i][j-i-1].ed=e; } else{ cout<<"update matrix error of v edge <"<<i<<"," <<j<<">"<<endl; exit(0); } } else error_message("update matrix error (not H or V)!!!"); } else { if(x=='H') { if(triangle_matrix[j][i-j-1].direction!=h) { //delete old edge in the graph old_e=triangle_matrix[j][i-j-1].ed; G.del_edge(old_e); //update matrix triangle_matrix[j][i-j-1].ed=e; triangle_matrix[j][i-j-1].direction=h; } else{ cout<<"update matrix error of h edge <"<<j<<"," <<i<<">"<<endl; exit(0); } } else if(x=='V') { if(triangle_matrix[j][i-j-1].direction!=v) { //delete old edge in the graph old_e=triangle_matrix[j][i-j-1].ed; G.del_edge(old_e); //update matrix triangle_matrix[j][i-j-1].direction=v; triangle_matrix[j][i-j-1].ed=e; } else{ cout<<"update matrix error of v edge <"<<j<<"," <<i<<">"<<endl; exit(0); } } else error_message("update matrix error (not H or V)!!!"); } }