0
                         4
                         0
                     
                 
                    | ... | ... | 
		@@ -209,136 +209,135 @@  | 
| 209 | 209 | 
		}  | 
| 210 | 210 | 
		      if(!_reached) {
	 | 
| 211 | 211 | 
		local_reached = true;  | 
| 212 | 212 | 
		_reached = Traits::createReachedMap(*G);  | 
| 213 | 213 | 
		}  | 
| 214 | 214 | 
		      if(!_processed) {
	 | 
| 215 | 215 | 
		local_processed = true;  | 
| 216 | 216 | 
		_processed = Traits::createProcessedMap(*G);  | 
| 217 | 217 | 
		}  | 
| 218 | 218 | 
		}  | 
| 219 | 219 | 
		 | 
| 220 | 220 | 
		protected:  | 
| 221 | 221 | 
		 | 
| 222 | 222 | 
		    Bfs() {}
	 | 
| 223 | 223 | 
		 | 
| 224 | 224 | 
		public:  | 
| 225 | 225 | 
		 | 
| 226 | 226 | 
		typedef Bfs Create;  | 
| 227 | 227 | 
		 | 
| 228 | 228 | 
		///\name Named template parameters  | 
| 229 | 229 | 
		 | 
| 230 | 230 | 
		    ///@{
	 | 
| 231 | 231 | 
		 | 
| 232 | 232 | 
		template <class T>  | 
| 233 | 
		struct  | 
|
| 233 | 
		    struct SetPredMapTraits : public Traits {
	 | 
|
| 234 | 234 | 
		typedef T PredMap;  | 
| 235 | 235 | 
		static PredMap *createPredMap(const Digraph &)  | 
| 236 | 236 | 
		      {
	 | 
| 237 | 237 | 
		throw UninitializedParameter();  | 
| 238 | 238 | 
		}  | 
| 239 | 239 | 
		};  | 
| 240 | 240 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 241 | 241 | 
		///\ref PredMap type.  | 
| 242 | 242 | 
		///  | 
| 243 | 243 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 244 | 244 | 
		///\ref PredMap type.  | 
| 245 | 245 | 
		template <class T>  | 
| 246 | 
		    struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {
	 | 
|
| 247 | 
		typedef Bfs< Digraph, DefPredMapTraits<T> > Create;  | 
|
| 246 | 
		    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
	 | 
|
| 247 | 
		typedef Bfs< Digraph, SetPredMapTraits<T> > Create;  | 
|
| 248 | 248 | 
		};  | 
| 249 | 249 | 
		 | 
| 250 | 250 | 
		template <class T>  | 
| 251 | 
		struct  | 
|
| 251 | 
		    struct SetDistMapTraits : public Traits {
	 | 
|
| 252 | 252 | 
		typedef T DistMap;  | 
| 253 | 253 | 
		static DistMap *createDistMap(const Digraph &)  | 
| 254 | 254 | 
		      {
	 | 
| 255 | 255 | 
		throw UninitializedParameter();  | 
| 256 | 256 | 
		}  | 
| 257 | 257 | 
		};  | 
| 258 | 258 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 259 | 259 | 
		///\ref DistMap type.  | 
| 260 | 260 | 
		///  | 
| 261 | 261 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 262 | 262 | 
		///\ref DistMap type.  | 
| 263 | 263 | 
		template <class T>  | 
| 264 | 
		    struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {
	 | 
|
| 265 | 
		typedef Bfs< Digraph, DefDistMapTraits<T> > Create;  | 
|
| 264 | 
		    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
	 | 
|
| 265 | 
		typedef Bfs< Digraph, SetDistMapTraits<T> > Create;  | 
|
| 266 | 266 | 
		};  | 
| 267 | 267 | 
		 | 
| 268 | 268 | 
		template <class T>  | 
| 269 | 
		struct  | 
|
| 269 | 
		    struct SetReachedMapTraits : public Traits {
	 | 
|
| 270 | 270 | 
		typedef T ReachedMap;  | 
| 271 | 271 | 
		static ReachedMap *createReachedMap(const Digraph &)  | 
| 272 | 272 | 
		      {
	 | 
| 273 | 273 | 
		throw UninitializedParameter();  | 
| 274 | 274 | 
		}  | 
| 275 | 275 | 
		};  | 
| 276 | 276 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 277 | 277 | 
		///\ref ReachedMap type.  | 
| 278 | 278 | 
		///  | 
| 279 | 279 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 280 | 280 | 
		///\ref ReachedMap type.  | 
| 281 | 281 | 
		template <class T>  | 
| 282 | 
		    struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {
	 | 
|
| 283 | 
		typedef Bfs< Digraph, DefReachedMapTraits<T> > Create;  | 
|
| 282 | 
		    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
	 | 
|
| 283 | 
		typedef Bfs< Digraph, SetReachedMapTraits<T> > Create;  | 
|
| 284 | 284 | 
		};  | 
| 285 | 285 | 
		 | 
| 286 | 286 | 
		template <class T>  | 
| 287 | 
		struct  | 
|
| 287 | 
		    struct SetProcessedMapTraits : public Traits {
	 | 
|
| 288 | 288 | 
		typedef T ProcessedMap;  | 
| 289 | 289 | 
		static ProcessedMap *createProcessedMap(const Digraph &)  | 
| 290 | 290 | 
		      {
	 | 
| 291 | 291 | 
		throw UninitializedParameter();  | 
| 292 | 292 | 
		}  | 
| 293 | 293 | 
		};  | 
| 294 | 294 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 295 | 295 | 
		///\ref ProcessedMap type.  | 
| 296 | 296 | 
		///  | 
| 297 | 297 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 298 | 298 | 
		///\ref ProcessedMap type.  | 
| 299 | 299 | 
		template <class T>  | 
| 300 | 
		    struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits<T> > {
	 | 
|
| 301 | 
		typedef Bfs< Digraph, DefProcessedMapTraits<T> > Create;  | 
|
| 300 | 
		    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
	 | 
|
| 301 | 
		typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create;  | 
|
| 302 | 302 | 
		};  | 
| 303 | 303 | 
		 | 
| 304 | 
		struct  | 
|
| 304 | 
		    struct SetStandardProcessedMapTraits : public Traits {
	 | 
|
| 305 | 305 | 
		typedef typename Digraph::template NodeMap<bool> ProcessedMap;  | 
| 306 | 306 | 
		static ProcessedMap *createProcessedMap(const Digraph &g)  | 
| 307 | 307 | 
		      {
	 | 
| 308 | 308 | 
		return new ProcessedMap(g);  | 
| 309 | 309 | 
		}  | 
| 310 | 310 | 
		};  | 
| 311 | 311 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 312 | 312 | 
		///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.  | 
| 313 | 313 | 
		///  | 
| 314 | 314 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 315 | 315 | 
		///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.  | 
| 316 | 316 | 
		///If you don't set it explicitly, it will be automatically allocated.  | 
| 317 | 
		template <class T>  | 
|
| 318 | 
		struct DefProcessedMapToBeDefaultMap :  | 
