Changeset 1693:269f0cbfbcc8 in lemon0.x
 Timestamp:
 09/30/05 15:15:28 (15 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2219
 Files:

 1 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

demo/grid_graph_demo.cc
r1681 r1693 42 42 bfs.run(start, stop) << std::endl; 43 43 44 GridGraph::NodeMap<xy<double> > coord(graph); 45 for (int i = 0; i < graph.width(); ++i) { 46 for (int j = 0; j < graph.height(); ++j) { 47 coord[graph(i, j)] = xy<double>( i * 10.0, j * 10.0); 48 } 49 } 50 51 FilteredGraph::EdgeMap<Color> color(filtered, Color(0.0, 0.0, 0.0)); 44 FilteredGraph::EdgeMap<bool> path(filtered, false); 52 45 53 46 for (GridGraph::Node node = stop; 54 47 node != start; node = bfs.predNode(node)) { 55 color[bfs.pred(node)] = Color(1.0, 0.0, 0.0);48 path[bfs.pred(node)] = true; 56 49 } 57 50 … … 59 52 title("Grid graph"). 60 53 copyright("(C) 2005 LEMON Project"). 61 coords( coord).54 coords(scaleMap(indexMap(graph), 10)). 62 55 enableParallel(). 63 nodeScale( .45).56 nodeScale(0.5). 64 57 drawArrows(). 65 edgeColors(co lor).58 edgeColors(composeMap(ColorSet(), path)). 66 59 run(); 67 60 
lemon/Makefile.am
r1677 r1693 35 35 graph_utils.h \ 36 36 graph_to_eps.h \ 37 hypercube_graph.h \ 37 38 invalid.h \ 38 39 iterable_maps.h \ 
lemon/grid_graph.h
r1680 r1693 28 28 #include <lemon/bits/undir_graph_extender.h> 29 29 30 #include <lemon/xy.h> 31 32 ///\ingroup graphs 33 ///\file 34 ///\brief GridGraph class. 35 30 36 namespace lemon { 31 37 38 /// \brief Base graph for GridGraph. 39 /// 40 /// Base graph for grid graph. It describes some member functions 41 /// which can be used in the GridGraph. 42 /// 43 /// \warning Always use the GridGraph instead of this. 44 /// \see GridGraph 32 45 class GridGraphBase { 33 46 … … 357 370 /// 358 371 /// \author Balazs Dezso 372 /// \see GridGraphBase 359 373 class GridGraph : public ExtendedGridGraphBase { 360 374 public: 361 375 376 /// \brief Map to get the indices of the nodes as xy<int>. 377 /// 378 /// Map to get the indices of the nodes as xy<int>. 379 class IndexMap { 380 public: 381 typedef True NeedCopy; 382 /// \brief The key type of the map 383 typedef GridGraph::Node Key; 384 /// \brief The value type of the map 385 typedef xy<int> Value; 386 387 /// \brief Constructor 388 /// 389 /// Constructor 390 IndexMap(const GridGraph& _graph) : graph(_graph) {} 391 392 /// \brief The subscript operator 393 /// 394 /// The subscript operator. 395 Value operator[](Key key) const { 396 return xy<int>(graph.row(key), graph.col(key)); 397 } 398 399 private: 400 const GridGraph& graph; 401 }; 402 403 /// \brief Map to get the row of the nodes. 404 /// 405 /// Map to get the row of the nodes. 406 class RowMap { 407 public: 408 typedef True NeedCopy; 409 /// \brief The key type of the map 410 typedef GridGraph::Node Key; 411 /// \brief The value type of the map 412 typedef int Value; 413 414 /// \brief Constructor 415 /// 416 /// Constructor 417 RowMap(const GridGraph& _graph) : graph(_graph) {} 418 419 /// \brief The subscript operator 420 /// 421 /// The subscript operator. 422 Value operator[](Key key) const { 423 return graph.row(key); 424 } 425 426 private: 427 const GridGraph& graph; 428 }; 429 430 /// \brief Map to get the column of the nodes. 431 /// 432 /// Map to get the column of the nodes. 433 class ColMap { 434 public: 435 typedef True NeedCopy; 436 /// \brief The key type of the map 437 typedef GridGraph::Node Key; 438 /// \brief The value type of the map 439 typedef int Value; 440 441 /// \brief Constructor 442 /// 443 /// Constructor 444 ColMap(const GridGraph& _graph) : graph(_graph) {} 445 446 /// \brief The subscript operator 447 /// 448 /// The subscript operator. 449 Value operator[](Key key) const { 450 return graph.col(key); 451 } 452 453 private: 454 const GridGraph& graph; 455 }; 456 362 457 GridGraph(int n, int m) { construct(n, m); } 363 458 … … 399 494 400 495 }; 496 497 /// \brief Index map of the grid graph 498 /// 499 /// Just returns an IndexMap for the grid graph. 500 GridGraph::IndexMap indexMap(const GridGraph& graph) { 501 return GridGraph::IndexMap(graph); 502 } 503 504 /// \brief Row map of the grid graph 505 /// 506 /// Just returns an RowMap for the grid graph. 507 GridGraph::RowMap rowMap(const GridGraph& graph) { 508 return GridGraph::RowMap(graph); 509 } 510 511 /// \brief Coloumn map of the grid graph 512 /// 513 /// Just returns an ColMap for the grid graph. 514 GridGraph::ColMap colMap(const GridGraph& graph) { 515 return GridGraph::ColMap(graph); 516 } 401 517 } 402 518 #endif
Note: See TracChangeset
for help on using the changeset viewer.