Changeset 2251:37fa5f83251e in lemon-0.x
- Timestamp:
- 10/17/06 13:02:05 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3001
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/graph_adaptor.h
r2177 r2251 1277 1277 /// \brief An undirected graph is made from a directed graph by an adaptor 1278 1278 /// 1279 /// Undocumented, untested!!! 1280 /// If somebody knows nice demo application, let's polulate it. 1279 /// This adaptor makes an undirected graph from a directed 1280 /// graph. All edge of the underlying will be showed in the adaptor 1281 /// as an undirected edge. Let's see an informal example about using 1282 /// this adaptor: 1283 /// 1284 /// There is a network of the streets of a town. Of course there are 1285 /// some one-way street in the town hence the network is a directed 1286 /// one. There is a crazy driver who go oppositely in the one-way 1287 /// street without moral sense. Of course he can pass this streets 1288 /// slower than the regular way, in fact his speed is half of the 1289 /// normal speed. How long should he drive to get from a source 1290 /// point to the target? Let see the example code which calculate it: 1291 /// 1292 ///\code 1293 /// typedef UndirGraphAdaptor<Graph> UGraph; 1294 /// UGraph ugraph(graph); 1295 /// 1296 /// typedef SimpleMap<LengthMap> FLengthMap; 1297 /// FLengthMap flength(length); 1298 /// 1299 /// typedef ScaleMap<LengthMap> RLengthMap; 1300 /// RLengthMap rlength(length, 2.0); 1301 /// 1302 /// typedef UGraph::CombinedEdgeMap<FLengthMap, RLengthMap > ULengthMap; 1303 /// ULengthMap ulength(flength, rlength); 1281 1304 /// 1282 /// \author Marton Makai 1305 /// Dijkstra<UGraph, ULengthMap> dijkstra(ugraph, ulength); 1306 /// std::cout << "Driving time : " << dijkstra.run(src, trg) << std::endl; 1307 ///\endcode 1308 /// 1309 /// The combined edge map makes the length map for the undirected 1310 /// graph. It is created from a forward and reverse map. The forward 1311 /// map is created from the original length map with a SimpleMap 1312 /// adaptor which just makes a read-write map from the reference map 1313 /// i.e. it forgets that it can be return reference to values. The 1314 /// reverse map is just the scaled original map with the ScaleMap 1315 /// adaptor. The combination solves that passing the reverse way 1316 /// takes double time than the original. To get the driving time we 1317 /// run the dijkstra algorithm on the undirected graph. 1318 /// 1319 /// \author Marton Makai and Balazs Dezso 1283 1320 template<typename _Graph> 1284 1321 class UndirGraphAdaptor : public AlterableUndirGraphAdaptor<_Graph> { … … 1289 1326 UndirGraphAdaptor() { } 1290 1327 public: 1328 1329 /// \brief Constructor 1330 /// 1331 /// Constructor 1291 1332 UndirGraphAdaptor(_Graph& _graph) { 1292 1333 setGraph(_graph); 1293 1334 } 1294 1335 1336 /// \brief EdgeMap combined from two original EdgeMap 1337 /// 1338 /// This class adapts two original graph EdgeMap to 1339 /// get an edge map on the adaptor. 1295 1340 template <typename _ForwardMap, typename _BackwardMap> 1296 1341 class CombinedEdgeMap { … … 1304 1349 typedef typename ForwardMap::Value Value; 1305 1350 typedef typename Parent::Edge Key; 1306 1351 1352 /// \brief Constructor 1353 /// 1354 /// Constructor 1307 1355 CombinedEdgeMap() : forward_map(0), backward_map(0) {} 1308 1356 1357 /// \brief Constructor 1358 /// 1359 /// Constructor 1309 1360 CombinedEdgeMap(ForwardMap& _forward_map, BackwardMap& _backward_map) 1310 1361 : forward_map(&_forward_map), backward_map(&_backward_map) {} 1311 1362 1363 1364 /// \brief Sets the value associated with a key. 1365 /// 1366 /// Sets the value associated with a key. 1312 1367 void set(const Key& e, const Value& a) { 1313 1368 if (Parent::direction(e)) { … … 1318 1373 } 1319 1374 1375 /// \brief Returns the value associated with a key. 1376 /// 1377 /// Returns the value associated with a key. 1320 1378 typename MapTraits<ForwardMap>::ConstReturnValue 1321 1379 operator[](const Key& e) const { … … 1327 1385 } 1328 1386 1387 /// \brief Returns the value associated with a key. 1388 /// 1389 /// Returns the value associated with a key. 1329 1390 typename MapTraits<ForwardMap>::ReturnValue 1330 1391 operator[](const Key& e) { … … 1336 1397 } 1337 1398 1399 /// \brief Sets the forward map 1400 /// 1401 /// Sets the forward map 1338 1402 void setForwardMap(ForwardMap& _forward_map) { 1339 1403 forward_map = &_forward_map; 1340 1404 } 1341 1405 1406 /// \brief Sets the backward map 1407 /// 1408 /// Sets the backward map 1342 1409 void setBackwardMap(BackwardMap& _backward_map) { 1343 1410 backward_map = &_backward_map;
Note: See TracChangeset
for help on using the changeset viewer.