Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:38

0001 /* This software is distributed under the GNU Lesser General Public License */
0002 //==========================================================================
0003 //
0004 //   components.cpp
0005 //
0006 //==========================================================================
0007 // $Id: components.cpp,v 1.5 2001/11/07 13:58:09 pick Exp $
0008 
0009 #include <GTL/components.h>
0010 
0011 #ifdef __GTL_MSVCC
0012 #   ifdef _DEBUG
0013 #   ifndef SEARCH_MEMORY_LEAKS_ENABLED
0014 #   error SEARCH NOT ENABLED
0015 #   endif
0016 #   define new DEBUG_NEW
0017 #   undef THIS_FILE
0018     static char THIS_FILE[] = __FILE__;
0019 #   endif   // _DEBUG
0020 #endif  // __GTL_MSVCC
0021 
0022 __GTL_BEGIN_NAMESPACE
0023 
0024 components::components () : dfs ()
0025 {
0026     scan_whole_graph (true);
0027     num_of_components = 0;
0028 }
0029 
0030 void components::reset () 
0031 { 
0032     dfs::reset ();
0033     comp.erase (comp.begin(), comp.end());
0034     num_of_components = 0;
0035 }
0036 
0037 int components::check (graph& G) 
0038 {
0039     return G.is_undirected() && whole_graph && 
0040     dfs::check (G) == GTL_OK ? GTL_OK : GTL_ERROR;
0041 }
0042     
0043 
0044 //--------------------------------------------------------------------------
0045 //   Handler
0046 //--------------------------------------------------------------------------
0047 
0048 
0049 void components::new_start_handler (graph& G, node& st) 
0050 {
0051     li = comp.insert (comp.end(), 
0052     pair<list<node>,list<edge> > (list<node> (), list<edge> ()));
0053     (*li).first.push_back (st);
0054     ++num_of_components;
0055 }
0056 
0057 void components::before_recursive_call_handler (graph& G, edge& e, node& n)
0058 {
0059     (*li).first.push_back (n);
0060     // (*li).second.push_back (e);    
0061 }
0062 
0063 
0064 void components::old_adj_node_handler (graph& G, edge& e, node& n) 
0065 {
0066     node curr = n.opposite (e);
0067 
0068     //
0069     // Store backedges at lower endpoint
0070     //
0071 
0072     if (dfs_num (curr) > dfs_num (n)) { 
0073     (*li).second.push_back (e);    
0074     }
0075 }
0076 
0077 
0078 __GTL_END_NAMESPACE
0079 
0080 //--------------------------------------------------------------------------
0081 //   end of file
0082 //--------------------------------------------------------------------------