COIN-OR::LEMON - Graph Library

Changeset 1627:3fd1ba6e9872 in lemon-0.x for lemon/bits


Ignore:
Timestamp:
08/11/05 17:55:17 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2135
Message:

Some modification on the undirected graph interface.
Doc improvments

Location:
lemon/bits
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/erasable_graph_extender.h

    r1435 r1627  
    7171    void erase(const UndirEdge& uedge) {
    7272      std::vector<Edge> edges;
    73       edges.push_back(Edge(uedge,true));
    74       edges.push_back(Edge(uedge,false));
     73      edges.push_back(Parent::direct(uedge,true));
     74      edges.push_back(Parent::direct(uedge,false));
    7575      Parent::getNotifier(Edge()).erase(edges);
    7676      Parent::getNotifier(UndirEdge()).erase(uedge);
  • lemon/bits/extendable_graph_extender.h

    r1435 r1627  
    5252
    5353      std::vector<Edge> edges;
    54       edges.push_back(Edge(uedge, true));
    55       edges.push_back(Edge(uedge, false));
     54      edges.push_back(Parent::direct(uedge, true));
     55      edges.push_back(Parent::direct(uedge, false));
    5656      Parent::getNotifier(Edge()).add(edges);
    5757
  • lemon/bits/iterable_graph_extender.h

    r1564 r1627  
    119119    };
    120120
    121     /// Base node of the iterator
     121    /// \brief Base node of the iterator
    122122    ///
    123123    /// Returns the base node (ie. the source in this case) of the iterator
    124     ///
    125     /// \todo Document in the concept!
    126124    Node baseNode(const OutEdgeIt &e) const {
    127125      return Parent::source((Edge)e);
    128126    }
    129     /// Running node of the iterator
     127    /// \brief Running node of the iterator
    130128    ///
    131129    /// Returns the running node (ie. the target in this case) of the
    132130    /// iterator
    133     ///
    134     /// \todo Document in the concept!
    135131    Node runningNode(const OutEdgeIt &e) const {
    136132      return Parent::target((Edge)e);
    137133    }
    138134
    139     /// Base node of the iterator
     135    /// \brief Base node of the iterator
    140136    ///
    141137    /// Returns the base node (ie. the target in this case) of the iterator
    142     ///
    143     /// \todo Document in the concept!
    144138    Node baseNode(const InEdgeIt &e) const {
    145139      return Parent::target((Edge)e);
    146140    }
    147     /// Running node of the iterator
     141    /// \brief Running node of the iterator
    148142    ///
    149143    /// Returns the running node (ie. the source in this case) of the
    150144    /// iterator
    151     ///
    152     /// \todo Document in the concept!
    153145    Node runningNode(const InEdgeIt &e) const {
    154146      return Parent::source((Edge)e);
     
    157149    using Parent::first;
    158150
     151    /// \brief The opposite node on the given edge.
     152    ///
     153    /// Gives back the opposite on the given edge.
     154    Node oppositeNode(const Node& n, const Edge& e) const {
     155      if (Parent::source(e) == n) {
     156        return Parent::target(e);
     157      } else {
     158        return Parent::source(e);
     159      }
     160    }
     161
    159162  private:
    160 
    161     // /// \todo When (and if) we change the iterators concept to use operator*,
    162     // /// then the following shadowed methods will become superfluous.
    163     // /// But for now these are important safety measures.
    164163
    165164    // void first(NodeIt &) const;
     
    191190    typedef IterableUndirGraphExtender<_Base> Graph;
    192191    typedef typename Parent::Node Node;
    193 
     192    typedef typename Parent::Edge Edge;
    194193    typedef typename Parent::UndirEdge UndirEdge;
    195194
     
    262261    }
    263262
     263    /// \brief The opposite node on the given undirected edge.
     264    ///
     265    /// Gives back the opposite on the given undirected edge.
     266    Node oppositeNode(const Node& n, const UndirEdge& e) const {
     267      if (Parent::source(e) == n) {
     268        return Parent::target(e);
     269      } else {
     270        return Parent::source(e);
     271      }
     272    }
     273
    264274  };
    265275}
  • lemon/bits/undir_graph_extender.h

    r1435 r1627  
    4343      bool forward;
    4444
     45      Edge(const UndirEdge &ue, bool _forward) :
     46        UndirEdge(ue), forward(_forward) {}
     47
    4548    public:
    4649      Edge() {}
    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!
    52       Edge(const UndirEdge &ue, bool _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); }
    6250
    6351      /// Invalid edge constructor
     
    8068    ///
    8169    /// Returns the Edge of opposite direction.
    82     Edge opposite(const Edge &e) const {
     70    Edge oppositeEdge(const Edge &e) const {
    8371      return Edge(e,!e.forward);
    8472    }
     
    114102      return _dirTarget(e);
    115103    }
    116 
    117     /// Returns whether the given directed edge is same orientation as the
    118     /// corresponding undirected edge.
    119     ///
    120     /// \todo reference to the corresponding point of the undirected graph
    121     /// concept. "What does the direction of an undirected edge mean?"
    122     bool forward(const Edge &e) const { return e.forward; }
    123104
    124105    Node oppositeNode(const Node &n, const UndirEdge &e) const {
     
    131112    }
    132113
    133     /// Directed edge from an undirected edge and a source node.
     114    /// \brief Directed edge from an undirected edge and a source node.
    134115    ///
    135116    /// Returns a (directed) Edge corresponding to the specified UndirEdge
    136117    /// and source Node.
    137118    ///
    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, ue, s);
    143     }
     119    Edge direct(const UndirEdge &ue, const Node &s) const {
     120      return Edge(ue, s == source(ue));
     121    }
     122
     123    /// \brief Directed edge from an undirected edge.
     124    ///
     125    /// Returns a directed edge corresponding to the specified UndirEdge.
     126    /// If the given bool is true the given undirected edge and the
     127    /// returned edge have the same source node.
     128    Edge direct(const UndirEdge &ue, bool d) const {
     129      return Edge(ue, d);
     130    }
     131
     132    /// Returns whether the given directed edge is same orientation as the
     133    /// corresponding undirected edge.
     134    ///
     135    /// \todo reference to the corresponding point of the undirected graph
     136    /// concept. "What does the direction of an undirected edge mean?"
     137    bool direction(const Edge &e) const { return e.forward; }
     138
    144139
    145140    using Parent::first;
Note: See TracChangeset for help on using the changeset viewer.