Changeset 4:8009bb5ddd09 in lemon-0.x for src/work/bfsdemo.cc
- Timestamp:
- 12/14/03 16:32:46 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@16
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/bfsdemo.cc
r3 r4 25 25 bool isValid() const {return n<=5000;} 26 26 int Index() {return n;} //csak a kiirashoz kell 27 28 NodeIterator() {} 29 NodeIterator(IGraph &Gr) {G=&Gr;n=1;} //Bfs class prefer this. 27 30 }; 28 31 … … 41 44 NodeIterator Anode() const {return From();} 42 45 NodeIterator Bnode() const {return To();} 46 47 OutEdgeIterator() {} 48 OutEdgeIterator(IGraph &Gr,NodeIterator &n) //Bfs class prefer this. 49 {G=&Gr;f=n.n;t=0;operator++();} 43 50 }; 44 51 … … 71 78 }; 72 79 80 // New style bfs traits 81 class BFS_T 82 { 83 public: 84 85 typedef IGraph Graph_t; 86 typedef IGraph::OutEdgeIterator SearchEdgeIterator; 87 88 struct visited_map_t { 89 typedef bool value_type; 90 void Put(const IGraph::NodeIterator &n,const value_type &t) { n->isVis=t; } 91 value_type Get(const IGraph::NodeIterator &n) const { return n->isVis; } 92 }; 93 struct tree_map_t { 94 typedef IGraph::EdgeIterator value_type; 95 void Put(const IGraph::NodeIterator &n,const value_type &t) 96 { cout << t.From().Index() << "->" << t.To().Index() << '\n'; } 97 }; 98 typedef do_nothing_map dist_map_t; //node->int (W) 99 typedef do_nothing_map priority_map_t; //node->int (W) 100 }; 101 73 102 74 103 int main() 75 104 { 76 105 IGraph IG; 77 IMaps_t IMaps;78 106 107 // //Function-syte calling 108 // IMaps_t IMaps; 109 110 // IGraph::NodeIterator in; 111 // IG.GetFirst(in); 112 // ++in; 113 // bfs_fn(IG,in,IMaps); 114 115 //Class-style calling: 116 79 117 IGraph::NodeIterator in; 80 118 IG.GetFirst(in); 81 119 ++in; 82 bfs(IG,in,IMaps); 120 Bfs<BFS_T> bfs; 121 bfs.SetG(IG); 122 bfs.Init(in); 123 bfs.Run(); 83 124 }
Note: See TracChangeset
for help on using the changeset viewer.