Changeset 969:0631847b37e5 in lemon0.x for src/lemon/smart_graph.h
 Timestamp:
 11/08/04 16:24:53 (19 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1356
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/smart_graph.h
r959 r969 46 46 /// @{ 47 47 48 ///Base of SmartGraph 49 50 ///Base of SmartGraph 51 /// 48 52 class SmartGraphBase { 49 53 … … 132 136 } 133 137 134 /// Finds an edge between two nodes.135 136 /// Finds an edge from node \c u to node \c v.137 ///138 /// If \c prev is \ref INVALID (this is the default value), then139 /// It finds the first edge from \c u to \c v. Otherwise it looks for140 /// the next edge from \c u to \c v after \c prev.141 /// \return The found edge or INVALID if there is no such an edge.142 Edge findEdge(Node u,Node v, Edge prev = INVALID)143 {144 int e = (prev.n==1)? nodes[u.n].first_out : edges[prev.n].next_out;145 while(e!=1 && edges[e].tail!=v.n) e = edges[e].next_out;146 prev.n=e;147 return prev;148 }149 150 138 void clear() { 151 139 edges.clear(); … … 215 203 } 216 204 205 Edge _findEdge(Node u,Node v, Edge prev = INVALID) 206 { 207 int e = (prev.n==1)? nodes[u.n].first_out : edges[prev.n].next_out; 208 while(e!=1 && edges[e].tail!=v.n) e = edges[e].next_out; 209 prev.n=e; 210 return prev; 211 } 217 212 }; 218 213 … … 243 238 /// 244 239 ///\author Alpar Juttner 245 class SmartGraph :public ClearableSmartGraphBase { }; 240 class SmartGraph :public ClearableSmartGraphBase { 241 public: 242 /// Finds an edge between two nodes. 243 244 /// Finds an edge from node \c u to node \c v. 245 /// 246 /// If \c prev is \ref INVALID (this is the default value), then 247 /// it finds the first edge from \c u to \c v. Otherwise it looks for 248 /// the next edge from \c u to \c v after \c prev. 249 /// \return The found edge or \ref INVALID if there is no such an edge. 250 /// 251 /// Thus you can iterate through each edge from \c u to \c v as it follows. 252 /// \code 253 /// for(Edge e=G.findEdge(u,v);e!=INVALID;e=G.findEdge(u,v,e)) { 254 /// ... 255 /// } 256 /// \endcode 257 /// \todo Possibly it should be a global function. 258 Edge findEdge(Node u,Node v, Edge prev = INVALID) 259 { 260 return _findEdge(u,v,prev); 261 } 262 }; 246 263 247 264 template <>
Note: See TracChangeset
for help on using the changeset viewer.