src/lemon/undir_graph_extender.h
changeset 988 aa19ca32d9b0
parent 981 2e34b796d532
child 1021 fd1d073b6557
equal deleted inserted replaced
2:0964ed4cbed3 3:b74ac4fc8358
    68     /// \bug Is this a good name for this? Or "reverse" is better?
    68     /// \bug Is this a good name for this? Or "reverse" is better?
    69     Edge opposite(const Edge &e) const {
    69     Edge opposite(const Edge &e) const {
    70       return Edge(e,!e.forward);
    70       return Edge(e,!e.forward);
    71     }
    71     }
    72 
    72 
    73     /// Tail of the given Edge.
    73     /// Source of the given Edge.
    74     Node tail(const Edge &e) const {
    74     Node source(const Edge &e) const {
    75       return e.forward ? Parent::tail(e) : Parent::head(e);
    75       return e.forward ? Parent::source(e) : Parent::target(e);
    76     }
    76     }
    77 
    77 
    78     /// \todo Shouldn't the "tail" of an undirected edge be called "aNode"
    78     /// \todo Shouldn't the "source" of an undirected edge be called "aNode"
    79     /// or something???
    79     /// or something???
    80     using Parent::tail;
    80     using Parent::source;
    81 
    81 
    82     /// Head of the given Edge.
    82     /// Target of the given Edge.
    83     Node head(const Edge &e) const {
    83     Node target(const Edge &e) const {
    84       return e.forward ? Parent::head(e) : Parent::tail(e);
    84       return e.forward ? Parent::target(e) : Parent::source(e);
    85     }
    85     }
    86 
    86 
    87     /// \todo Shouldn't the "head" of an undirected edge be called "bNode"
    87     /// \todo Shouldn't the "target" of an undirected edge be called "bNode"
    88     /// or something???
    88     /// or something???
    89     using Parent::head;
    89     using Parent::target;
    90 
    90 
    91     /// Returns whether the given directed edge is same orientation as the
    91     /// Returns whether the given directed edge is same orientation as the
    92     /// corresponding undirected edge.
    92     /// corresponding undirected edge.
    93     ///
    93     ///
    94     /// \todo reference to the corresponding point of the undirected graph
    94     /// \todo reference to the corresponding point of the undirected graph
    95     /// concept. "What does the direction of an undirected edge mean?"
    95     /// concept. "What does the direction of an undirected edge mean?"
    96     bool forward(const Edge &e) const { return e.forward; }
    96     bool forward(const Edge &e) const { return e.forward; }
    97 
    97 
    98     Node oppsiteNode(const Node &n, const Edge &e) const {
    98     Node oppsiteNode(const Node &n, const Edge &e) const {
    99       if( n == Parent::tail(e))
    99       if( n == Parent::source(e))
   100 	return Parent::head(e);
   100 	return Parent::target(e);
   101       else if( n == Parent::head(e))
   101       else if( n == Parent::target(e))
   102 	return Parent::tail(e);
   102 	return Parent::source(e);
   103       else
   103       else
   104 	return INVALID;
   104 	return INVALID;
   105     }
   105     }
   106 
   106 
   107 
   107 
   145 
   145 
   146     void nextOut(Edge &e) const {
   146     void nextOut(Edge &e) const {
   147       if( e.forward ) {
   147       if( e.forward ) {
   148 	Parent::nextOut(e);
   148 	Parent::nextOut(e);
   149 	if( UndirEdge(e) == INVALID ) {
   149 	if( UndirEdge(e) == INVALID ) {
   150 	  Parent::firstIn(e, Parent::tail(e));
   150 	  Parent::firstIn(e, Parent::source(e));
   151 	  e.forward = false;
   151 	  e.forward = false;
   152 	}
   152 	}
   153       }
   153       }
   154       else {
   154       else {
   155 	Parent::nextIn(e);
   155 	Parent::nextIn(e);
   157     }
   157     }
   158     void nextIn(Edge &e) const {
   158     void nextIn(Edge &e) const {
   159       if( e.forward ) {
   159       if( e.forward ) {
   160 	Parent::nextIn(e);
   160 	Parent::nextIn(e);
   161 	if( UndirEdge(e) == INVALID ) {
   161 	if( UndirEdge(e) == INVALID ) {
   162 	  Parent::firstOut(e, Parent::head(e));
   162 	  Parent::firstOut(e, Parent::target(e));
   163 	  e.forward = false;
   163 	  e.forward = false;
   164 	}
   164 	}
   165       }
   165       }
   166       else {
   166       else {
   167 	Parent::nextOut(e);
   167 	Parent::nextOut(e);