Changeset 743:efab34f23b30 in lemon0.x
 Timestamp:
 07/27/04 20:56:10 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1001
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/alpar/bfsnamedparam.cc
r741 r743 4 4 #include <hugo/maps.h> 5 5 #include <vector> 6 #include <iostream> 6 7 7 8 using namespace hugo; … … 90 91 91 92 template<class T> 92 _BFS<Graph,Visited, _BFS_CUSTOM_VIS,T,PredEdge,Priority>93 _BFS<Graph,Visited,DefaultVisitedTag,T,PredEdge,Priority> 93 94 setPredNodeMap(T &t) 94 95 { 95 return _BFS<Graph,Visited, _BFS_CUSTOM_VIS,T,PredEdge,Priority>96 return _BFS<Graph,Visited,DefaultVisitedTag,T,PredEdge,Priority> 96 97 (_graph,_source, 97 98 _visited, … … 100 101 101 102 template<class T> 102 _BFS<Graph,Visited, _BFS_CUSTOM_VIS,PredNode,T,Priority>103 _BFS<Graph,Visited,DefaultVisitedTag,PredNode,T,Priority> 103 104 setPredEdgeMap(T &t) 104 105 { 105 return _BFS<Graph,Visited, _BFS_CUSTOM_VIS,PredNode,T,Priority>106 return _BFS<Graph,Visited,DefaultVisitedTag,PredNode,T,Priority> 106 107 (_graph,_source, 107 108 _visited, … … 109 110 } 110 111 111 _BFS<Graph,Visited, _BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>112 _BFS<Graph,Visited,DefaultVisitedTag,PredNode,PredEdge,Priority> 112 113 setNothing() 113 114 { 114 return _BFS<Graph,Visited, _BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>115 return _BFS<Graph,Visited,DefaultVisitedTag,PredNode,PredEdge,Priority> 115 116 (_graph,_source, 116 117 _visited, … … 146 147 147 148 149 class MyVisitedMap : public SmartGraph::NodeMap<bool> 150 { 151 const SmartGraph &_G; 152 public: 153 MyVisitedMap(const SmartGraph &G) : SmartGraph::NodeMap<bool>(G), _G(G) {} 154 void set(SmartGraph::Node n,bool b) 155 { 156 SmartGraph::NodeMap<bool>::set(n,b); 157 if(b) std::cout << _G.id(n) << std::endl; 158 } 159 }; 160 161 148 162 int main() 149 163 { 150 164 SmartGraph G; 151 SmartGraph::NodeIt n(G); 165 SmartGraph::Node s=G.addNode(); 166 SmartGraph::Node n1=G.addNode(); 167 SmartGraph::Node n2=G.addNode(); 168 SmartGraph::Node n3=G.addNode(); 169 SmartGraph::Node n4=G.addNode(); 170 SmartGraph::Node n5=G.addNode(); 171 SmartGraph::Node n6=G.addNode(); 172 SmartGraph::Node n7=G.addNode(); 173 174 G.addEdge(s,n1);G.addEdge(s,n3);G.addEdge(n1,n2);G.addEdge(n1,n3); 175 G.addEdge(s,n4);G.addEdge(n4,n7);G.addEdge(n7,n6);G.addEdge(n4,n5); 176 G.addEdge(n7,n2);G.addEdge(n6,n3);G.addEdge(n4,s);G.addEdge(n1,s); 177 178 179 152 180 SmartGraph::NodeMap<SmartGraph::Node> m(G); 153 181 SmartGraph::NodeMap<SmartGraph::Edge> em(G); 154 155 bfs(G,n).run(); 156 bfs(G,n).setPredNodeMap(m).run(); 157 bfs(G,n).setPredNodeMap(m).setPredEdgeMap(em).run(); 182 183 MyVisitedMap vm(G); 184 185 186 //bfs(G,n).run(); 187 188 bfs(G,s).setPredNodeMap(m).run(); 189 190 bfs(G,s).setPredNodeMap(m).setPredEdgeMap(em).run(); 191 192 bfs(G,s).setVisitMap(vm).run(); 158 193 159 194 }
Note: See TracChangeset
for help on using the changeset viewer.