SHARE
TWEET

Untitled

a guest May 19th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. std::vector<std::vector<int>> AEGraph::possible_double_cuts() const {
  2.     /*folosim un stack pentru a introduce fiecare subgraf,
  3.       in cazul in care nu are atomi si nu este SA atunci se poate face
  4.       operatia de double cut*/
  5.     std::vector<std::vector<int>> paths;
  6.     std::stack<AEGraph> my_stack;
  7.     my_stack.push(*this);
  8.     while(!my_stack.empty()) {
  9.         auto aux = my_stack.top();
  10.         my_stack.pop();
  11.         if(!aux.is_SA && aux.num_atoms() == 0) {
  12.             if(get_paths_to(aux).size())
  13.                 /*in cazul in care  exista path-ul, il introducem drept
  14.                   path pentru subgraful corect*/
  15.             paths.push_back(get_paths_to(aux)[get_paths_to(aux).size() - 1]);
  16.         }
  17.         for (int i = 0; i < aux.num_subgraphs(); ++i) {
  18.             my_stack.push(aux.subgraphs[i]);
  19.         }
  20.     }
  21.     return paths;
  22.  }
  23.  
  24. AEGraph AEGraph::double_cut(std::vector<int> where) const {
  25.     std::string string_final= {};
  26.  
  27.     auto aux = this->subgraphs[where[0]];
  28.  
  29.     /*varianta originala a grafului*/
  30.     string_final = this->repr();
  31.  
  32.     for (unsigned int i = 1; i < where.size(); i++){
  33.         aux = aux.subgraphs[where[i]];
  34.     }
  35.  
  36.     /*stringul subgrafului caruia trebuie sa i se aplice double cut*/
  37.     std::string string_gresit = aux.repr();
  38.  
  39.     /*o copie a stringului anterior din care stergem 2 perechi de paranteze*/
  40.     std::string string_corect = string_gresit;
  41.  
  42.     string_corect.erase(string_corect.begin(), string_corect.begin() + 2);
  43.     string_corect.erase(string_corect.end() - 2, string_corect.end());
  44.  
  45.     /*inlocuim string-ul gresit cu cel modificat in interiorul stringului
  46.      grafului original*/
  47.     int found = string_final.find(string_gresit);
  48.     string_final.replace(found, string_gresit.length(), string_corect);
  49.  
  50.     return AEGraph(string_final);
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top