Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
gain-traverse.h
00001 /**************************************************************************
00002  * Copyright (c) 2001-2011 T. M. Murali                                   *
00003  * Copyright (c) 2011 Phillip Whisenhunt                                  *
00004  * Copyright (c) 2011 David Badger                                        *
00005  * Copyright (c) 2010 Jacqueline Addesa                                   *
00006  *                                                                        *
00007  * This file is part of Biorithm.                                         *
00008  *                                                                        *
00009  * Biorithm is free software: you can redistribute it and/or modify       *
00010  * it under the terms of the GNU General Public License as published by   *
00011  * the Free Software Foundation, either version 3 of the License, or      *
00012  * (at your option) any later version.                                    *
00013  *                                                                        *
00014  * Biorithm is distributed in the hope that it will be useful,            *
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00017  * GNU General Public License for more details.                           *
00018  *                                                                        *
00019  * You should have received a copy of the GNU General Public License      *
00020  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00021  *                                                                        *
00022  **************************************************************************/
00023 
00032 // Purpose: visitors that traverse MyGainGraphs.
00033 
00034 
00035 #ifndef _GAIN_TRAVERSE_H
00036 #define _GAIN_TRAVERSE_H
00037 
00038 #include "bfs.h"
00039 #include "dfs.h"
00040 #include "gain.h"
00041 
00042 class  MyGainReduce2DFSVisitor: public MyDefaultDFSVisitor
00043 {
00044 private:
00045   MyGainGraph component;
00046   const map< MyNodeId, MyGainTriStateType > *nodeStateTypes;
00047   set< MyGainTriStateType > stateTypesSeen;
00048   MyNodeIdSet nodesInHypotheticalStateSeen;
00049   
00050 public:
00051 
00052   virtual ~MyGainReduce2DFSVisitor()
00053     {}
00054 
00055   // don't define this method without arguments.
00056 //  virtual void initialise();
00057   
00058   virtual void initialise(const map< MyNodeId, MyGainTriStateType > *states)
00059     {
00060       component.clear();
00061       nodeStateTypes = states;
00062       stateTypesSeen.clear();
00063       nodesInHypotheticalStateSeen.clear();
00064     }   
00065 
00066   virtual MyGainGraph &getComponent()
00067     {
00068       return(component);
00069     }
00070 
00071   virtual set< MyGainTriStateType > getStateTypesSeen() const
00072     {
00073       return(stateTypesSeen);
00074     }
00075 
00077   virtual void addNodesInHypotheticalStateSeen(MyNodeIdSet &nodes) const
00078     {
00079       nodes.insert(nodesInHypotheticalStateSeen.begin(), nodesInHypotheticalStateSeen.end());
00080     }
00081   
00082 };
00083 
00084 // traverse a connected subgraph of the graph starting at a node (it
00085 // should be a node predicted to have a function) until i reach a
00086 // clamped node. also compute the connected component as i go. add the
00087 // clamped nodes to the component. this component should be the
00088 // propagation graph for the node.
00089 class  MyOneVersusAllGainAlgoPropagationBFSVisitor: public MyDefaultBFSVisitor
00090 {
00091 private:
00092   MyGainGraph component;
00093   const map< MyNodeId, MyGainTriStateInfo > *nodeStates;
00094 
00095 public:
00096     
00097   virtual ~MyOneVersusAllGainAlgoPropagationBFSVisitor()
00098     {}
00099 
00100   // don't define this method without arguments.
00101 //  virtual void initialise();
00102   
00103   virtual void initialise(const map< MyNodeId, MyGainTriStateInfo > *states)
00104     {
00105       component.clear();
00106       nodeStates = states;
00107     }
00108 
00109   virtual MyGainGraph &getComponent()
00110     {
00111       return(component);
00112     }
00113   
00114 };
00115 
00116 
00117 #endif // _GAIN_TRAVERSE_H 
 All Classes Functions Variables Typedefs Friends