lemon/concepts/graph_components.h
changeset 1018 2e959a5a0c2d
parent 1010 36fa2fee7144
child 1025 c8fa41fcc4a7
     1.1 --- a/lemon/concepts/graph_components.h	Sun Feb 24 19:44:14 2013 +0100
     1.2 +++ b/lemon/concepts/graph_components.h	Sun Nov 14 16:35:31 2010 +0100
     1.3 @@ -299,6 +299,151 @@
     1.4  
     1.5      };
     1.6  
     1.7 +    /// \brief Base skeleton class for undirected bipartite graphs.
     1.8 +    ///
     1.9 +    /// This class describes the base interface of undirected
    1.10 +    /// bipartite graph types.  All bipartite graph %concepts have to
    1.11 +    /// conform to this class.  It extends the interface of \ref
    1.12 +    /// BaseGraphComponent with an \c Edge type and functions to get
    1.13 +    /// the end nodes of edges, to convert from arcs to edges and to
    1.14 +    /// get both direction of edges.
    1.15 +    class BaseBpGraphComponent : public BaseGraphComponent {
    1.16 +    public:
    1.17 +
    1.18 +      typedef BaseBpGraphComponent BpGraph;
    1.19 +
    1.20 +      typedef BaseDigraphComponent::Node Node;
    1.21 +      typedef BaseDigraphComponent::Arc Arc;
    1.22 +
    1.23 +      /// \brief Class to represent red nodes.
    1.24 +      ///
    1.25 +      /// This class represents the red nodes of the graph. It does
    1.26 +      /// not supposed to be used directly, because the nodes can be
    1.27 +      /// represented as Node instances. This class can be used as
    1.28 +      /// template parameter for special map classes.
    1.29 +      class RedNode : public Node {
    1.30 +        typedef Node Parent;
    1.31 +
    1.32 +      public:
    1.33 +        /// \brief Default constructor.
    1.34 +        ///
    1.35 +        /// Default constructor.
    1.36 +        /// \warning The default constructor is not required to set
    1.37 +        /// the item to some well-defined value. So you should consider it
    1.38 +        /// as uninitialized.
    1.39 +        RedNode() {}
    1.40 +
    1.41 +        /// \brief Copy constructor.
    1.42 +        ///
    1.43 +        /// Copy constructor.
    1.44 +        RedNode(const RedNode &) : Parent() {}
    1.45 +
    1.46 +        /// \brief Constructor for conversion from \c INVALID.
    1.47 +        ///
    1.48 +        /// Constructor for conversion from \c INVALID.
    1.49 +        /// It initializes the item to be invalid.
    1.50 +        /// \sa Invalid for more details.
    1.51 +        RedNode(Invalid) {}
    1.52 +
    1.53 +        /// \brief Constructor for conversion from a node.
    1.54 +        ///
    1.55 +        /// Constructor for conversion from a node. The conversion can
    1.56 +        /// be invalid, since the Node can be member of the blue
    1.57 +        /// set.
    1.58 +        RedNode(const Node&) {}
    1.59 +      };
    1.60 +
    1.61 +      /// \brief Class to represent blue nodes.
    1.62 +      ///
    1.63 +      /// This class represents the blue nodes of the graph. It does
    1.64 +      /// not supposed to be used directly, because the nodes can be
    1.65 +      /// represented as Node instances. This class can be used as
    1.66 +      /// template parameter for special map classes.
    1.67 +      class BlueNode : public Node {
    1.68 +        typedef Node Parent;
    1.69 +
    1.70 +      public:
    1.71 +        /// \brief Default constructor.
    1.72 +        ///
    1.73 +        /// Default constructor.
    1.74 +        /// \warning The default constructor is not required to set
    1.75 +        /// the item to some well-defined value. So you should consider it
    1.76 +        /// as uninitialized.
    1.77 +        BlueNode() {}
    1.78 +
    1.79 +        /// \brief Copy constructor.
    1.80 +        ///
    1.81 +        /// Copy constructor.
    1.82 +        BlueNode(const BlueNode &) : Parent() {}
    1.83 +
    1.84 +        /// \brief Constructor for conversion from \c INVALID.
    1.85 +        ///
    1.86 +        /// Constructor for conversion from \c INVALID.
    1.87 +        /// It initializes the item to be invalid.
    1.88 +        /// \sa Invalid for more details.
    1.89 +        BlueNode(Invalid) {}
    1.90 +
    1.91 +        /// \brief Constructor for conversion from a node.
    1.92 +        ///
    1.93 +        /// Constructor for conversion from a node. The conversion can
    1.94 +        /// be invalid, since the Node can be member of the red
    1.95 +        /// set.
    1.96 +        BlueNode(const Node&) {}
    1.97 +      };
    1.98 +
    1.99 +      /// \brief Gives back %true for red nodes.
   1.100 +      ///
   1.101 +      /// Gives back %true for red nodes.
   1.102 +      bool red(const Node&) const { return true; }
   1.103 +
   1.104 +      /// \brief Gives back %true for blue nodes.
   1.105 +      ///
   1.106 +      /// Gives back %true for blue nodes.
   1.107 +      bool blue(const Node&) const { return true; }
   1.108 +
   1.109 +      /// \brief Gives back the red end node of the edge.
   1.110 +      /// 
   1.111 +      /// Gives back the red end node of the edge.
   1.112 +      Node redNode(const Edge&) const { return Node(); }
   1.113 +
   1.114 +      /// \brief Gives back the blue end node of the edge.
   1.115 +      /// 
   1.116 +      /// Gives back the blue end node of the edge.
   1.117 +      Node blueNode(const Edge&) const { return Node(); }
   1.118 +
   1.119 +      template <typename _BpGraph>
   1.120 +      struct Constraints {
   1.121 +        typedef typename _BpGraph::Node Node;
   1.122 +        typedef typename _BpGraph::RedNode RedNode;
   1.123 +        typedef typename _BpGraph::BlueNode BlueNode;
   1.124 +        typedef typename _BpGraph::Arc Arc;
   1.125 +        typedef typename _BpGraph::Edge Edge;
   1.126 +
   1.127 +        void constraints() {
   1.128 +          checkConcept<BaseGraphComponent, _BpGraph>();
   1.129 +          checkConcept<GraphItem<'n'>, RedNode>();
   1.130 +          checkConcept<GraphItem<'n'>, BlueNode>();
   1.131 +          {
   1.132 +            Node n;
   1.133 +            RedNode rn = n;
   1.134 +            BlueNode bn = bn;
   1.135 +            Edge e;
   1.136 +            bool b;
   1.137 +            b = bpgraph.red(n);
   1.138 +            b = bpgraph.blue(n);
   1.139 +            ignore_unused_variable_warning(b);
   1.140 +            n = bpgraph.redNode(e);
   1.141 +            n = bpgraph.blueNode(e);
   1.142 +            rn = n;
   1.143 +            bn = n;
   1.144 +          }
   1.145 +        }
   1.146 +
   1.147 +        const _BpGraph& bpgraph;
   1.148 +      };
   1.149 +
   1.150 +    };
   1.151 +
   1.152      /// \brief Skeleton class for \e idable directed graphs.
   1.153      ///
   1.154      /// This class describes the interface of \e idable directed graphs.
   1.155 @@ -431,6 +576,82 @@
   1.156        };
   1.157      };
   1.158  
   1.159 +    /// \brief Skeleton class for \e idable undirected bipartite graphs.
   1.160 +    ///
   1.161 +    /// This class describes the interface of \e idable undirected
   1.162 +    /// bipartite graphs. It extends \ref IDableGraphComponent with
   1.163 +    /// the core ID functions of undirected bipartite graphs. Beside
   1.164 +    /// the regular node ids, this class also provides ids within the
   1.165 +    /// the red and blue sets of the nodes. This concept is part of
   1.166 +    /// the BpGraph concept.
   1.167 +    template <typename BAS = BaseBpGraphComponent>
   1.168 +    class IDableBpGraphComponent : public IDableGraphComponent<BAS> {
   1.169 +    public:
   1.170 +
   1.171 +      typedef BAS Base;
   1.172 +      typedef IDableGraphComponent<BAS> Parent;
   1.173 +      typedef typename Base::Node Node;
   1.174 +      typedef typename Base::RedNode RedNode;
   1.175 +      typedef typename Base::BlueNode BlueNode;
   1.176 +
   1.177 +      using Parent::id;
   1.178 +
   1.179 +      /// \brief Return a unique integer id for the given node in the red set.
   1.180 +      ///
   1.181 +      /// Return a unique integer id for the given node in the red set.
   1.182 +      int redId(const Node&) const { return -1; }
   1.183 +
   1.184 +      /// \brief Return the same value as redId().
   1.185 +      ///
   1.186 +      /// Return the same value as redId().
   1.187 +      int id(const RedNode&) const { return -1; }
   1.188 +
   1.189 +      /// \brief Return a unique integer id for the given node in the blue set.
   1.190 +      ///
   1.191 +      /// Return a unique integer id for the given node in the blue set.
   1.192 +      int blueId(const Node&) const { return -1; }
   1.193 +
   1.194 +      /// \brief Return the same value as blueId().
   1.195 +      ///
   1.196 +      /// Return the same value as blueId().
   1.197 +      int id(const BlueNode&) const { return -1; }
   1.198 +
   1.199 +      /// \brief Return an integer greater or equal to the maximum
   1.200 +      /// node id in the red set.
   1.201 +      ///
   1.202 +      /// Return an integer greater or equal to the maximum
   1.203 +      /// node id in the red set.
   1.204 +      int maxRedId() const { return -1; }
   1.205 +
   1.206 +      /// \brief Return an integer greater or equal to the maximum
   1.207 +      /// node id in the blue set.
   1.208 +      ///
   1.209 +      /// Return an integer greater or equal to the maximum
   1.210 +      /// node id in the blue set.
   1.211 +      int maxBlueId() const { return -1; }
   1.212 +
   1.213 +      template <typename _BpGraph>
   1.214 +      struct Constraints {
   1.215 +
   1.216 +        void constraints() {
   1.217 +          checkConcept<IDableGraphComponent<Base>, _BpGraph>();
   1.218 +          typename _BpGraph::Node node;
   1.219 +          typename _BpGraph::RedNode red;
   1.220 +          typename _BpGraph::BlueNode blue;
   1.221 +          int rid = bpgraph.redId(node);
   1.222 +          int bid = bpgraph.blueId(node);
   1.223 +          rid = bpgraph.id(red);
   1.224 +          bid = bpgraph.id(blue);
   1.225 +          rid = bpgraph.maxRedId();
   1.226 +          bid = bpgraph.maxBlueId();
   1.227 +          ignore_unused_variable_warning(rid);
   1.228 +          ignore_unused_variable_warning(bid);
   1.229 +        }
   1.230 +
   1.231 +        const _BpGraph& bpgraph;
   1.232 +      };
   1.233 +    };
   1.234 +
   1.235      /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
   1.236      ///
   1.237      /// This class describes the concept of \c NodeIt, \c ArcIt and
   1.238 @@ -904,6 +1125,92 @@
   1.239        };
   1.240      };
   1.241  
   1.242 +    /// \brief Skeleton class for iterable undirected bipartite graphs.
   1.243 +    ///
   1.244 +    /// This class describes the interface of iterable undirected
   1.245 +    /// bipartite graphs. It extends \ref IterableGraphComponent with
   1.246 +    /// the core iterable interface of undirected bipartite graphs.
   1.247 +    /// This concept is part of the BpGraph concept.
   1.248 +    template <typename BAS = BaseBpGraphComponent>
   1.249 +    class IterableBpGraphComponent : public IterableGraphComponent<BAS> {
   1.250 +    public:
   1.251 +
   1.252 +      typedef BAS Base;
   1.253 +      typedef typename Base::Node Node;
   1.254 +      typedef typename Base::Arc Arc;
   1.255 +      typedef typename Base::Edge Edge;
   1.256 +
   1.257 +
   1.258 +      typedef IterableBpGraphComponent BpGraph;
   1.259 +
   1.260 +      /// \name Base Iteration
   1.261 +      ///
   1.262 +      /// This interface provides functions for iteration on red and blue nodes.
   1.263 +      ///
   1.264 +      /// @{
   1.265 +
   1.266 +      /// \brief Return the first red node.
   1.267 +      ///
   1.268 +      /// This function gives back the first red node in the iteration order.
   1.269 +      void firstRed(Node&) const {}
   1.270 +
   1.271 +      /// \brief Return the next red node.
   1.272 +      ///
   1.273 +      /// This function gives back the next red node in the iteration order.
   1.274 +      void nextRed(Node&) const {}
   1.275 +
   1.276 +      /// \brief Return the first blue node.
   1.277 +      ///
   1.278 +      /// This function gives back the first blue node in the iteration order.
   1.279 +      void firstBlue(Node&) const {}
   1.280 +
   1.281 +      /// \brief Return the next blue node.
   1.282 +      ///
   1.283 +      /// This function gives back the next blue node in the iteration order.
   1.284 +      void nextBlue(Node&) const {}
   1.285 +
   1.286 +
   1.287 +      /// @}
   1.288 +
   1.289 +      /// \name Class Based Iteration
   1.290 +      ///
   1.291 +      /// This interface provides iterator classes for red and blue nodes.
   1.292 +      ///
   1.293 +      /// @{
   1.294 +
   1.295 +      /// \brief This iterator goes through each red node.
   1.296 +      ///
   1.297 +      /// This iterator goes through each red node.
   1.298 +      typedef GraphItemIt<BpGraph, Node> RedIt;
   1.299 +
   1.300 +      /// \brief This iterator goes through each blue node.
   1.301 +      ///
   1.302 +      /// This iterator goes through each blue node.
   1.303 +      typedef GraphItemIt<BpGraph, Node> BlueIt;
   1.304 +
   1.305 +      /// @}
   1.306 +
   1.307 +      template <typename _BpGraph>
   1.308 +      struct Constraints {
   1.309 +        void constraints() {
   1.310 +          checkConcept<IterableGraphComponent<Base>, _BpGraph>();
   1.311 +
   1.312 +          typename _BpGraph::Node node(INVALID);
   1.313 +          bpgraph.firstRed(node);
   1.314 +          bpgraph.nextRed(node); 
   1.315 +          bpgraph.firstBlue(node);
   1.316 +          bpgraph.nextBlue(node);
   1.317 +
   1.318 +          checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>,
   1.319 +            typename _BpGraph::RedIt>();
   1.320 +          checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::Node>,
   1.321 +            typename _BpGraph::BlueIt>();
   1.322 +        }
   1.323 +
   1.324 +        const _BpGraph& bpgraph;
   1.325 +      };
   1.326 +    };
   1.327 +
   1.328      /// \brief Skeleton class for alterable directed graphs.
   1.329      ///
   1.330      /// This class describes the interface of alterable directed
   1.331 @@ -929,18 +1236,21 @@
   1.332        typedef AlterationNotifier<AlterableDigraphComponent, Arc>
   1.333        ArcNotifier;
   1.334  
   1.335 +      mutable NodeNotifier node_notifier;
   1.336 +      mutable ArcNotifier arc_notifier;
   1.337 +
   1.338        /// \brief Return the node alteration notifier.
   1.339        ///
   1.340        /// This function gives back the node alteration notifier.
   1.341        NodeNotifier& notifier(Node) const {
   1.342 -         return NodeNotifier();
   1.343 +        return node_notifier;
   1.344        }
   1.345  
   1.346        /// \brief Return the arc alteration notifier.
   1.347        ///
   1.348        /// This function gives back the arc alteration notifier.
   1.349        ArcNotifier& notifier(Arc) const {
   1.350 -        return ArcNotifier();
   1.351 +        return arc_notifier;
   1.352        }
   1.353  
   1.354        template <typename _Digraph>
   1.355 @@ -976,6 +1286,7 @@
   1.356      public:
   1.357  
   1.358        typedef BAS Base;
   1.359 +      typedef AlterableDigraphComponent<Base> Parent;
   1.360        typedef typename Base::Edge Edge;
   1.361  
   1.362  
   1.363 @@ -983,11 +1294,15 @@
   1.364        typedef AlterationNotifier<AlterableGraphComponent, Edge>
   1.365        EdgeNotifier;
   1.366  
   1.367 +      mutable EdgeNotifier edge_notifier;
   1.368 +
   1.369 +      using Parent::notifier;
   1.370 +
   1.371        /// \brief Return the edge alteration notifier.
   1.372        ///
   1.373        /// This function gives back the edge alteration notifier.
   1.374        EdgeNotifier& notifier(Edge) const {
   1.375 -        return EdgeNotifier();
   1.376 +        return edge_notifier;
   1.377        }
   1.378  
   1.379        template <typename _Graph>
   1.380 @@ -1004,6 +1319,68 @@
   1.381        };
   1.382      };
   1.383  
   1.384 +    /// \brief Skeleton class for alterable undirected bipartite graphs.
   1.385 +    ///
   1.386 +    /// This class describes the interface of alterable undirected
   1.387 +    /// bipartite graphs. It extends \ref AlterableGraphComponent with
   1.388 +    /// the alteration notifier interface of bipartite graphs. It
   1.389 +    /// implements an observer-notifier pattern for the red and blue
   1.390 +    /// nodes. More obsevers can be registered into the notifier and
   1.391 +    /// whenever an alteration occured in the graph all the observers
   1.392 +    /// will be notified about it.
   1.393 +    template <typename BAS = BaseBpGraphComponent>
   1.394 +    class AlterableBpGraphComponent : public AlterableGraphComponent<BAS> {
   1.395 +    public:
   1.396 +
   1.397 +      typedef BAS Base;
   1.398 +      typedef AlterableGraphComponent<Base> Parent;
   1.399 +      typedef typename Base::RedNode RedNode;
   1.400 +      typedef typename Base::BlueNode BlueNode;
   1.401 +
   1.402 +
   1.403 +      /// Red node alteration notifier class.
   1.404 +      typedef AlterationNotifier<AlterableBpGraphComponent, RedNode>
   1.405 +      RedNodeNotifier;
   1.406 +
   1.407 +      /// Blue node alteration notifier class.
   1.408 +      typedef AlterationNotifier<AlterableBpGraphComponent, BlueNode>
   1.409 +      BlueNodeNotifier;
   1.410 +
   1.411 +      mutable RedNodeNotifier red_node_notifier;
   1.412 +      mutable BlueNodeNotifier blue_node_notifier;
   1.413 +
   1.414 +      using Parent::notifier;
   1.415 +
   1.416 +      /// \brief Return the red node alteration notifier.
   1.417 +      ///
   1.418 +      /// This function gives back the red node alteration notifier.
   1.419 +      RedNodeNotifier& notifier(RedNode) const {
   1.420 +        return red_node_notifier;
   1.421 +      }
   1.422 +
   1.423 +      /// \brief Return the blue node alteration notifier.
   1.424 +      ///
   1.425 +      /// This function gives back the blue node alteration notifier.
   1.426 +      BlueNodeNotifier& notifier(BlueNode) const {
   1.427 +        return blue_node_notifier;
   1.428 +      }
   1.429 +
   1.430 +      template <typename _BpGraph>
   1.431 +      struct Constraints {
   1.432 +        void constraints() {
   1.433 +          checkConcept<AlterableGraphComponent<Base>, _BpGraph>();
   1.434 +          typename _BpGraph::RedNodeNotifier& rnn
   1.435 +            = bpgraph.notifier(typename _BpGraph::RedNode());
   1.436 +          typename _BpGraph::BlueNodeNotifier& bnn
   1.437 +            = bpgraph.notifier(typename _BpGraph::BlueNode());
   1.438 +          ignore_unused_variable_warning(rnn);
   1.439 +          ignore_unused_variable_warning(bnn);
   1.440 +        }
   1.441 +
   1.442 +        const _BpGraph& bpgraph;
   1.443 +      };
   1.444 +    };
   1.445 +
   1.446      /// \brief Concept class for standard graph maps.
   1.447      ///
   1.448      /// This class describes the concept of standard graph maps, i.e.
   1.449 @@ -1307,6 +1684,143 @@
   1.450        };
   1.451      };
   1.452  
   1.453 +    /// \brief Skeleton class for mappable undirected bipartite graphs.
   1.454 +    ///
   1.455 +    /// This class describes the interface of mappable undirected
   1.456 +    /// bipartite graphs.  It extends \ref MappableGraphComponent with
   1.457 +    /// the standard graph map class for red and blue nodes (\c
   1.458 +    /// RedMap and BlueMap). This concept is part of the BpGraph concept.
   1.459 +    template <typename BAS = BaseBpGraphComponent>
   1.460 +    class MappableBpGraphComponent : public MappableGraphComponent<BAS>  {
   1.461 +    public:
   1.462 +
   1.463 +      typedef BAS Base;
   1.464 +      typedef typename Base::Node Node;
   1.465 +
   1.466 +      typedef MappableBpGraphComponent BpGraph;
   1.467 +
   1.468 +      /// \brief Standard graph map for the red nodes.
   1.469 +      ///
   1.470 +      /// Standard graph map for the red nodes.
   1.471 +      /// It conforms to the ReferenceMap concept.
   1.472 +      template <typename V>
   1.473 +      class RedMap : public GraphMap<MappableBpGraphComponent, Node, V> {
   1.474 +        typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
   1.475 +
   1.476 +      public:
   1.477 +        /// \brief Construct a new map.
   1.478 +        ///
   1.479 +        /// Construct a new map for the graph.
   1.480 +        explicit RedMap(const MappableBpGraphComponent& graph)
   1.481 +          : Parent(graph) {}
   1.482 +
   1.483 +        /// \brief Construct a new map with default value.
   1.484 +        ///
   1.485 +        /// Construct a new map for the graph and initalize the values.
   1.486 +        RedMap(const MappableBpGraphComponent& graph, const V& value)
   1.487 +          : Parent(graph, value) {}
   1.488 +
   1.489 +      private:
   1.490 +        /// \brief Copy constructor.
   1.491 +        ///
   1.492 +        /// Copy Constructor.
   1.493 +        RedMap(const RedMap& nm) : Parent(nm) {}
   1.494 +
   1.495 +        /// \brief Assignment operator.
   1.496 +        ///
   1.497 +        /// Assignment operator.
   1.498 +        template <typename CMap>
   1.499 +        RedMap& operator=(const CMap&) {
   1.500 +          checkConcept<ReadMap<Node, V>, CMap>();
   1.501 +          return *this;
   1.502 +        }
   1.503 +
   1.504 +      };
   1.505 +
   1.506 +      /// \brief Standard graph map for the blue nodes.
   1.507 +      ///
   1.508 +      /// Standard graph map for the blue nodes.
   1.509 +      /// It conforms to the ReferenceMap concept.
   1.510 +      template <typename V>
   1.511 +      class BlueMap : public GraphMap<MappableBpGraphComponent, Node, V> {
   1.512 +        typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
   1.513 +
   1.514 +      public:
   1.515 +        /// \brief Construct a new map.
   1.516 +        ///
   1.517 +        /// Construct a new map for the graph.
   1.518 +        explicit BlueMap(const MappableBpGraphComponent& graph)
   1.519 +          : Parent(graph) {}
   1.520 +
   1.521 +        /// \brief Construct a new map with default value.
   1.522 +        ///
   1.523 +        /// Construct a new map for the graph and initalize the values.
   1.524 +        BlueMap(const MappableBpGraphComponent& graph, const V& value)
   1.525 +          : Parent(graph, value) {}
   1.526 +
   1.527 +      private:
   1.528 +        /// \brief Copy constructor.
   1.529 +        ///
   1.530 +        /// Copy Constructor.
   1.531 +        BlueMap(const BlueMap& nm) : Parent(nm) {}
   1.532 +
   1.533 +        /// \brief Assignment operator.
   1.534 +        ///
   1.535 +        /// Assignment operator.
   1.536 +        template <typename CMap>
   1.537 +        BlueMap& operator=(const CMap&) {
   1.538 +          checkConcept<ReadMap<Node, V>, CMap>();
   1.539 +          return *this;
   1.540 +        }
   1.541 +
   1.542 +      };
   1.543 +
   1.544 +
   1.545 +      template <typename _BpGraph>
   1.546 +      struct Constraints {
   1.547 +
   1.548 +        struct Dummy {
   1.549 +          int value;
   1.550 +          Dummy() : value(0) {}
   1.551 +          Dummy(int _v) : value(_v) {}
   1.552 +        };
   1.553 +
   1.554 +        void constraints() {
   1.555 +          checkConcept<MappableGraphComponent<Base>, _BpGraph>();
   1.556 +
   1.557 +          { // int map test
   1.558 +            typedef typename _BpGraph::template RedMap<int> IntRedMap;
   1.559 +            checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, int>,
   1.560 +              IntRedMap >();
   1.561 +          } { // bool map test
   1.562 +            typedef typename _BpGraph::template RedMap<bool> BoolRedMap;
   1.563 +            checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, bool>,
   1.564 +              BoolRedMap >();
   1.565 +          } { // Dummy map test
   1.566 +            typedef typename _BpGraph::template RedMap<Dummy> DummyRedMap;
   1.567 +            checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, Dummy>,
   1.568 +              DummyRedMap >();
   1.569 +          }
   1.570 +
   1.571 +          { // int map test
   1.572 +            typedef typename _BpGraph::template BlueMap<int> IntBlueMap;
   1.573 +            checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, int>,
   1.574 +              IntBlueMap >();
   1.575 +          } { // bool map test
   1.576 +            typedef typename _BpGraph::template BlueMap<bool> BoolBlueMap;
   1.577 +            checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, bool>,
   1.578 +              BoolBlueMap >();
   1.579 +          } { // Dummy map test
   1.580 +            typedef typename _BpGraph::template BlueMap<Dummy> DummyBlueMap;
   1.581 +            checkConcept<GraphMap<_BpGraph, typename _BpGraph::Node, Dummy>,
   1.582 +              DummyBlueMap >();
   1.583 +          }
   1.584 +        }
   1.585 +
   1.586 +        const _BpGraph& bpgraph;
   1.587 +      };
   1.588 +    };
   1.589 +
   1.590      /// \brief Skeleton class for extendable directed graphs.
   1.591      ///
   1.592      /// This class describes the interface of extendable directed graphs.
   1.593 @@ -1397,6 +1911,58 @@
   1.594        };
   1.595      };
   1.596  
   1.597 +    /// \brief Skeleton class for extendable undirected bipartite graphs.
   1.598 +    ///
   1.599 +    /// This class describes the interface of extendable undirected
   1.600 +    /// bipartite graphs. It extends \ref BaseGraphComponent with
   1.601 +    /// functions for adding nodes and edges to the graph. This
   1.602 +    /// concept requires \ref AlterableBpGraphComponent.
   1.603 +    template <typename BAS = BaseBpGraphComponent>
   1.604 +    class ExtendableBpGraphComponent : public BAS {
   1.605 +    public:
   1.606 +
   1.607 +      typedef BAS Base;
   1.608 +      typedef typename Base::Node Node;
   1.609 +      typedef typename Base::Edge Edge;
   1.610 +
   1.611 +      /// \brief Add a new red node to the digraph.
   1.612 +      ///
   1.613 +      /// This function adds a red new node to the digraph.
   1.614 +      Node addRedNode() {
   1.615 +        return INVALID;
   1.616 +      }
   1.617 +
   1.618 +      /// \brief Add a new blue node to the digraph.
   1.619 +      ///
   1.620 +      /// This function adds a blue new node to the digraph.
   1.621 +      Node addBlueNode() {
   1.622 +        return INVALID;
   1.623 +      }
   1.624 +
   1.625 +      /// \brief Add a new edge connecting the given two nodes.
   1.626 +      ///
   1.627 +      /// This function adds a new edge connecting the given two nodes
   1.628 +      /// of the graph. The first node has to be a red node, and the
   1.629 +      /// second one a blue node.
   1.630 +      Edge addEdge(const Node&, const Node&) {
   1.631 +        return INVALID;
   1.632 +      }
   1.633 +
   1.634 +      template <typename _BpGraph>
   1.635 +      struct Constraints {
   1.636 +        void constraints() {
   1.637 +          checkConcept<Base, _BpGraph>();
   1.638 +          typename _BpGraph::Node red_node, blue_node;
   1.639 +          red_node = bpgraph.addRedNode();
   1.640 +          blue_node = bpgraph.addBlueNode();
   1.641 +          typename _BpGraph::Edge edge;
   1.642 +          edge = bpgraph.addEdge(red_node, blue_node);
   1.643 +        }
   1.644 +
   1.645 +        _BpGraph& bpgraph;
   1.646 +      };
   1.647 +    };
   1.648 +
   1.649      /// \brief Skeleton class for erasable directed graphs.
   1.650      ///
   1.651      /// This class describes the interface of erasable directed graphs.
   1.652 @@ -1477,6 +2043,15 @@
   1.653        };
   1.654      };
   1.655  
   1.656 +    /// \brief Skeleton class for erasable undirected graphs.
   1.657 +    ///
   1.658 +    /// This class describes the interface of erasable undirected
   1.659 +    /// bipartite graphs. It extends \ref BaseBpGraphComponent with
   1.660 +    /// functions for removing nodes and edges from the graph. This
   1.661 +    /// concept requires \ref AlterableBpGraphComponent.
   1.662 +    template <typename BAS = BaseBpGraphComponent>
   1.663 +    class ErasableBpGraphComponent : public ErasableGraphComponent<BAS> {};
   1.664 +
   1.665      /// \brief Skeleton class for clearable directed graphs.
   1.666      ///
   1.667      /// This class describes the interface of clearable directed graphs.
   1.668 @@ -1513,27 +2088,16 @@
   1.669      /// the graph.
   1.670      /// This concept requires \ref AlterableGraphComponent.
   1.671      template <typename BAS = BaseGraphComponent>
   1.672 -    class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {
   1.673 -    public:
   1.674 +    class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {};
   1.675  
   1.676 -      typedef BAS Base;
   1.677 -
   1.678 -      /// \brief Erase all nodes and edges from the graph.
   1.679 -      ///
   1.680 -      /// This function erases all nodes and edges from the graph.
   1.681 -      void clear() {}
   1.682 -
   1.683 -      template <typename _Graph>
   1.684 -      struct Constraints {
   1.685 -        void constraints() {
   1.686 -          checkConcept<Base, _Graph>();
   1.687 -          graph.clear();
   1.688 -        }
   1.689 -
   1.690 -        _Graph& graph;
   1.691 -        Constraints() {}
   1.692 -      };
   1.693 -    };
   1.694 +    /// \brief Skeleton class for clearable undirected biparite graphs.
   1.695 +    ///
   1.696 +    /// This class describes the interface of clearable undirected
   1.697 +    /// bipartite graphs. It extends \ref BaseBpGraphComponent with a
   1.698 +    /// function for clearing the graph.  This concept requires \ref
   1.699 +    /// AlterableBpGraphComponent.
   1.700 +    template <typename BAS = BaseBpGraphComponent>
   1.701 +    class ClearableBpGraphComponent : public ClearableGraphComponent<BAS> {};
   1.702  
   1.703    }
   1.704