COIN-OR::LEMON - Graph Library

Changeset 2222:a24939ee343c in lemon-0.x


Ignore:
Timestamp:
09/29/06 13:23:54 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2962
Message:

findEdge extension also for the BpUGraphs
proper handling of loop edges in the UGraph::findUEdge

Location:
lemon/bits
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/base_extender.h

    r2187 r2222  
    3636  /// \ingroup graphbits
    3737  ///
    38   /// \brief BaseExtender for the UGraphs
     38  /// \brief BaseGraph to BaseUGraph extender
    3939  template <typename Base>
    4040  class UndirGraphExtender : public Base {
     
    239239    }
    240240
    241     Edge findEdge(Node source, Node target, Edge prev) const {
     241    Edge findEdge(Node source, Node target, Edge prev = INVALID) const {
    242242      if (prev == INVALID) {
    243243        UEdge edge = Parent::findEdge(source, target);
     
    257257    }
    258258
    259     UEdge findUEdge(Node source, Node target, UEdge prev) const {
    260       if (prev == INVALID) {
    261         UEdge edge = Parent::findEdge(source, target);
    262         if (edge != INVALID) return edge;
    263         edge = Parent::findEdge(target, source);
    264         if (edge != INVALID) return edge;
    265       } else if (Parent::source(prev) == source) {
    266         UEdge edge = Parent::findEdge(source, target, prev);
    267         if (edge != INVALID) return edge;
    268         edge = Parent::findEdge(target, source);
    269         if (edge != INVALID) return edge;       
     259    UEdge findUEdge(Node source, Node target, UEdge prev = INVALID) const {
     260      if (source != target) {
     261        if (prev == INVALID) {
     262          UEdge edge = Parent::findEdge(source, target);
     263          if (edge != INVALID) return edge;
     264          edge = Parent::findEdge(target, source);
     265          if (edge != INVALID) return edge;
     266        } else if (Parent::source(prev) == source) {
     267          UEdge edge = Parent::findEdge(source, target, prev);
     268          if (edge != INVALID) return edge;
     269          edge = Parent::findEdge(target, source);
     270          if (edge != INVALID) return edge;     
     271        } else {
     272          UEdge edge = Parent::findEdge(target, source, prev);
     273          if (edge != INVALID) return edge;           
     274        }
    270275      } else {
    271         UEdge edge = Parent::findEdge(target, source, prev);
    272         if (edge != INVALID) return edge;             
     276        return Parent::findEdge(source, target, prev);
    273277      }
    274278      return INVALID;
  • lemon/bits/graph_extender.h

    r2203 r2222  
    15241524    }
    15251525
     1526    Edge findEdge(Node u, Node v, Edge prev = INVALID) const {
     1527      UEdge uedge = Parent::findUEdge(u, v, prev);
     1528      if (uedge != INVALID) {
     1529        return direct(uedge, Parent::aNode(u));
     1530      } else {
     1531        return INVALID;
     1532      }
     1533    }
    15261534
    15271535  };
Note: See TracChangeset for help on using the changeset viewer.