src/lemon/undir_graph_extender.h
changeset 1162 2f51fccbc261
parent 1060 7a24bb2e7480
child 1164 80bb73097736
equal deleted inserted replaced
8:20ea7c9e0e15 9:06057b78f8ac
    42       // be reasonable to syncronize...
    42       // be reasonable to syncronize...
    43       bool forward;
    43       bool forward;
    44 
    44 
    45     public:
    45     public:
    46       Edge() {}
    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       Edge(const UndirEdge &ue, bool _forward) :
    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       /// Invalid edge constructor
    63       /// Invalid edge constructor
    51       Edge(Invalid i) : UndirEdge(i), forward(true) {}
    64       Edge(Invalid i) : UndirEdge(i), forward(true) {}
    52 
    65 
    53       bool operator==(const Edge &that) const {
    66       bool operator==(const Edge &that) const {
    54 	return forward==that.forward && UndirEdge(*this)==UndirEdge(that);
    67 	return forward==that.forward && UndirEdge(*this)==UndirEdge(that);
    61 	  (!(that.forward<forward) && UndirEdge(*this)<UndirEdge(that));
    74 	  (!(that.forward<forward) && UndirEdge(*this)<UndirEdge(that));
    62       }
    75       }
    63     };
    76     };
    64 
    77 
    65 
    78 
    66     /// \brief Returns the Edge of opposite direction.
    79     /// \brief Edge of opposite direction.
    67     ///
    80     ///
    68     /// \bug Is this a good name for this? Or "reverse" is better?
    81     /// Returns the Edge of opposite direction.
    69     Edge opposite(const Edge &e) const {
    82     Edge opposite(const Edge &e) const {
    70       return Edge(e,!e.forward);
    83       return Edge(e,!e.forward);
    71     }
    84     }
    72 
    85 
    73   protected:
    86   protected:
   115 	return Parent::source(e);
   128 	return Parent::source(e);
   116       else
   129       else
   117 	return INVALID;
   130 	return INVALID;
   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     using Parent::first;
   145     using Parent::first;
   122     void first(Edge &e) const {
   146     void first(Edge &e) const {
   123       Parent::first(e);
   147       Parent::first(e);
   124       e.forward=true;
   148       e.forward=true;