G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 9th, 2020 139 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const char* vizFileName = "tree.gpvz";
  2.  
  3.  
  4.     void showTreeIter( AVLTreeNode *cur, std::ofstream &out ){
  5.         if( !cur ) return;
  6.  
  7.         out << reinterpret_cast <long> (cur) << " [ label = \"" << cur->getKey() << "\" ]\n";
  8.  
  9.         if(cur->getLeft()) out << reinterpret_cast <long> (cur) << " -> " << reinterpret_cast <long> (cur->getLeft());
  10.         if(cur->getRight()) out << reinterpret_cast <long> (cur) << " -> " << reinterpret_cast <long> (cur->getRight());
  11.  
  12.         showTreeIter(cur->getRight(), out);
  13.  
  14.         showTreeIter(cur->getRight(), out);
  15.  
  16.     }
  17.  
  18.     void showTree(){
  19.         std::ofstream out;
  20.         out.open( vizFileName );
  21.         out << "digraph {\n";
  22.  
  23.         showTreeIter(root, out);
  24.  
  25.         out << "}\n";
  26.         out.close();
  27.         system( "dot tree.gpvz -T png -o tree_image.png" );
  28.         system( "eog tree_image.png" );
  29.     }
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