|
| 319 | 
		      public Bfs< Digraph, DefDigraphProcessedMapTraits> {
	 | 
|
| 320 | 
		typedef Bfs< Digraph, DefDigraphProcessedMapTraits> Create;  | 
|
| 317 | 
		struct SetStandardProcessedMap :  | 
|
| 318 | 
		      public Bfs< Digraph, SetStandardProcessedMapTraits > {
	 | 
|
| 319 | 
		typedef Bfs< Digraph, SetStandardProcessedMapTraits > Create;  | 
|
| 321 | 320 | 
		};  | 
| 322 | 321 | 
		 | 
| 323 | 322 | 
		///@}  | 
| 324 | 323 | 
		 | 
| 325 | 324 | 
		public:  | 
| 326 | 325 | 
		 | 
| 327 | 326 | 
		///Constructor.  | 
| 328 | 327 | 
		 | 
| 329 | 328 | 
		///Constructor.  | 
| 330 | 329 | 
		///\param g The digraph the algorithm runs on.  | 
| 331 | 330 | 
		Bfs(const Digraph &g) :  | 
| 332 | 331 | 
		G(&g),  | 
| 333 | 332 | 
		_pred(NULL), local_pred(false),  | 
| 334 | 333 | 
		_dist(NULL), local_dist(false),  | 
| 335 | 334 | 
		_reached(NULL), local_reached(false),  | 
| 336 | 335 | 
		_processed(NULL), local_processed(false)  | 
| 337 | 336 | 
		    { }
	 | 
| 338 | 337 | 
		 | 
| 339 | 338 | 
		///Destructor.  | 
| 340 | 339 | 
		~Bfs()  | 
| 341 | 340 | 
		    {
	 | 
| 342 | 341 | 
		if(local_pred) delete _pred;  | 
| 343 | 342 | 
		if(local_dist) delete _dist;  | 
| 344 | 343 | 
		if(local_reached) delete _reached;  | 
| ... | ... | 
		@@ -1044,117 +1043,117 @@  | 
| 1044 | 1043 | 
		alg.run(Base::_source);  | 
| 1045 | 1044 | 
		}  | 
| 1046 | 1045 | 
		 | 
| 1047 | 1046 | 
		///Runs BFS algorithm from the given node.  | 
| 1048 | 1047 | 
		 | 
| 1049 | 1048 | 
		///Runs BFS algorithm from the given node.  | 
| 1050 | 1049 | 
		///\param s is the given source.  | 
| 1051 | 1050 | 
		void run(Node s)  | 
| 1052 | 1051 | 
		    {
	 | 
| 1053 | 1052 | 
		Base::_source=s;  | 
| 1054 | 1053 | 
		run();  | 
| 1055 | 1054 | 
		}  | 
| 1056 | 1055 | 
		 | 
| 1057 | 1056 | 
		/// Sets the source node, from which the Bfs algorithm runs.  | 
| 1058 | 1057 | 
		 | 
| 1059 | 1058 | 
		/// Sets the source node, from which the Bfs algorithm runs.  | 
| 1060 | 1059 | 
		/// \param s is the source node.  | 
| 1061 | 1060 | 
		BfsWizard<TR> &source(Node s)  | 
| 1062 | 1061 | 
		    {
	 | 
| 1063 | 1062 | 
		Base::_source=s;  | 
| 1064 | 1063 | 
		return *this;  | 
| 1065 | 1064 | 
		}  | 
| 1066 | 1065 | 
		 | 
| 1067 | 1066 | 
		template<class T>  | 
| 1068 | 
		struct  | 
|
| 1067 | 
		    struct SetPredMapBase : public Base {
	 | 
|
| 1069 | 1068 | 
		typedef T PredMap;  | 
| 1070 | 1069 | 
		      static PredMap *createPredMap(const Digraph &) { return 0; };
	 | 
| 1071 | 
		
  | 
|
| 1070 | 
		      SetPredMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1072 | 1071 | 
		};  | 
| 1073 | 1072 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1074 | 1073 | 
		///for setting \ref PredMap object.  | 
| 1075 | 1074 | 
		///  | 
| 1076 | 1075 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1077 | 1076 | 
		///for setting \ref PredMap object.  | 
| 1078 | 1077 | 
		template<class T>  | 
| 1079 | 
		BfsWizard<  | 
|
| 1078 | 
		BfsWizard<SetPredMapBase<T> > predMap(const T &t)  | 
|
| 1080 | 1079 | 
		    {
	 | 
| 1081 | 1080 | 
		Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1082 | 
		return BfsWizard<  | 
|
| 1081 | 
		return BfsWizard<SetPredMapBase<T> >(*this);  | 
|
| 1083 | 1082 | 
		}  | 
| 1084 | 1083 | 
		 | 
| 1085 | 1084 | 
		template<class T>  | 
| 1086 | 
		struct  | 
|
| 1085 | 
		    struct SetReachedMapBase : public Base {
	 | 
|
| 1087 | 1086 | 
		typedef T ReachedMap;  | 
| 1088 | 1087 | 
		      static ReachedMap *createReachedMap(const Digraph &) { return 0; };
	 | 
| 1089 | 
		
  | 
|
| 1088 | 
		      SetReachedMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1090 | 1089 | 
		};  | 
| 1091 | 1090 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1092 | 1091 | 
		///for setting \ref ReachedMap object.  | 
| 1093 | 1092 | 
		///  | 
| 1094 | 1093 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1095 | 1094 | 
		///for setting \ref ReachedMap object.  | 
| 1096 | 1095 | 
		template<class T>  | 
| 1097 | 
		BfsWizard<  | 
|
| 1096 | 
		BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)  | 
|
| 1098 | 1097 | 
		    {
	 | 
| 1099 | 1098 | 
		Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1100 | 
		return BfsWizard<  | 
|
| 1099 | 
		return BfsWizard<SetReachedMapBase<T> >(*this);  | 
|
| 1101 | 1100 | 
		}  | 
| 1102 | 1101 | 
		 | 
| 1103 | 1102 | 
		template<class T>  | 
| 1104 | 
		struct  | 
|
| 1103 | 
		    struct SetProcessedMapBase : public Base {
	 | 
|
| 1105 | 1104 | 
		typedef T ProcessedMap;  | 
| 1106 | 1105 | 
		      static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
	 | 
| 1107 | 
		
  | 
|
| 1106 | 
		      SetProcessedMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1108 | 1107 | 
		};  | 
| 1109 | 1108 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1110 | 1109 | 
		///for setting \ref ProcessedMap object.  | 
| 1111 | 1110 | 
		///  | 
| 1112 | 1111 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1113 | 1112 | 
		///for setting \ref ProcessedMap object.  | 
| 1114 | 1113 | 
		template<class T>  | 
| 1115 | 
		BfsWizard<  | 
|
| 1114 | 
		BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)  | 
|
| 1116 | 1115 | 
		    {
	 | 
| 1117 | 1116 | 
		Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1118 | 
		return BfsWizard<  | 
|
| 1117 | 
		return BfsWizard<SetProcessedMapBase<T> >(*this);  | 
|
| 1119 | 1118 | 
		}  | 
| 1120 | 1119 | 
		 | 
| 1121 | 1120 | 
		template<class T>  | 
| 1122 | 
		struct  | 
|
| 1121 | 
		    struct SetDistMapBase : public Base {
	 | 
|
| 1123 | 1122 | 
		typedef T DistMap;  | 
| 1124 | 1123 | 
		      static DistMap *createDistMap(const Digraph &) { return 0; };
	 | 
| 1125 | 
		
  | 
|
| 1124 | 
		      SetDistMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1126 | 1125 | 
		};  | 
| 1127 | 1126 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1128 | 1127 | 
		///for setting \ref DistMap object.  | 
| 1129 | 1128 | 
		///  | 
| 1130 | 1129 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1131 | 1130 | 
		///for setting \ref DistMap object.  | 
| 1132 | 1131 | 
		template<class T>  | 
| 1133 | 
		BfsWizard<  | 
|
| 1132 | 
		BfsWizard<SetDistMapBase<T> > distMap(const T &t)  | 
|
| 1134 | 1133 | 
		    {
	 | 
| 1135 | 1134 | 
		Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1136 | 
		return BfsWizard<  | 
|
| 1135 | 
		return BfsWizard<SetDistMapBase<T> >(*this);  | 
|
| 1137 | 1136 | 
		}  | 
| 1138 | 1137 | 
		 | 
| 1139 | 1138 | 
		};  | 
| 1140 | 1139 | 
		 | 
| 1141 | 1140 | 
		///Function type interface for Bfs algorithm.  | 
| 1142 | 1141 | 
		 | 
| 1143 | 1142 | 
		/// \ingroup search  | 
| 1144 | 1143 | 
		///Function type interface for Bfs algorithm.  | 
| 1145 | 1144 | 
		///  | 
| 1146 | 1145 | 
		///This function also has several  | 
| 1147 | 1146 | 
		///\ref named-templ-func-param "named parameters",  | 
| 1148 | 1147 | 
		///they are declared as the members of class \ref BfsWizard.  | 
| 1149 | 1148 | 
		///The following  | 
| 1150 | 1149 | 
		///example shows how to use these parameters.  | 
| 1151 | 1150 | 
		///\code  | 
| 1152 | 1151 | 
		/// bfs(g,source).predMap(preds).run();  | 
| 1153 | 1152 | 
		///\endcode  | 
| 1154 | 1153 | 
		///\warning Don't forget to put the \ref BfsWizard::run() "run()"  | 
| 1155 | 1154 | 
		///to the end of the parameter list.  | 
| 1156 | 1155 | 
		///\sa BfsWizard  | 
| 1157 | 1156 | 
		///\sa Bfs  | 
| 1158 | 1157 | 
		template<class GR>  | 
