lemon/dfs.h
changeset 1830 ffd6d50fb155
parent 1773 ea5927cef15c
child 1865 dcefd1d1377f
equal deleted inserted replaced
19:5f1cdbf896bf 20:ba5c8f1e831f
  1047   dfs(const GR &g,typename GR::Node s=INVALID)
  1047   dfs(const GR &g,typename GR::Node s=INVALID)
  1048   {
  1048   {
  1049     return DfsWizard<DfsWizardBase<GR> >(g,s);
  1049     return DfsWizard<DfsWizardBase<GR> >(g,s);
  1050   }
  1050   }
  1051 
  1051 
       
  1052 #ifdef DOXYGEN
  1052   /// \brief Visitor class for dfs.
  1053   /// \brief Visitor class for dfs.
  1053   ///  
  1054   ///  
  1054   /// It gives a simple interface for a functional interface for dfs 
  1055   /// It gives a simple interface for a functional interface for dfs 
  1055   /// traversal. The traversal on a linear data structure. 
  1056   /// traversal. The traversal on a linear data structure. 
  1056   template <typename _Graph>
  1057   template <typename _Graph>
  1082     /// already discovered.
  1083     /// already discovered.
  1083     void examine(const Edge& edge) {}
  1084     void examine(const Edge& edge) {}
  1084     /// \brief Called for the source node of the dfs.
  1085     /// \brief Called for the source node of the dfs.
  1085     /// 
  1086     /// 
  1086     /// It is called for the source node of the dfs.
  1087     /// It is called for the source node of the dfs.
  1087     void start(const Node&) {}
  1088     void start(const Node& node) {}
  1088     /// \brief Called when we leave the source node of the dfs.
  1089     /// \brief Called when we leave the source node of the dfs.
  1089     /// 
  1090     /// 
  1090     /// It is called when we leave the source node of the dfs.
  1091     /// It is called when we leave the source node of the dfs.
       
  1092     void stop(const Node& node) {}
       
  1093 
       
  1094   };
       
  1095 #else
       
  1096   template <typename _Graph>
       
  1097   struct DfsVisitor {
       
  1098     typedef _Graph Graph;
       
  1099     typedef typename Graph::Edge Edge;
       
  1100     typedef typename Graph::Node Node;
       
  1101     void discover(const Edge&) {}
       
  1102     void reach(const Node&) {}
       
  1103     void backtrack(const Edge&) {}
       
  1104     void leave(const Node&) {}
       
  1105     void examine(const Edge&) {}
       
  1106     void start(const Node&) {}
  1091     void stop(const Node&) {}
  1107     void stop(const Node&) {}
  1092 
  1108 
  1093     template <typename _Visitor>
  1109     template <typename _Visitor>
  1094     struct Constraints {
  1110     struct Constraints {
  1095       void constraints() {
  1111       void constraints() {
  1104 	visitor.stop(edge);
  1120 	visitor.stop(edge);
  1105       }
  1121       }
  1106       _Visitor& visitor;
  1122       _Visitor& visitor;
  1107     };
  1123     };
  1108   };
  1124   };
       
  1125 #endif
  1109 
  1126 
  1110   /// \brief Default traits class of DfsVisit class.
  1127   /// \brief Default traits class of DfsVisit class.
  1111   ///
  1128   ///
  1112   /// Default traits class of DfsVisit class.
  1129   /// Default traits class of DfsVisit class.
  1113   /// \param _Graph Graph type.
  1130   /// \param _Graph Graph type.