Changeset 1158:29961fa390a3 in lemon-0.x for src
- Timestamp:
- 02/20/05 02:02:07 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1559
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/concept/graph_component.h
r1136 r1158 626 626 Edge e = it1; 627 627 e = it2; 628 } 629 630 Edge& edge; 631 Node& node; 632 Graph& graph; 628 629 const_constraits(); 630 } 631 632 void const_constraits() { 633 Node n = graph.baseNode(it); 634 n = graph.runningNode(it); 635 } 636 637 Edge edge; 638 Node node; 639 Graph graph; 640 _GraphIncIterator it; 633 641 }; 634 642 }; -
src/lemon/concept/undir_graph.h
r1030 r1158 37 37 /// Skeleton class which describes an edge with direction in \ref 38 38 /// UndirGraph "undirected graph". 39 template <typename UndirEdge> 40 class UndirGraphEdge : public UndirEdge { 39 template <typename UndirGraph> 40 class UndirGraphEdge : public UndirGraph::UndirEdge { 41 typedef typename UndirGraph::UndirEdge UndirEdge; 42 typedef typename UndirGraph::Node Node; 41 43 public: 42 44 … … 50 52 UndirGraphEdge(Invalid) {} 51 53 52 /// \brief Constructs a directed version of an undirected edge 53 /// 54 /// \param forward If \c true the direction of the contructed edge 55 /// is the same as the inherent direction of the \c undir_edge; if 56 /// \c false --- the opposite. 57 UndirGraphEdge(UndirEdge undir_edge, bool forward) { 54 /// \brief Directed edge from undirected edge and a source node. 55 /// 56 /// Constructs a directed edge from undirected edge and a source node. 57 /// 58 /// \note You have to specify the graph for this constructor. 59 UndirGraphEdge(const UndirGraph &g, 60 UndirEdge undir_edge, Node n) { 58 61 ignore_unused_variable_warning(undir_edge); 59 ignore_unused_variable_warning(forward); 62 ignore_unused_variable_warning(g); 63 ignore_unused_variable_warning(n); 60 64 } 61 65 … … 74 78 struct Constraints { 75 79 void constraints() { 80 const_constraints(); 81 } 82 void const_constraints() const { 76 83 /// \bug This should be is_base_and_derived ... 77 84 UndirEdge ue = e; 78 85 ue = e; 79 Edge forward(ue, true); 80 Edge backward(ue, false); 81 82 ignore_unused_variable_warning(forward); 83 ignore_unused_variable_warning(backward); 86 87 Edge e_with_source(graph,ue,n); 88 ignore_unused_variable_warning(e_with_source); 84 89 } 85 90 Edge e; 91 UndirEdge ue; 92 UndirGraph graph; 93 Node n; 86 94 }; 87 95 }; … … 100 108 checkConcept<BaseIterableGraphComponent, Graph>(); 101 109 checkConcept<GraphItem<>, UndirEdge>(); 102 checkConcept<UndirGraphEdge< UndirEdge>, Edge>();110 checkConcept<UndirGraphEdge<Graph>, Edge>(); 103 111 104 112 graph.first(ue); … … 235 243 /// Type describing an UndirEdge with direction 236 244 #ifndef DOXYGEN 237 typedef UndirGraphEdge<Undir Edge> Edge;245 typedef UndirGraphEdge<UndirGraph> Edge; 238 246 #else 239 247 typedef UndirGraphEdge Edge; … … 431 439 432 440 441 /// Base node of the iterator 442 /// 443 /// Returns the base node (the source in this case) of the iterator 444 Node baseNode(OutEdgeIt e) const { 445 return source(e); 446 } 447 /// Running node of the iterator 448 /// 449 /// Returns the running node (the target in this case) of the 450 /// iterator 451 Node runningNode(OutEdgeIt e) const { 452 return target(e); 453 } 454 455 /// Base node of the iterator 456 /// 457 /// Returns the base node (the target in this case) of the iterator 458 Node baseNode(InEdgeIt e) const { 459 return target(e); 460 } 461 /// Running node of the iterator 462 /// 463 /// Returns the running node (the source in this case) of the 464 /// iterator 465 Node runningNode(InEdgeIt e) const { 466 return source(e); 467 } 468 469 /// Base node of the iterator 470 /// 471 /// Returns the base node of the iterator 472 Node baseNode(IncEdgeIt e) const { 473 return INVALID; 474 } 475 /// Running node of the iterator 476 /// 477 /// Returns the running node of the iterator 478 Node runningNode(IncEdgeIt e) const { 479 return INVALID; 480 } 481 482 433 483 template <typename Graph> 434 484 struct Constraints { -
src/lemon/iterable_graph_extender.h
r1030 r1158 111 111 }; 112 112 113 /// Base node of the iterator 114 /// 115 /// Returns the base node (ie. the source in this case) of the iterator 116 /// 117 /// \todo Document in the concept! 118 Node baseNode(const OutEdgeIt &e) const { 119 return source(e); 120 } 121 /// Running node of the iterator 122 /// 123 /// Returns the running node (ie. the target in this case) of the 124 /// iterator 125 /// 126 /// \todo Document in the concept! 127 Node runningNode(const OutEdgeIt &e) const { 128 return target(e); 129 } 130 131 /// Base node of the iterator 132 /// 133 /// Returns the base node (ie. the target in this case) of the iterator 134 /// 135 /// \todo Document in the concept! 136 Node baseNode(const InEdgeIt &e) const { 137 return target(e); 138 } 139 /// Running node of the iterator 140 /// 141 /// Returns the running node (ie. the source in this case) of the 142 /// iterator 143 /// 144 /// \todo Document in the concept! 145 Node runningNode(const InEdgeIt &e) const { 146 return source(e); 147 } 148 113 149 using Parent::first; 114 150 … … 125 161 126 162 }; 163 164 165 166 167 127 168 128 169 template <typename _Base> … … 170 211 IncEdgeIt(Invalid i) : UndirEdge(i), forward(false) { } 171 212 172 explicitIncEdgeIt(const Graph& _graph, const Node &n)213 IncEdgeIt(const Graph& _graph, const Node &n) 173 214 : graph(&_graph) 174 215 { … … 176 217 } 177 218 178 // FIXME: Do we need this type of constructor here? 179 // IncEdgeIt(const Graph& _graph, const Edge& e) : 180 // UndirEdge(e), graph(&_graph), forward(_graph.forward(e)) { } 181 // or 182 // IncEdgeIt(const Graph& _graph, const Node& n, 183 // Const UndirEdge &e) ... ? 219 IncEdgeIt(const Graph& _graph, const UndirEdge &ue, const Node &n) 220 : graph(&_graph), UndirEdge(ue) 221 { 222 forward = (_graph.source(ue) == n); 223 } 184 224 185 225 IncEdgeIt& operator++() { … … 189 229 }; 190 230 191 Node source(const IncEdgeIt &e) const { 231 using Parent::baseNode; 232 using Parent::runningNode; 233 234 /// Base node of the iterator 235 /// 236 /// Returns the base node of the iterator 237 Node baseNode(const IncEdgeIt &e) const { 192 238 return _dirSource(e); 193 239 } 194 195 /// \todo Shouldn't the "source" of an undirected edge be called "aNode" 196 /// or something??? 197 using Parent::source; 198 199 /// Target of the given Edge. 200 Node target(const IncEdgeIt &e) const { 240 /// Running node of the iterator 241 /// 242 /// Returns the running node of the iterator 243 Node runningNode(const IncEdgeIt &e) const { 201 244 return _dirTarget(e); 202 245 } 203 204 /// \todo Shouldn't the "target" of an undirected edge be called "bNode"205 /// or something???206 using Parent::target;207 246 208 247 }; -
src/lemon/max_matching.h
r1093 r1158 181 181 Node u=_mate[v]; 182 182 for(IncEdgeIt e(g,v); e!=INVALID; ++e) { 183 if ( g. target(e) == u ) {183 if ( g.runningNode(e) == u ) { 184 184 map.set(u,e); 185 185 map.set(v,e); … … 228 228 Node u=_mate[v]; 229 229 for(IncEdgeIt e(g,v); e!=INVALID; ++e) { 230 if ( g. target(e) == u ) {230 if ( g.runningNode(e) == u ) { 231 231 map.set(e,true); 232 232 todo.set(u,false); … … 333 333 334 334 for( IncEdgeIt e(g,x); e!=INVALID ; ++e ) { 335 Node y=g. target(e);335 Node y=g.runningNode(e); 336 336 337 337 if ( position[y] == D && blossom.find(x) != blossom.find(y) ) { … … 389 389 390 390 for( IncEdgeIt e(g,x); e!=INVALID; ++e ) { 391 Node y=g. target(e);391 Node y=g.runningNode(e); 392 392 393 393 switch ( position[y] ) { … … 454 454 if ( _mate[v]==INVALID ) { 455 455 for( IncEdgeIt e(g,v); e!=INVALID ; ++e ) { 456 Node y=g. target(e);456 Node y=g.runningNode(e); 457 457 if ( _mate[y]==INVALID && y!=v ) { 458 458 _mate.set(v,y); … … 485 485 UFE& blossom, UFE& tree, std::queue<Node>& Q) { 486 486 for( IncEdgeIt e(g,x); e!= INVALID; ++e ) { 487 Node y=g. target(e);487 Node y=g.runningNode(e); 488 488 489 489 if ( position[y]==C ) { -
src/lemon/undir_graph_extender.h
r1060 r1158 45 45 public: 46 46 Edge() {} 47 /// Construct a direct edge from undirect edge and a direction. 47 48 /// \brief Directed edge from undirected edge and a direction. 49 /// 50 /// This constructor is not a part of the concept interface of 51 /// undirected graph, so please avoid using it if possible! 48 52 Edge(const UndirEdge &ue, bool _forward) : 49 UndirEdge(ue), forward(_forward) {} 53 UndirEdge(ue), forward(_forward) {} 54 55 /// \brief Directed edge from undirected edge and a source node. 56 /// 57 /// Constructs a directed edge from undirected edge and a source node. 58 /// 59 /// \note You have to specify the graph for this constructor. 60 Edge(const Graph &g, const UndirEdge &ue, const Node &n) : 61 UndirEdge(ue) { forward = (g.source(ue) == n); } 62 50 63 /// Invalid edge constructor 51 64 Edge(Invalid i) : UndirEdge(i), forward(true) {} … … 64 77 65 78 66 /// \brief Returns theEdge of opposite direction.67 /// 68 /// \bug Is this a good name for this? Or "reverse" is better?79 /// \brief Edge of opposite direction. 80 /// 81 /// Returns the Edge of opposite direction. 69 82 Edge opposite(const Edge &e) const { 70 83 return Edge(e,!e.forward); … … 118 131 } 119 132 133 /// Directed edge from an undirected edge and a source node. 134 /// 135 /// Returns a (directed) Edge corresponding to the specified UndirEdge 136 /// and source Node. 137 /// 138 ///\todo Do we need this? 139 /// 140 ///\todo Better name... 141 Edge edgeWithSource(const UndirEdge &ue, const Node &s) const { 142 return Edge(*this, eu, s); 143 } 120 144 121 145 using Parent::first; -
src/test/max_matching_test.cc
r1101 r1158 160 160 Q.pop(); 161 161 for(IncEdgeIt e(g,w); e!=INVALID; ++e) { 162 Node u=g. target(e);162 Node u=g.runningNode(e); 163 163 if ( pos[u]==max_matching.D && todo[u] ) { 164 164 ++comp_size;
Note: See TracChangeset
for help on using the changeset viewer.