| 1159 | 1158 | 
		BfsWizard<BfsWizardBase<GR> >  | 
| 1160 | 1159 | 
		bfs(const GR &g,typename GR::Node s=INVALID)  | 
| ... | ... | 
		@@ -1328,62 +1327,62 @@  | 
| 1328 | 1327 | 
		std::vector<typename Digraph::Node> _list;  | 
| 1329 | 1328 | 
		int _list_front, _list_back;  | 
| 1330 | 1329 | 
		 | 
| 1331 | 1330 | 
		///Creates the maps if necessary.  | 
| 1332 | 1331 | 
		///\todo Better memory allocation (instead of new).  | 
| 1333 | 1332 | 
		    void create_maps() {
	 | 
| 1334 | 1333 | 
		      if(!_reached) {
	 | 
| 1335 | 1334 | 
		local_reached = true;  | 
| 1336 | 1335 | 
		_reached = Traits::createReachedMap(*_digraph);  | 
| 1337 | 1336 | 
		}  | 
| 1338 | 1337 | 
		}  | 
| 1339 | 1338 | 
		 | 
| 1340 | 1339 | 
		protected:  | 
| 1341 | 1340 | 
		 | 
| 1342 | 1341 | 
		    BfsVisit() {}
	 | 
| 1343 | 1342 | 
		 | 
| 1344 | 1343 | 
		public:  | 
| 1345 | 1344 | 
		 | 
| 1346 | 1345 | 
		typedef BfsVisit Create;  | 
| 1347 | 1346 | 
		 | 
| 1348 | 1347 | 
		/// \name Named template parameters  | 
| 1349 | 1348 | 
		 | 
| 1350 | 1349 | 
		    ///@{
	 | 
| 1351 | 1350 | 
		template <class T>  | 
| 1352 | 
		struct  | 
|
| 1351 | 
		    struct SetReachedMapTraits : public Traits {
	 | 
|
| 1353 | 1352 | 
		typedef T ReachedMap;  | 
| 1354 | 1353 | 
		      static ReachedMap *createReachedMap(const Digraph &digraph) {
	 | 
| 1355 | 1354 | 
		throw UninitializedParameter();  | 
| 1356 | 1355 | 
		}  | 
| 1357 | 1356 | 
		};  | 
| 1358 | 1357 | 
		/// \brief \ref named-templ-param "Named parameter" for setting  | 
| 1359 | 1358 | 
		/// ReachedMap type.  | 
| 1360 | 1359 | 
		///  | 
| 1361 | 1360 | 
		/// \ref named-templ-param "Named parameter" for setting ReachedMap type.  | 
| 1362 | 1361 | 
		template <class T>  | 
| 1363 | 
		struct DefReachedMap : public BfsVisit< Digraph, Visitor,  | 
|
| 1364 | 
		                                            DefReachedMapTraits<T> > {
	 | 
|
| 1365 | 
		
  | 
|
| 1362 | 
		struct SetReachedMap : public BfsVisit< Digraph, Visitor,  | 
|
| 1363 | 
		                                            SetReachedMapTraits<T> > {
	 | 
|
| 1364 | 
		typedef BfsVisit< Digraph, Visitor, SetReachedMapTraits<T> > Create;  | 
|
| 1366 | 1365 | 
		};  | 
| 1367 | 1366 | 
		///@}  | 
| 1368 | 1367 | 
		 | 
| 1369 | 1368 | 
		public:  | 
| 1370 | 1369 | 
		 | 
| 1371 | 1370 | 
		/// \brief Constructor.  | 
| 1372 | 1371 | 
		///  | 
| 1373 | 1372 | 
		/// Constructor.  | 
| 1374 | 1373 | 
		///  | 
| 1375 | 1374 | 
		/// \param digraph The digraph the algorithm runs on.  | 
| 1376 | 1375 | 
		/// \param visitor The visitor object of the algorithm.  | 
| 1377 | 1376 | 
		BfsVisit(const Digraph& digraph, Visitor& visitor)  | 
| 1378 | 1377 | 
		: _digraph(&digraph), _visitor(&visitor),  | 
| 1379 | 1378 | 
		        _reached(0), local_reached(false) {}
	 | 
| 1380 | 1379 | 
		 | 
| 1381 | 1380 | 
		/// \brief Destructor.  | 
| 1382 | 1381 | 
		    ~BfsVisit() {
	 | 
| 1383 | 1382 | 
		if(local_reached) delete _reached;  | 
| 1384 | 1383 | 
		}  | 
| 1385 | 1384 | 
		 | 
| 1386 | 1385 | 
		/// \brief Sets the map that indicates which nodes are reached.  | 
| 1387 | 1386 | 
		///  | 
| 1388 | 1387 | 
		/// Sets the map that indicates which nodes are reached.  | 
| 1389 | 1388 | 
		/// If you don't use this function before calling \ref run(),  | 
| ... | ... | 
		@@ -209,136 +209,135 @@  | 
| 209 | 209 | 
		}  | 
| 210 | 210 | 
		      if(!_reached) {
	 | 
| 211 | 211 | 
		local_reached = true;  | 
| 212 | 212 | 
		_reached = Traits::createReachedMap(*G);  | 
| 213 | 213 | 
		}  | 
| 214 | 214 | 
		      if(!_processed) {
	 | 
| 215 | 215 | 
		local_processed = true;  | 
| 216 | 216 | 
		_processed = Traits::createProcessedMap(*G);  | 
| 217 | 217 | 
		}  | 
| 218 | 218 | 
		}  | 
| 219 | 219 | 
		 | 
| 220 | 220 | 
		protected:  | 
| 221 | 221 | 
		 | 
| 222 | 222 | 
		    Dfs() {}
	 | 
| 223 | 223 | 
		 | 
| 224 | 224 | 
		public:  | 
| 225 | 225 | 
		 | 
| 226 | 226 | 
		typedef Dfs Create;  | 
| 227 | 227 | 
		 | 
| 228 | 228 | 
		///\name Named template parameters  | 
| 229 | 229 | 
		 | 
| 230 | 230 | 
		    ///@{
	 | 
| 231 | 231 | 
		 | 
| 232 | 232 | 
		template <class T>  | 
| 233 | 
		struct  | 
|
| 233 | 
		    struct SetPredMapTraits : public Traits {
	 | 
|
| 234 | 234 | 
		typedef T PredMap;  | 
| 235 | 235 | 
		static PredMap *createPredMap(const Digraph &)  | 
| 236 | 236 | 
		      {
	 | 
| 237 | 237 | 
		throw UninitializedParameter();  | 
| 238 | 238 | 
		}  | 
| 239 | 239 | 
		};  | 
| 240 | 240 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 241 | 241 | 
		///\ref PredMap type.  | 
| 242 | 242 | 
		///  | 
| 243 | 243 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 244 | 244 | 
		///\ref PredMap type.  | 
| 245 | 245 | 
		template <class T>  | 
