src/lemon/concept/undir_graph.h
changeset 1158 29961fa390a3
parent 1030 c8a41699e613
child 1164 80bb73097736
     1.1 --- a/src/lemon/concept/undir_graph.h	Sat Feb 19 21:11:20 2005 +0000
     1.2 +++ b/src/lemon/concept/undir_graph.h	Sun Feb 20 01:02:07 2005 +0000
     1.3 @@ -36,8 +36,10 @@
     1.4  
     1.5      /// Skeleton class which describes an edge with direction in \ref
     1.6      /// UndirGraph "undirected graph".
     1.7 -    template <typename UndirEdge>
     1.8 -    class UndirGraphEdge : public UndirEdge {
     1.9 +    template <typename UndirGraph>
    1.10 +    class UndirGraphEdge : public UndirGraph::UndirEdge {
    1.11 +      typedef typename UndirGraph::UndirEdge UndirEdge;
    1.12 +      typedef typename UndirGraph::Node Node;
    1.13      public:
    1.14  
    1.15        /// \e
    1.16 @@ -49,14 +51,16 @@
    1.17        /// \e
    1.18        UndirGraphEdge(Invalid) {}
    1.19  
    1.20 -      /// \brief Constructs a directed version of an undirected edge
    1.21 +      /// \brief Directed edge from undirected edge and a source node.
    1.22        ///
    1.23 -      /// \param forward If \c true the direction of the contructed edge
    1.24 -      /// is the same as the inherent direction of the \c undir_edge; if
    1.25 -      /// \c false --- the opposite.
    1.26 -      UndirGraphEdge(UndirEdge undir_edge, bool forward) {
    1.27 +      /// Constructs a directed edge from undirected edge and a source node.
    1.28 +      ///
    1.29 +      /// \note You have to specify the graph for this constructor.
    1.30 +      UndirGraphEdge(const UndirGraph &g,
    1.31 +		     UndirEdge undir_edge, Node n) {
    1.32  	ignore_unused_variable_warning(undir_edge);
    1.33 -	ignore_unused_variable_warning(forward);
    1.34 +	ignore_unused_variable_warning(g);
    1.35 +	ignore_unused_variable_warning(n);
    1.36        }
    1.37  
    1.38        /// \e
    1.39 @@ -73,16 +77,20 @@
    1.40        template <typename Edge>
    1.41        struct Constraints {
    1.42  	void constraints() {
    1.43 +	  const_constraints();
    1.44 +	}
    1.45 +	void const_constraints() const {
    1.46  	  /// \bug This should be is_base_and_derived ...
    1.47  	  UndirEdge ue = e;
    1.48  	  ue = e;
    1.49 -	  Edge forward(ue, true);
    1.50 -	  Edge backward(ue, false);
    1.51  
    1.52 -	  ignore_unused_variable_warning(forward);
    1.53 -	  ignore_unused_variable_warning(backward);
    1.54 +	  Edge e_with_source(graph,ue,n);
    1.55 +	  ignore_unused_variable_warning(e_with_source);
    1.56  	}
    1.57  	Edge e;
    1.58 +	UndirEdge ue;
    1.59 +	UndirGraph graph;
    1.60 +	Node n;
    1.61        };
    1.62      };
    1.63      
    1.64 @@ -99,7 +107,7 @@
    1.65  	void constraints() {
    1.66  	  checkConcept<BaseIterableGraphComponent, Graph>();
    1.67  	  checkConcept<GraphItem<>, UndirEdge>();
    1.68 -	  checkConcept<UndirGraphEdge<UndirEdge>, Edge>();
    1.69 +	  checkConcept<UndirGraphEdge<Graph>, Edge>();
    1.70  
    1.71  	  graph.first(ue);
    1.72  	  graph.next(ue);
    1.73 @@ -234,7 +242,7 @@
    1.74  
    1.75        /// Type describing an UndirEdge with direction
    1.76  #ifndef DOXYGEN
    1.77 -      typedef UndirGraphEdge<UndirEdge> Edge;
    1.78 +      typedef UndirGraphEdge<UndirGraph> Edge;
    1.79  #else
    1.80        typedef UndirGraphEdge Edge;
    1.81  #endif
    1.82 @@ -430,6 +438,48 @@
    1.83        void nextIn(Edge&) const {}
    1.84  
    1.85  
    1.86 +      /// Base node of the iterator
    1.87 +      ///
    1.88 +      /// Returns the base node (the source in this case) of the iterator
    1.89 +      Node baseNode(OutEdgeIt e) const {
    1.90 +	return source(e);
    1.91 +      }
    1.92 +      /// Running node of the iterator
    1.93 +      ///
    1.94 +      /// Returns the running node (the target in this case) of the
    1.95 +      /// iterator
    1.96 +      Node runningNode(OutEdgeIt e) const {
    1.97 +	return target(e);
    1.98 +      }
    1.99 +
   1.100 +      /// Base node of the iterator
   1.101 +      ///
   1.102 +      /// Returns the base node (the target in this case) of the iterator
   1.103 +      Node baseNode(InEdgeIt e) const {
   1.104 +	return target(e);
   1.105 +      }
   1.106 +      /// Running node of the iterator
   1.107 +      ///
   1.108 +      /// Returns the running node (the source in this case) of the
   1.109 +      /// iterator
   1.110 +      Node runningNode(InEdgeIt e) const {
   1.111 +	return source(e);
   1.112 +      }
   1.113 +
   1.114 +      /// Base node of the iterator
   1.115 +      ///
   1.116 +      /// Returns the base node of the iterator
   1.117 +      Node baseNode(IncEdgeIt e) const {
   1.118 +	return INVALID;
   1.119 +      }
   1.120 +      /// Running node of the iterator
   1.121 +      ///
   1.122 +      /// Returns the running node of the iterator
   1.123 +      Node runningNode(IncEdgeIt e) const {
   1.124 +	return INVALID;
   1.125 +      }
   1.126 +
   1.127 +
   1.128        template <typename Graph>
   1.129        struct Constraints {
   1.130  	void constraints() {