pq_tree.h

00001 //==========================================================================
00002 //
00003 //   pq_tree.h
00004 //
00005 //==========================================================================
00006 // $Id: pq_tree.h,v 1.20 2008/02/03 18:17:08 chris Exp $
00007 
00008 #ifndef PQ_TREE_H
00009 #define PQ_TREE_H
00010 
00011 #include <GTL/GTL.h>
00012 #include <GTL/pq_node.h>
00013 #include <GTL/embedding.h>
00014 #include <GTL/debug.h>
00015 
00016 #include <list>
00017 #include <iostream>
00018 
00019 __GTL_BEGIN_NAMESPACE
00020     
00028 class GTL_EXTERN pq_tree 
00029 {
00030 public:
00034     typedef symlist<pq_node*> sons_list;
00035 
00039     typedef symlist<pq_node*>::iterator sons_iterator;
00040 
00044     pq_tree() : root(0), pert_root(0), pseudo(0), fail(0)
00045     {
00046     }
00047     
00056     pq_tree(int id, node n, const list<pq_leaf*>& le);
00057 
00061     ~pq_tree();
00062 
00079     bool reduce(list<pq_leaf*>& leaves);
00080 
00099     void replace_pert(int id,
00100                       node n,
00101                       const list<pq_leaf*>& le,
00102                       planar_embedding* em = 0,
00103                       list<direction_indicator>* dirs = 0);
00104     
00118     void get_frontier (planar_embedding& em, list<direction_indicator>& dirs);
00119 
00124     void reset ();
00125 
00132     pq_node* get_fail()
00133     {
00134         return fail;
00135     }
00136 
00144     bool is_fail_root()
00145     {
00146         return failed_at_root;
00147     }
00148 
00158     sons_iterator remove_dir_ind(q_node* q_fail, sons_iterator s_it);
00159 
00168     bool integrity_check () const;
00169 
00170 //    p_node* insert_P (pq_node*, sons_list&);
00171 
00172 //    q_node* insert_Q (pq_node*, sons_list&);
00173 
00174 //    pq_leaf* insert_leaf (pq_node*);
00175 
00176 //    void insert (pq_node*, pq_node*);
00177 private:
00190     bool bubble_up (list<pq_leaf*>& leaves);
00191     
00202     void dfs(pq_node* p,
00203              planar_embedding& em,
00204              list<direction_indicator>& dirs);
00205 
00217     pq_node* leads_to_blocked(pq_node* le);
00218 
00219     
00232     bool leads_to(pq_node* le, pq_node* other);
00233 
00234 
00246     pq_node* where_bubble_up_failed(list<pq_leaf*>& leaves); 
00247 
00248 
00257     pq_node* blocked_in_subtree(pq_node* n);
00258 
00259 
00260     //
00261     // Template Matchings
00262     //
00263 
00264     //---------------------------------------------------------- P-Templates
00265     
00270     bool P1 (p_node* x, bool);
00271 
00276     bool P2 (p_node* x);
00277 
00282     bool P3 (p_node* x);
00283 
00288     bool P4 (p_node* x);
00289 
00294     bool P5 (p_node* x);
00295 
00300     bool P6 (p_node* x);
00301 
00302     //---------------------------------------------------------- Q-Templates
00303     
00308     bool Q1 (q_node* x, bool);
00309 
00314     bool Q2 (q_node* x, bool);
00315 
00320     bool Q3 (q_node* x);
00321 
00322 
00323     //
00324     // Data
00325     //
00326 
00331     list<pq_node*> clear_me;
00332 
00337     pq_node* root;
00338 
00343     pq_node* pert_root;
00344 
00353     q_node* pseudo;
00354 
00359     pq_node* fail;
00360 
00365     bool failed_at_root;
00366 
00372     int pert_leaves_count;
00373 
00374     //
00375     // Friends
00376     //
00377 
00382     GTL_EXTERN friend ostream& operator<< (ostream&, const pq_tree&);
00383 };
00384 
00385 __GTL_END_NAMESPACE
00386 
00387 #endif
00388 
00389 //--------------------------------------------------------------------------
00390 //   end of file
00391 //--------------------------------------------------------------------------