| 246 | 
		    struct DefPredMap : public Dfs<Digraph, DefPredMapTraits<T> > {
	 | 
|
| 247 | 
		typedef Dfs<Digraph, DefPredMapTraits<T> > Create;  | 
|
| 246 | 
		    struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > {
	 | 
|
| 247 | 
		typedef Dfs<Digraph, SetPredMapTraits<T> > Create;  | 
|
| 248 | 248 | 
		};  | 
| 249 | 249 | 
		 | 
| 250 | 250 | 
		template <class T>  | 
| 251 | 
		struct  | 
|
| 251 | 
		    struct SetDistMapTraits : public Traits {
	 | 
|
| 252 | 252 | 
		typedef T DistMap;  | 
| 253 | 253 | 
		static DistMap *createDistMap(const Digraph &)  | 
| 254 | 254 | 
		      {
	 | 
| 255 | 255 | 
		throw UninitializedParameter();  | 
| 256 | 256 | 
		}  | 
| 257 | 257 | 
		};  | 
| 258 | 258 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 259 | 259 | 
		///\ref DistMap type.  | 
| 260 | 260 | 
		///  | 
| 261 | 261 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 262 | 262 | 
		///\ref DistMap type.  | 
| 263 | 263 | 
		template <class T>  | 
| 264 | 
		    struct DefDistMap : public Dfs< Digraph, DefDistMapTraits<T> > {
	 | 
|
| 265 | 
		typedef Dfs<Digraph, DefDistMapTraits<T> > Create;  | 
|
| 264 | 
		    struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > {
	 | 
|
| 265 | 
		typedef Dfs<Digraph, SetDistMapTraits<T> > Create;  | 
|
| 266 | 266 | 
		};  | 
| 267 | 267 | 
		 | 
| 268 | 268 | 
		template <class T>  | 
| 269 | 
		struct  | 
|
| 269 | 
		    struct SetReachedMapTraits : public Traits {
	 | 
|
| 270 | 270 | 
		typedef T ReachedMap;  | 
| 271 | 271 | 
		static ReachedMap *createReachedMap(const Digraph &)  | 
| 272 | 272 | 
		      {
	 | 
| 273 | 273 | 
		throw UninitializedParameter();  | 
| 274 | 274 | 
		}  | 
| 275 | 275 | 
		};  | 
| 276 | 276 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 277 | 277 | 
		///\ref ReachedMap type.  | 
| 278 | 278 | 
		///  | 
| 279 | 279 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 280 | 280 | 
		///\ref ReachedMap type.  | 
| 281 | 281 | 
		template <class T>  | 
| 282 | 
		    struct DefReachedMap : public Dfs< Digraph, DefReachedMapTraits<T> > {
	 | 
|
| 283 | 
		typedef Dfs< Digraph, DefReachedMapTraits<T> > Create;  | 
|
| 282 | 
		    struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > {
	 | 
|
| 283 | 
		typedef Dfs< Digraph, SetReachedMapTraits<T> > Create;  | 
|
| 284 | 284 | 
		};  | 
| 285 | 285 | 
		 | 
| 286 | 286 | 
		template <class T>  | 
| 287 | 
		struct  | 
|
| 287 | 
		    struct SetProcessedMapTraits : public Traits {
	 | 
|
| 288 | 288 | 
		typedef T ProcessedMap;  | 
| 289 | 289 | 
		static ProcessedMap *createProcessedMap(const Digraph &)  | 
| 290 | 290 | 
		      {
	 | 
| 291 | 291 | 
		throw UninitializedParameter();  | 
| 292 | 292 | 
		}  | 
| 293 | 293 | 
		};  | 
| 294 | 294 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 295 | 295 | 
		///\ref ProcessedMap type.  | 
| 296 | 296 | 
		///  | 
| 297 | 297 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 298 | 298 | 
		///\ref ProcessedMap type.  | 
| 299 | 299 | 
		template <class T>  | 
| 300 | 
		    struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits<T> > {
	 | 
|
| 301 | 
		typedef Dfs< Digraph, DefProcessedMapTraits<T> > Create;  | 
|
| 300 | 
		    struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > {
	 | 
|
| 301 | 
		typedef Dfs< Digraph, SetProcessedMapTraits<T> > Create;  | 
|
| 302 | 302 | 
		};  | 
| 303 | 303 | 
		 | 
| 304 | 
		struct  | 
|
| 304 | 
		    struct SetStandardProcessedMapTraits : public Traits {
	 | 
|
| 305 | 305 | 
		typedef typename Digraph::template NodeMap<bool> ProcessedMap;  | 
| 306 | 306 | 
		static ProcessedMap *createProcessedMap(const Digraph &g)  | 
| 307 | 307 | 
		      {
	 | 
| 308 | 308 | 
		return new ProcessedMap(g);  | 
| 309 | 309 | 
		}  | 
| 310 | 310 | 
		};  | 
| 311 | 311 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 312 | 312 | 
		///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.  | 
| 313 | 313 | 
		///  | 
| 314 | 314 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 315 | 315 | 
		///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.  | 
| 316 | 316 | 
		///If you don't set it explicitly, it will be automatically allocated.  | 
| 317 | 
		template <class T>  | 
|
| 318 | 
		struct DefProcessedMapToBeDefaultMap :  | 
|
| 319 | 
		      public Dfs< Digraph, DefDigraphProcessedMapTraits> {
	 | 
|
| 320 | 
		typedef Dfs< Digraph, DefDigraphProcessedMapTraits> Create;  | 
|
| 317 | 
		struct SetStandardProcessedMap :  | 
|
| 318 | 
		      public Dfs< Digraph, SetStandardProcessedMapTraits > {
	 | 
|
| 319 | 
		typedef Dfs< Digraph, SetStandardProcessedMapTraits > Create;  | 
|
| 321 | 320 | 
		};  | 
| 322 | 321 | 
		 | 
| 323 | 322 | 
		///@}  | 
| 324 | 323 | 
		 | 
| 325 | 324 | 
		public:  | 
| 326 | 325 | 
		 | 
| 327 | 326 | 
		///Constructor.  | 
| 328 | 327 | 
		 | 
| 329 | 328 | 
		///Constructor.  | 
| 330 | 329 | 
		///\param g The digraph the algorithm runs on.  | 
| 331 | 330 | 
		Dfs(const Digraph &g) :  | 
| 332 | 331 | 
		G(&g),  | 
| 333 | 332 | 
		_pred(NULL), local_pred(false),  | 
| 334 | 333 | 
		_dist(NULL), local_dist(false),  | 
| 335 | 334 | 
		_reached(NULL), local_reached(false),  | 
| 336 | 335 | 
		_processed(NULL), local_processed(false)  | 
| 337 | 336 | 
		    { }
	 | 
| 338 | 337 | 
		 | 
| 339 | 338 | 
		///Destructor.  | 
| 340 | 339 | 
		~Dfs()  | 
| 341 | 340 | 
		    {
	 | 
| 342 | 341 | 
		if(local_pred) delete _pred;  | 
| 343 | 342 | 
		if(local_dist) delete _dist;  | 
| 344 | 343 | 
		if(local_reached) delete _reached;  | 
| ... | ... | 
		@@ -979,117 +978,117 @@  | 
| 979 | 978 | 
		alg.run(Base::_source);  | 
| 980 | 979 | 
		}  | 
| 981 | 980 | 
		 | 
| 982 | 981 | 
		///Runs DFS algorithm from the given node.  | 
| 983 | 982 | 
		 | 
| 984 | 983 | 
		///Runs DFS algorithm from the given node.  | 
| 985 | 984 | 
		///\param s is the given source.  | 
| 986 | 985 | 
		void run(Node s)  | 
| 987 | 986 | 
		    {
	 | 
| 988 | 987 | 
		Base::_source=s;  | 
| 989 | 988 | 
		run();  | 
| 990 | 989 | 
		}  | 
| 991 | 990 | 
		 | 
| 992 | 991 | 
		/// Sets the source node, from which the Dfs algorithm runs.  | 
| 993 | 992 | 
		 | 
| 994 | 993 | 
		/// Sets the source node, from which the Dfs algorithm runs.  | 
| 995 | 994 | 
		/// \param s is the source node.  | 
| 996 | 995 | 
		DfsWizard<TR> &source(Node s)  | 
| 997 | 996 | 
		    {
	 | 
| 998 | 997 | 
		Base::_source=s;  | 
| 999 | 998 | 
		return *this;  | 
| 1000 | 999 | 
		}  | 
| 1001 | 1000 | 
		 | 
| 1002 | 1001 | 
		template<class T>  | 
| 1003 | 
		struct  | 
|
| 1002 | 
		    struct SetPredMapBase : public Base {
	 | 
|
| 1004 | 1003 | 
		typedef T PredMap;  | 
| 1005 | 1004 | 
		      static PredMap *createPredMap(const Digraph &) { return 0; };
	 | 
| 1006 | 
		
  | 
|
| 1005 | 
		      SetPredMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1007 | 1006 | 
		};  | 
| 1008 | 1007 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1009 | 1008 | 
		///for setting \ref PredMap object.  | 
| 1010 | 1009 | 
		///  | 
| 1011 | 1010 | 
		///\ref named-templ-param "Named parameter"  | 
| 1012 | 1011 | 
		///for setting \ref PredMap object.  | 
| 1013 | 1012 | 
		template<class T>  | 
| 1014 | 
		DfsWizard<  | 
|
| 1013 | 
		DfsWizard<SetPredMapBase<T> > predMap(const T &t)  | 
|
| 1015 | 1014 | 
		    {
	 | 
| 1016 | 1015 | 
		Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1017 | 
		return DfsWizard<  | 
|
| 1016 | 
		return DfsWizard<SetPredMapBase<T> >(*this);  | 
|
| 1018 | 1017 | 
		}  | 
| 1019 | 1018 | 
		 | 
| 1020 | 1019 | 
		template<class T>  | 
| 1021 | 
		struct  | 
|
| 1020 | 
		    struct SetReachedMapBase : public Base {
	 | 
|
| 1022 | 1021 | 
		typedef T ReachedMap;  | 
| 1023 | 1022 | 
		      static ReachedMap *createReachedMap(const Digraph &) { return 0; };
	 | 
| 1024 | 
		
  | 
|
| 1023 | 
		      SetReachedMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1025 | 1024 | 
		};  | 
| 1026 | 1025 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1027 | 1026 | 
		///for setting \ref ReachedMap object.  | 
| 1028 | 1027 | 
		///  | 
| 1029 | 1028 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1030 | 1029 | 
		///for setting \ref ReachedMap object.  | 
| 1031 | 1030 | 
		template<class T>  | 
| 1032 | 
		DfsWizard<  | 
|
| 1031 | 
		DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)  | 
|
| 1033 | 1032 | 
		    {
	 | 
| 1034 | 1033 | 
		Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1035 | 
		return DfsWizard<  | 
|
| 1034 | 
		return DfsWizard<SetReachedMapBase<T> >(*this);  | 
|
| 1036 | 1035 | 
		}  | 
| 1037 | 1036 | 
		 | 
| 1038 | 1037 | 
		template<class T>  | 
| 1039 | 
		struct  | 
|
| 1038 | 
		    struct SetProcessedMapBase : public Base {
	 | 
|
| 1040 | 1039 | 
		typedef T ProcessedMap;  | 
| 1041 | 1040 | 
		      static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
	 | 
| 1042 | 
		
  | 
|
| 1041 | 
		      SetProcessedMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1043 | 1042 | 
		};  | 
| 1044 | 1043 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1045 | 1044 | 
		///for setting \ref ProcessedMap object.  | 
| 1046 | 1045 | 
		///  | 
| 1047 | 1046 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1048 | 1047 | 
		///for setting \ref ProcessedMap object.  | 
| 1049 | 1048 | 
		template<class T>  | 
| 1050 | 
		DfsWizard<  | 
|
| 1049 | 
		DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)  | 
|
| 1051 | 1050 | 
		    {
	 | 
| 1052 | 1051 | 
		Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1053 | 
		return DfsWizard<  | 
|
| 1052 | 
		return DfsWizard<SetProcessedMapBase<T> >(*this);  | 
|
| 1054 | 1053 | 
		}  | 
| 1055 | 1054 | 
		 | 
| 1056 | 1055 | 
		template<class T>  | 
| 1057 | 
		struct  | 
|
| 1056 | 
		    struct SetDistMapBase : public Base {
	 | 
|
| 1058 | 1057 | 
		typedef T DistMap;  | 
| 1059 | 1058 | 
		      static DistMap *createDistMap(const Digraph &) { return 0; };
	 | 
| 1060 | 
		
  | 
|
| 1059 | 
		      SetDistMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1061 | 1060 | 
		};  | 
| 1062 | 1061 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1063 | 1062 | 
		///for setting \ref DistMap object.  | 
| 1064 | 1063 | 
		///  | 
| 1065 | 1064 | 
		///\ref named-templ-param "Named parameter"  | 
| 1066 | 1065 | 
		///for setting \ref DistMap object.  | 
| 1067 | 1066 | 
		template<class T>  | 
| 1068 | 
		DfsWizard<  | 
|
| 1067 | 
		DfsWizard<SetDistMapBase<T> > distMap(const T &t)  | 
|
| 1069 | 1068 | 
		    {
	 | 
| 1070 | 1069 | 
		Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1071 | 
		return DfsWizard<  | 
|
| 1070 | 
		return DfsWizard<SetDistMapBase<T> >(*this);  | 
|
| 1072 | 1071 | 
		}  | 
| 1073 | 1072 | 
		 | 
| 1074 | 1073 | 
		};  | 
| 1075 | 1074 | 
		 | 
| 1076 | 1075 | 
		///Function type interface for Dfs algorithm.  | 
| 1077 | 1076 | 
		 | 
| 1078 | 1077 | 
		///\ingroup search  | 
| 1079 | 1078 | 
		///Function type interface for Dfs algorithm.  | 
| 1080 | 1079 | 
		///  | 
| 1081 | 1080 | 
		///This function also has several  | 
| 1082 | 1081 | 
		///\ref named-templ-func-param "named parameters",  | 
| 1083 | 1082 | 
		///they are declared as the members of class \ref DfsWizard.  | 
| 1084 | 1083 | 
		///The following  | 
| 1085 | 1084 | 
		///example shows how to use these parameters.  | 
| 1086 | 1085 | 
		///\code  | 
| 1087 | 1086 | 
		/// dfs(g,source).predMap(preds).run();  | 
| 1088 | 1087 | 
		///\endcode  | 
| 1089 | 1088 | 
		///\warning Don't forget to put the \ref DfsWizard::run() "run()"  | 
| 1090 | 1089 | 
		///to the end of the parameter list.  | 
| 1091 | 1090 | 
		///\sa DfsWizard  | 
| 1092 | 1091 | 
		///\sa Dfs  | 
| 1093 | 1092 | 
		template<class GR>  | 
| 1094 | 1093 | 
		DfsWizard<DfsWizardBase<GR> >  | 
| 1095 | 1094 | 
		dfs(const GR &g,typename GR::Node s=INVALID)  | 
| ... | ... | 
		@@ -1275,62 +1274,62 @@  | 
| 1275 | 1274 | 
		std::vector<typename Digraph::Arc> _stack;  | 
| 1276 | 1275 | 
		int _stack_head;  | 
| 1277 | 1276 | 
		 | 
| 1278 | 1277 | 
		///Creates the maps if necessary.  | 
| 1279 | 1278 | 
		///\todo Better memory allocation (instead of new).  | 
| 1280 | 1279 | 
		    void create_maps() {
	 | 
| 1281 | 1280 | 
		      if(!_reached) {
	 | 
| 1282 | 1281 | 
		local_reached = true;  | 
| 1283 | 1282 | 
		_reached = Traits::createReachedMap(*_digraph);  | 
| 1284 | 1283 | 
		}  | 
| 1285 | 1284 | 
		}  | 
| 1286 | 1285 | 
		 | 
| 1287 | 1286 | 
		protected:  | 
| 1288 | 1287 | 
		 | 
| 1289 | 1288 | 
		    DfsVisit() {}
	 | 
| 1290 | 1289 | 
		 | 
| 1291 | 1290 | 
		public:  | 
| 1292 | 1291 | 
		 | 
| 1293 | 1292 | 
		typedef DfsVisit Create;  | 
| 1294 | 1293 | 
		 | 
| 1295 | 1294 | 
		/// \name Named template parameters  | 
| 1296 | 1295 | 
		 | 
| 1297 | 1296 | 
		    ///@{
	 | 
| 1298 | 1297 | 
		template <class T>  | 
| 1299 | 
		struct  | 
|
| 1298 | 
		    struct SetReachedMapTraits : public Traits {
	 | 
|
| 1300 | 1299 | 
		typedef T ReachedMap;  | 
| 1301 | 1300 | 
		      static ReachedMap *createReachedMap(const Digraph &digraph) {
	 | 
| 1302 | 1301 | 
		throw UninitializedParameter();  | 
| 1303 | 1302 | 
		}  | 
| 1304 | 1303 | 
		};  | 
| 1305 | 1304 | 
		/// \brief \ref named-templ-param "Named parameter" for setting  | 
| 1306 | 1305 | 
		/// ReachedMap type.  | 
| 1307 | 1306 | 
		///  | 
| 1308 | 1307 | 
		/// \ref named-templ-param "Named parameter" for setting ReachedMap type.  | 
| 1309 | 1308 | 
		template <class T>  | 
| 1310 | 
		struct DefReachedMap : public DfsVisit< Digraph, Visitor,  | 
|
| 1311 | 
		                                            DefReachedMapTraits<T> > {
	 | 
|
| 1312 | 
		
  | 
|
| 1309 | 
		struct SetReachedMap : public DfsVisit< Digraph, Visitor,  | 
|
| 1310 | 
		                                            SetReachedMapTraits<T> > {
	 | 
|
| 1311 | 
		typedef DfsVisit< Digraph, Visitor, SetReachedMapTraits<T> > Create;  | 
|
| 1313 | 1312 | 
		};  | 
| 1314 | 1313 | 
		///@}  | 
| 1315 | 1314 | 
		 | 
| 1316 | 1315 | 
		public:  | 
| 1317 | 1316 | 
		 | 
| 1318 | 1317 | 
		/// \brief Constructor.  | 
| 1319 | 1318 | 
		///  | 
| 1320 | 1319 | 
		/// Constructor.  | 
| 1321 | 1320 | 
		///  | 
| 1322 | 1321 | 
		/// \param digraph The digraph the algorithm runs on.  | 
| 1323 | 1322 | 
		/// \param visitor The visitor object of the algorithm.  | 
| 1324 | 1323 | 
		DfsVisit(const Digraph& digraph, Visitor& visitor)  | 
| 1325 | 1324 | 
		: _digraph(&digraph), _visitor(&visitor),  | 
| 1326 | 1325 | 
		        _reached(0), local_reached(false) {}
	 | 
| 1327 | 1326 | 
		 | 
| 1328 | 1327 | 
		/// \brief Destructor.  | 
| 1329 | 1328 | 
		    ~DfsVisit() {
	 | 
| 1330 | 1329 | 
		if(local_reached) delete _reached;  | 
| 1331 | 1330 | 
		}  | 
| 1332 | 1331 | 
		 | 
| 1333 | 1332 | 
		/// \brief Sets the map that indicates which nodes are reached.  | 
| 1334 | 1333 | 
		///  | 
| 1335 | 1334 | 
		/// Sets the map that indicates which nodes are reached.  | 
| 1336 | 1335 | 
		/// If you don't use this function before calling \ref run(),  | 
| ... | ... | 
		@@ -310,187 +310,186 @@  | 
| 310 | 310 | 
		}  | 
| 311 | 311 | 
		      if(!_processed) {
	 | 
| 312 | 312 | 
		local_processed = true;  | 
| 313 | 313 | 
		_processed = Traits::createProcessedMap(*G);  | 
| 314 | 314 | 
		}  | 
| 315 | 315 | 
		      if (!_heap_cross_ref) {
	 | 
| 316 | 316 | 
		local_heap_cross_ref = true;  | 
| 317 | 317 | 
		_heap_cross_ref = Traits::createHeapCrossRef(*G);  | 
| 318 | 318 | 
		}  | 
| 319 | 319 | 
		      if (!_heap) {
	 | 
| 320 | 320 | 
		local_heap = true;  | 
| 321 | 321 | 
		_heap = Traits::createHeap(*_heap_cross_ref);  | 
| 322 | 322 | 
		}  | 
| 323 | 323 | 
		}  | 
| 324 | 324 | 
		 | 
| 325 | 325 | 
		public:  | 
| 326 | 326 | 
		 | 
| 327 | 327 | 
		typedef Dijkstra Create;  | 
| 328 | 328 | 
		 | 
| 329 | 329 | 
		///\name Named template parameters  | 
| 330 | 330 | 
		 | 
| 331 | 331 | 
		    ///@{
	 | 
| 332 | 332 | 
		 | 
| 333 | 333 | 
		template <class T>  | 
| 334 | 
		struct  | 
|
| 334 | 
		    struct SetPredMapTraits : public Traits {
	 | 
|
| 335 | 335 | 
		typedef T PredMap;  | 
| 336 | 336 | 
		static PredMap *createPredMap(const Digraph &)  | 
| 337 | 337 | 
		      {
	 | 
| 338 | 338 | 
		throw UninitializedParameter();  | 
| 339 | 339 | 
		}  | 
| 340 | 340 | 
		};  | 
| 341 | 341 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 342 | 342 | 
		///\ref PredMap type.  | 
| 343 | 343 | 
		///  | 
| 344 | 344 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 345 | 345 | 
		///\ref PredMap type.  | 
| 346 | 346 | 
		template <class T>  | 
| 347 | 
		struct DefPredMap  | 
|
| 348 | 
		      : public Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > {
	 | 
|
| 349 | 
		
  | 
|
| 347 | 
		struct SetPredMap  | 
|
| 348 | 
		      : public Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > {
	 | 
|
| 349 | 
		typedef Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > Create;  | 
|
| 350 | 350 | 
		};  | 
| 351 | 351 | 
		 | 
| 352 | 352 | 
		template <class T>  | 
| 353 | 
		struct  | 
|
| 353 | 
		    struct SetDistMapTraits : public Traits {
	 | 
|
| 354 | 354 | 
		typedef T DistMap;  | 
| 355 | 355 | 
		static DistMap *createDistMap(const Digraph &)  | 
| 356 | 356 | 
		      {
	 | 
| 357 | 357 | 
		throw UninitializedParameter();  | 
| 358 | 358 | 
		}  | 
| 359 | 359 | 
		};  | 
| 360 | 360 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 361 | 361 | 
		///\ref DistMap type.  | 
| 362 | 362 | 
		///  | 
| 363 | 363 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 364 | 364 | 
		///\ref DistMap type.  | 
| 365 | 365 | 
		template <class T>  | 
| 366 | 
		struct DefDistMap  | 
|
| 367 | 
		      : public Dijkstra< Digraph, LengthMap, DefDistMapTraits<T> > {
	 | 
|
| 368 | 
		
  | 
|
| 366 | 
		struct SetDistMap  | 
|
| 367 | 
		      : public Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > {
	 | 
|
| 368 | 
		typedef Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > Create;  | 
|
| 369 | 369 | 
		};  | 
| 370 | 370 | 
		 | 
| 371 | 371 | 
		template <class T>  | 
| 372 | 
		struct  | 
|
| 372 | 
		    struct SetProcessedMapTraits : public Traits {
	 | 
|
| 373 | 373 | 
		typedef T ProcessedMap;  | 
| 374 | 374 | 
		static ProcessedMap *createProcessedMap(const Digraph &)  | 
| 375 | 375 | 
		      {
	 | 
| 376 | 376 | 
		throw UninitializedParameter();  | 
| 377 | 377 | 
		}  | 
| 378 | 378 | 
		};  | 
| 379 | 379 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 380 | 380 | 
		///\ref ProcessedMap type.  | 
| 381 | 381 | 
		///  | 
| 382 | 382 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 383 | 383 | 
		///\ref ProcessedMap type.  | 
| 384 | 384 | 
		template <class T>  | 
| 385 | 
		struct DefProcessedMap  | 
|
| 386 | 
		      : public Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > {
	 | 
|
| 387 | 
		
  | 
|
| 385 | 
		struct SetProcessedMap  | 
|
| 386 | 
		      : public Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > {
	 | 
|
| 387 | 
		typedef Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > Create;  | 
|
| 388 | 388 | 
		};  | 
| 389 | 389 | 
		 | 
| 390 | 
		struct  | 
|
| 390 | 
		    struct SetStandardProcessedMapTraits : public Traits {
	 | 
|
| 391 | 391 | 
		typedef typename Digraph::template NodeMap<bool> ProcessedMap;  | 
| 392 | 392 | 
		static ProcessedMap *createProcessedMap(const Digraph &g)  | 
| 393 | 393 | 
		      {
	 | 
| 394 | 394 | 
		return new ProcessedMap(g);  | 
| 395 | 395 | 
		}  | 
| 396 | 396 | 
		};  | 
| 397 | 397 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 398 | 398 | 
		///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.  | 
| 399 | 399 | 
		///  | 
| 400 | 400 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 401 | 401 | 
		///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.  | 
| 402 | 402 | 
		///If you don't set it explicitly, it will be automatically allocated.  | 
| 403 | 
		template <class T>  | 
|
| 404 | 
		struct DefProcessedMapToBeDefaultMap  | 
|
| 405 | 
		      : public Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits> {
	 | 
|
| 406 | 
		typedef Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits>  | 
|
| 403 | 
		struct SetStandardProcessedMap  | 
|
| 404 | 
		      : public Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > {
	 | 
|
| 405 | 
		typedef Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits >  | 
|
| 407 | 406 | 
		Create;  | 
| 408 | 407 | 
		};  | 
| 409 | 408 | 
		 | 
| 410 | 409 | 
		template <class H, class CR>  | 
| 411 | 
		struct  | 
|
| 410 | 
		    struct SetHeapTraits : public Traits {
	 | 
|
| 412 | 411 | 
		typedef CR HeapCrossRef;  | 
| 413 | 412 | 
		typedef H Heap;  | 
| 414 | 413 | 
		      static HeapCrossRef *createHeapCrossRef(const Digraph &) {
	 | 
| 415 | 414 | 
		throw UninitializedParameter();  | 
| 416 | 415 | 
		}  | 
| 417 | 416 | 
		static Heap *createHeap(HeapCrossRef &)  | 
| 418 | 417 | 
		      {
	 | 
| 419 | 418 | 
		throw UninitializedParameter();  | 
| 420 | 419 | 
		}  | 
| 421 | 420 | 
		};  | 
| 422 | 421 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 423 | 422 | 
		///heap and cross reference type  | 
| 424 | 423 | 
		///  | 
| 425 | 424 | 
		///\ref named-templ-param "Named parameter" for setting heap and cross  | 
| 426 | 425 | 
		///reference type.  | 
| 427 | 426 | 
		template <class H, class CR = typename Digraph::template NodeMap<int> >  | 
| 428 | 
		struct DefHeap  | 
|
| 429 | 
		      : public Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > {
	 | 
|
| 430 | 
		
  | 
|
| 427 | 
		struct SetHeap  | 
|
| 428 | 
		      : public Dijkstra< Digraph, LengthMap, SetHeapTraits<H, CR> > {
	 | 
|
| 429 | 
		typedef Dijkstra< Digraph, LengthMap, SetHeapTraits<H, CR> > Create;  | 
|
| 431 | 430 | 
		};  | 
| 432 | 431 | 
		 | 
| 433 | 432 | 
		template <class H, class CR>  | 
| 434 | 
		struct  | 
|
| 433 | 
		    struct SetStandardHeapTraits : public Traits {
	 | 
|
| 435 | 434 | 
		typedef CR HeapCrossRef;  | 
| 436 | 435 | 
		typedef H Heap;  | 
| 437 | 436 | 
		      static HeapCrossRef *createHeapCrossRef(const Digraph &G) {
	 | 
| 438 | 437 | 
		return new HeapCrossRef(G);  | 
| 439 | 438 | 
		}  | 
| 440 | 439 | 
		static Heap *createHeap(HeapCrossRef &R)  | 
| 441 | 440 | 
		      {
	 | 
| 442 | 441 | 
		return new Heap(R);  | 
| 443 | 442 | 
		}  | 
| 444 | 443 | 
		};  | 
| 445 | 444 | 
		///\brief \ref named-templ-param "Named parameter" for setting  | 
| 446 | 445 | 
		///heap and cross reference type with automatic allocation  | 
| 447 | 446 | 
		///  | 
| 448 | 447 | 
		///\ref named-templ-param "Named parameter" for setting heap and cross  | 
| 449 | 448 | 
		///reference type. It can allocate the heap and the cross reference  | 
| 450 | 449 | 
		///object if the cross reference's constructor waits for the digraph as  | 
| 451 | 450 | 
		///parameter and the heap's constructor waits for the cross reference.  | 
| 452 | 451 | 
		template <class H, class CR = typename Digraph::template NodeMap<int> >  | 
| 453 | 
		struct DefStandardHeap  | 
|
| 454 | 
		      : public Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> > {
	 | 
|
| 455 | 
		
  | 
|
| 452 | 
		struct SetStandardHeap  | 
|
| 453 | 
		      : public Dijkstra< Digraph, LengthMap, SetStandardHeapTraits<H, CR> > {
	 | 
|
| 454 | 
		typedef Dijkstra< Digraph, LengthMap, SetStandardHeapTraits<H, CR> >  | 
|
| 456 | 455 | 
		Create;  | 
| 457 | 456 | 
		};  | 
| 458 | 457 | 
		 | 
| 459 | 458 | 
		template <class T>  | 
| 460 | 
		struct  | 
|
| 459 | 
		    struct SetOperationTraitsTraits : public Traits {
	 | 
|
| 461 | 460 | 
		typedef T OperationTraits;  | 
| 462 | 461 | 
		};  | 
| 463 | 462 | 
		 | 
| 464 | 463 | 
		/// \brief \ref named-templ-param "Named parameter" for setting  | 
| 465 | 464 | 
		///\ref OperationTraits type  | 
| 466 | 465 | 
		///  | 
| 467 | 466 | 
		///\ref named-templ-param "Named parameter" for setting  | 
| 468 | 467 | 
		///\ref OperationTraits type.  | 
| 469 | 468 | 
		template <class T>  | 
| 470 | 
		struct DefOperationTraits  | 
|
| 471 | 
		      : public Dijkstra<Digraph, LengthMap, DefOperationTraitsTraits<T> > {
	 | 
|
| 472 | 
		
  | 
|
| 469 | 
		struct SetOperationTraits  | 
|
| 470 | 
		      : public Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > {
	 | 
|
| 471 | 
		typedef Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> >  | 
|
| 473 | 472 | 
		Create;  | 
| 474 | 473 | 
		};  | 
| 475 | 474 | 
		 | 
| 476 | 475 | 
		///@}  | 
| 477 | 476 | 
		 | 
| 478 | 477 | 
		protected:  | 
| 479 | 478 | 
		 | 
| 480 | 479 | 
		    Dijkstra() {}
	 | 
| 481 | 480 | 
		 | 
| 482 | 481 | 
		public:  | 
| 483 | 482 | 
		 | 
| 484 | 483 | 
		///Constructor.  | 
| 485 | 484 | 
		 | 
| 486 | 485 | 
		///Constructor.  | 
| 487 | 486 | 
		///\param _g The digraph the algorithm runs on.  | 
| 488 | 487 | 
		///\param _length The length map used by the algorithm.  | 
| 489 | 488 | 
		Dijkstra(const Digraph& _g, const LengthMap& _length) :  | 
| 490 | 489 | 
		G(&_g), length(&_length),  | 
| 491 | 490 | 
		_pred(NULL), local_pred(false),  | 
| 492 | 491 | 
		_dist(NULL), local_dist(false),  | 
| 493 | 492 | 
		_processed(NULL), local_processed(false),  | 
| 494 | 493 | 
		_heap_cross_ref(NULL), local_heap_cross_ref(false),  | 
| 495 | 494 | 
		_heap(NULL), local_heap(false)  | 
| 496 | 495 | 
		    { }
	 | 
| ... | ... | 
		@@ -1178,99 +1177,99 @@  | 
| 1178 | 1177 | 
		dij.run(Base::_source);  | 
| 1179 | 1178 | 
		}  | 
| 1180 | 1179 | 
		 | 
| 1181 | 1180 | 
		///Runs Dijkstra algorithm from the given node.  | 
| 1182 | 1181 | 
		 | 
| 1183 | 1182 | 
		///Runs Dijkstra algorithm from the given node.  | 
| 1184 | 1183 | 
		///\param s is the given source.  | 
| 1185 | 1184 | 
		void run(Node s)  | 
| 1186 | 1185 | 
		    {
	 | 
| 1187 | 1186 | 
		Base::_source=s;  | 
| 1188 | 1187 | 
		run();  | 
| 1189 | 1188 | 
		}  | 
| 1190 | 1189 | 
		 | 
| 1191 | 1190 | 
		/// Sets the source node, from which the Dijkstra algorithm runs.  | 
| 1192 | 1191 | 
		 | 
| 1193 | 1192 | 
		/// Sets the source node, from which the Dijkstra algorithm runs.  | 
| 1194 | 1193 | 
		/// \param s is the source node.  | 
| 1195 | 1194 | 
		DijkstraWizard<TR> &source(Node s)  | 
| 1196 | 1195 | 
		    {
	 | 
| 1197 | 1196 | 
		Base::_source=s;  | 
| 1198 | 1197 | 
		return *this;  | 
| 1199 | 1198 | 
		}  | 
| 1200 | 1199 | 
		 | 
| 1201 | 1200 | 
		template<class T>  | 
| 1202 | 
		struct  | 
|
| 1201 | 
		    struct SetPredMapBase : public Base {
	 | 
|
| 1203 | 1202 | 
		typedef T PredMap;  | 
| 1204 | 1203 | 
		      static PredMap *createPredMap(const Digraph &) { return 0; };
	 | 
| 1205 | 
		
  | 
|
| 1204 | 
		      SetPredMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1206 | 1205 | 
		};  | 
| 1207 | 1206 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1208 | 1207 | 
		///for setting \ref PredMap object.  | 
| 1209 | 1208 | 
		///  | 
| 1210 | 1209 | 
		///\ref named-templ-param "Named parameter"  | 
| 1211 | 1210 | 
		///for setting \ref PredMap object.  | 
| 1212 | 1211 | 
		template<class T>  | 
| 1213 | 
		DijkstraWizard<  | 
|
| 1212 | 
		DijkstraWizard<SetPredMapBase<T> > predMap(const T &t)  | 
|
| 1214 | 1213 | 
		    {
	 | 
| 1215 | 1214 | 
		Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1216 | 
		return DijkstraWizard<  | 
|
| 1215 | 
		return DijkstraWizard<SetPredMapBase<T> >(*this);  | 
|
| 1217 | 1216 | 
		}  | 
| 1218 | 1217 | 
		 | 
| 1219 | 1218 | 
		template<class T>  | 
| 1220 | 
		struct  | 
|
| 1219 | 
		    struct SetProcessedMapBase : public Base {
	 | 
|
| 1221 | 1220 | 
		typedef T ProcessedMap;  | 
| 1222 | 1221 | 
		      static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
	 | 
| 1223 | 
		
  | 
|
| 1222 | 
		      SetProcessedMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1224 | 1223 | 
		};  | 
| 1225 | 1224 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1226 | 1225 | 
		///for setting \ref ProcessedMap object.  | 
| 1227 | 1226 | 
		///  | 
| 1228 | 1227 | 
		/// \ref named-templ-param "Named parameter"  | 
| 1229 | 1228 | 
		///for setting \ref ProcessedMap object.  | 
| 1230 | 1229 | 
		template<class T>  | 
| 1231 | 
		DijkstraWizard<  | 
|
| 1230 | 
		DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t)  | 
|
| 1232 | 1231 | 
		    {
	 | 
| 1233 | 1232 | 
		Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1234 | 
		return DijkstraWizard<  | 
|
| 1233 | 
		return DijkstraWizard<SetProcessedMapBase<T> >(*this);  | 
|
| 1235 | 1234 | 
		}  | 
| 1236 | 1235 | 
		 | 
| 1237 | 1236 | 
		template<class T>  | 
| 1238 | 
		struct  | 
|
| 1237 | 
		    struct SetDistMapBase : public Base {
	 | 
|
| 1239 | 1238 | 
		typedef T DistMap;  | 
| 1240 | 1239 | 
		      static DistMap *createDistMap(const Digraph &) { return 0; };
	 | 
| 1241 | 
		
  | 
|
| 1240 | 
		      SetDistMapBase(const TR &b) : TR(b) {}
	 | 
|
| 1242 | 1241 | 
		};  | 
| 1243 | 1242 | 
		///\brief \ref named-templ-param "Named parameter"  | 
| 1244 | 1243 | 
		///for setting \ref DistMap object.  | 
| 1245 | 1244 | 
		///  | 
| 1246 | 1245 | 
		///\ref named-templ-param "Named parameter"  | 
| 1247 | 1246 | 
		///for setting \ref DistMap object.  | 
| 1248 | 1247 | 
		template<class T>  | 
| 1249 | 
		DijkstraWizard<  | 
|
| 1248 | 
		DijkstraWizard<SetDistMapBase<T> > distMap(const T &t)  | 
|
| 1250 | 1249 | 
		    {
	 | 
| 1251 | 1250 | 
		Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));  | 
| 1252 | 
		return DijkstraWizard<  | 
|
| 1251 | 
		return DijkstraWizard<SetDistMapBase<T> >(*this);  | 
|
| 1253 | 1252 | 
		}  | 
| 1254 | 1253 | 
		 | 
| 1255 | 1254 | 
		};  | 
| 1256 | 1255 | 
		 | 
| 1257 | 1256 | 
		///Function type interface for Dijkstra algorithm.  | 
| 1258 | 1257 | 
		 | 
| 1259 | 1258 | 
		/// \ingroup shortest_path  | 
| 1260 | 1259 | 
		///Function type interface for Dijkstra algorithm.  | 
| 1261 | 1260 | 
		///  | 
| 1262 | 1261 | 
		///This function also has several  | 
| 1263 | 1262 | 
		///\ref named-templ-func-param "named parameters",  | 
| 1264 | 1263 | 
		///they are declared as the members of class \ref DijkstraWizard.  | 
| 1265 | 1264 | 
		///The following  | 
| 1266 | 1265 | 
		///example shows how to use these parameters.  | 
| 1267 | 1266 | 
		///\code  | 
| 1268 | 1267 | 
		/// dijkstra(g,length,source).predMap(preds).run();  | 
| 1269 | 1268 | 
		///\endcode  | 
| 1270 | 1269 | 
		///\warning Don't forget to put the \ref DijkstraWizard::run() "run()"  | 
| 1271 | 1270 | 
		///to the end of the parameter list.  | 
| 1272 | 1271 | 
		///\sa DijkstraWizard  | 
| 1273 | 1272 | 
		///\sa Dijkstra  | 
| 1274 | 1273 | 
		template<class GR, class LM>  | 
| 1275 | 1274 | 
		DijkstraWizard<DijkstraWizardBase<GR,LM> >  | 
| 1276 | 1275 | 
		dijkstra(const GR &g,const LM &l,typename GR::Node s=INVALID)  | 
| ... | ... | 
		@@ -110,49 +110,49 @@  | 
| 110 | 110 | 
		 | 
| 111 | 111 | 
		std::vector<int> v(test_len);  | 
| 112 | 112 | 
		 | 
| 113 | 113 | 
		  for (int i = 0; i < test_len; ++i) {
	 | 
| 114 | 114 | 
		v[i] = test_seq[i];  | 
| 115 | 115 | 
		heap.push(i, v[i]);  | 
| 116 | 116 | 
		}  | 
| 117 | 117 | 
		  for (int i = 0; i < test_len; ++i) {
	 | 
| 118 | 118 | 
		v[i] += test_inc[i];  | 
| 119 | 119 | 
		heap.increase(i, v[i]);  | 
| 120 | 120 | 
		}  | 
| 121 | 121 | 
		std::sort(v.begin(), v.end());  | 
| 122 | 122 | 
		  for (int i = 0; i < test_len; ++i) {
	 | 
| 123 | 123 | 
		check(v[i] == heap.prio() ,"Wrong order in heap increase test.");  | 
| 124 | 124 | 
		heap.pop();  | 
| 125 | 125 | 
		}  | 
| 126 | 126 | 
		}  | 
| 127 | 127 | 
		 | 
| 128 | 128 | 
		 | 
| 129 | 129 | 
		 | 
| 130 | 130 | 
		template <typename Heap>  | 
| 131 | 131 | 
		void dijkstraHeapTest(const Digraph& digraph, const IntArcMap& length,  | 
| 132 | 132 | 
		                      Node source) {
	 | 
| 133 | 133 | 
		 | 
| 134 | 
		typename Dijkstra<Digraph, IntArcMap>::template  | 
|
| 134 | 
		typename Dijkstra<Digraph, IntArcMap>::template SetStandardHeap<Heap>::  | 
|
| 135 | 135 | 
		Create dijkstra(digraph, length);  | 
| 136 | 136 | 
		 | 
| 137 | 137 | 
		dijkstra.run(source);  | 
| 138 | 138 | 
		 | 
| 139 | 139 | 
		  for(ArcIt a(digraph); a != INVALID; ++a) {
	 | 
| 140 | 140 | 
		Node s = digraph.source(a);  | 
| 141 | 141 | 
		Node t = digraph.target(a);  | 
| 142 | 142 | 
		    if (dijkstra.reached(s)) {
	 | 
| 143 | 143 | 
		check( dijkstra.dist(t) - dijkstra.dist(s) <= length[a],  | 
| 144 | 144 | 
		"Error in a shortest path tree!");  | 
| 145 | 145 | 
		}  | 
| 146 | 146 | 
		}  | 
| 147 | 147 | 
		 | 
| 148 | 148 | 
		  for(NodeIt n(digraph); n != INVALID; ++n) {
	 | 
| 149 | 149 | 
		    if ( dijkstra.reached(n) && dijkstra.predArc(n) != INVALID ) {
	 | 
| 150 | 150 | 
		Arc a = dijkstra.predArc(n);  | 
| 151 | 151 | 
		Node s = digraph.source(a);  | 
| 152 | 152 | 
		check( dijkstra.dist(n) - dijkstra.dist(s) == length[a],  | 
| 153 | 153 | 
		"Error in a shortest path tree!");  | 
| 154 | 154 | 
		}  | 
| 155 | 155 | 
		}  | 
| 156 | 156 | 
		 | 
| 157 | 157 | 
		}  | 
| 158 | 158 | 
		 | 
0 comments (0 inline)