topsort.h

00001 //==========================================================================
00002 //
00003 //   topsort.h 
00004 //
00005 //==========================================================================
00006 // $Id: topsort.h,v 1.8 2000/09/11 07:36:43 raitner Exp $
00007 
00008 #ifndef GTL_TOPSORT
00009 #define GTL_TOPSORT
00010 
00011 #include <GTL/GTL.h>
00012 #include <GTL/dfs.h>
00013 
00014 __GTL_BEGIN_NAMESPACE
00015 
00034 class GTL_EXTERN topsort : public dfs 
00035 {
00036 public:
00042     topsort () : dfs () {whole_graph = true; acyclic = true;}
00043 
00050     int top_num (const node& n) const 
00051         { return top_numbers[n]; }
00052 
00058     bool is_acyclic () const
00059         { return acyclic; }
00060 
00064     typedef list<node>::const_iterator topsort_iterator;
00065 
00071     topsort_iterator top_order_begin() const
00072         { return top_order.begin(); }
00073 
00079     topsort_iterator top_order_end() const
00080         { return top_order.end(); }
00081 
00094     virtual int check (graph& G);
00095 
00100     virtual void reset ();
00101 
00105     virtual void init_handler (graph& G);
00106 
00110     virtual void leave_handler (graph&, node&, node&);
00111 
00115     virtual void old_adj_node_handler (graph&, edge&, node&);
00116 
00117 protected:
00121     int act_top_num;
00125     node_map<int> top_numbers;
00129     list<node> top_order;
00133     bool acyclic;
00134 };
00135 
00136 __GTL_END_NAMESPACE
00137 
00138 #endif // GTL_TOPSORT
00139 
00140 //--------------------------------------------------------------------------
00141 //   end of file
00142 //--------------------------------------------------------------------------