[Lemon-commits] [lemon_svn] deba: r2569 - in hugo/trunk: demo lemon lemon/bits lemon/concept test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:53:37 CET 2006
Author: deba
Date: Wed Feb 22 19:26:56 2006
New Revision: 2569
Added:
hugo/trunk/demo/grid_ugraph_demo.cc
- copied unchanged from r2568, /hugo/branches/extendermerge/demo/grid_ugraph_demo.cc
hugo/trunk/demo/grid_ugraph_demo.in
- copied unchanged from r2568, /hugo/branches/extendermerge/demo/grid_ugraph_demo.in
hugo/trunk/lemon/bits/edge_set_extender.h
- copied unchanged from r2568, /hugo/branches/extendermerge/lemon/bits/edge_set_extender.h
hugo/trunk/lemon/bits/graph_adaptor_extender.h
- copied unchanged from r2568, /hugo/branches/extendermerge/lemon/bits/graph_adaptor_extender.h
hugo/trunk/lemon/grid_ugraph.h
- copied unchanged from r2568, /hugo/branches/extendermerge/lemon/grid_ugraph.h
hugo/trunk/lemon/ugraph_adaptor.h
- copied unchanged from r2568, /hugo/branches/extendermerge/lemon/ugraph_adaptor.h
Removed:
hugo/trunk/demo/grid_graph_demo.cc
hugo/trunk/demo/grid_graph_demo.in
hugo/trunk/lemon/bits/clearable_graph_extender.h
hugo/trunk/lemon/bits/erasable_graph_extender.h
hugo/trunk/lemon/bits/extendable_graph_extender.h
hugo/trunk/lemon/bits/iterable_graph_extender.h
hugo/trunk/lemon/grid_graph.h
Modified:
hugo/trunk/demo/Makefile.am
hugo/trunk/lemon/Makefile.am
hugo/trunk/lemon/bits/alteration_notifier.h
hugo/trunk/lemon/bits/default_map.h
hugo/trunk/lemon/bits/graph_extender.h
hugo/trunk/lemon/bits/static_map.h
hugo/trunk/lemon/concept/bpugraph.h
hugo/trunk/lemon/concept/graph.h
hugo/trunk/lemon/concept/ugraph.h
hugo/trunk/lemon/edge_set.h
hugo/trunk/lemon/euler.h
hugo/trunk/lemon/fredman_tarjan.h
hugo/trunk/lemon/full_graph.h
hugo/trunk/lemon/graph_adaptor.h
hugo/trunk/lemon/hypercube_graph.h
hugo/trunk/lemon/kruskal.h
hugo/trunk/lemon/list_graph.h
hugo/trunk/lemon/prim.h
hugo/trunk/lemon/radix_sort.h
hugo/trunk/lemon/smart_graph.h
hugo/trunk/lemon/sub_graph.h
hugo/trunk/lemon/topology.h
hugo/trunk/lemon/traits.h
hugo/trunk/test/graph_adaptor_test.cc
hugo/trunk/test/ugraph_test.cc
Log:
Mergeing extendermerge branch
Changes:
the extender system
resize for static size graph
UGraphExtender => UndirectGraphExtender
UGraphExtenders with changed meaning
Some UGraphExtender /SubUGraphExtenders, DirectUGraphExtender/
GridGraph => GridUGraph
radix sort to ansi compatible
Modified: hugo/trunk/demo/Makefile.am
==============================================================================
--- hugo/trunk/demo/Makefile.am (original)
+++ hugo/trunk/demo/Makefile.am Wed Feb 22 19:26:56 2006
@@ -16,7 +16,7 @@
sub_graph_adaptor_demo \
descriptor_map_demo \
coloring \
- grid_graph_demo \
+ grid_ugraph_demo \
topology_demo \
simann_maxcut_demo
@@ -43,7 +43,7 @@
graph_to_eps_demo_SOURCES = graph_to_eps_demo.cc
-grid_graph_demo_SOURCES = grid_graph_demo.cc
+grid_ugraph_demo_SOURCES = grid_ugraph_demo.cc
graph_orientation_SOURCES = graph_orientation.cc
Modified: hugo/trunk/lemon/Makefile.am
==============================================================================
--- hugo/trunk/lemon/Makefile.am (original)
+++ hugo/trunk/lemon/Makefile.am Wed Feb 22 19:26:56 2006
@@ -40,7 +40,7 @@
floyd_warshall.h \
fredman_tarjan.h \
full_graph.h \
- grid_graph.h \
+ grid_ugraph.h \
graph_adaptor.h \
graph_utils.h \
graph_to_eps.h \
@@ -75,6 +75,7 @@
time_measure.h \
topology.h \
traits.h \
+ ugraph_adaptor.h \
unionfind.h \
xy.h \
concept_check.h \
@@ -87,14 +88,12 @@
bits/alteration_notifier.h \
bits/array_map.h \
bits/default_map.h \
+ bits/static_map.h \
bits/vector_map.h \
- bits/iterable_graph_extender.h \
- bits/extendable_graph_extender.h \
- bits/clearable_graph_extender.h \
- bits/erasable_graph_extender.h \
- bits/graph_extender.h \
bits/map_extender.h \
- bits/static_map.h \
+ bits/graph_extender.h \
+ bits/graph_adaptor_extender.h \
+ bits/edge_set_extender.h \
bits/item_reader.h \
bits/item_writer.h \
concept/bpugraph.h \
Modified: hugo/trunk/lemon/bits/alteration_notifier.h
==============================================================================
--- hugo/trunk/lemon/bits/alteration_notifier.h (original)
+++ hugo/trunk/lemon/bits/alteration_notifier.h Wed Feb 22 19:26:56 2006
@@ -265,8 +265,16 @@
///
void add(const Item& item) {
typename Container::iterator it;
- for (it = container.begin(); it != container.end(); ++it) {
- (*it)->add(item);
+ try {
+ for (it = container.begin(); it != container.end(); ++it) {
+ (*it)->add(item);
+ }
+ } catch (...) {
+ typename Container::iterator jt;
+ for (jt = container.begin(); jt != it; ++it) {
+ (*it)->erase(item);
+ }
+ throw;
}
}
@@ -278,8 +286,16 @@
///
void add(const std::vector<Item>& items) {
typename Container::iterator it;
- for (it = container.begin(); it != container.end(); ++it) {
- (*it)->add(items);
+ try {
+ for (it = container.begin(); it != container.end(); ++it) {
+ (*it)->add(items);
+ }
+ } catch (...) {
+ typename Container::iterator jt;
+ for (jt = container.begin(); jt != it; ++it) {
+ (*it)->erase(items);
+ }
+ throw;
}
}
@@ -316,8 +332,16 @@
/// from an empty container.
void build() {
typename Container::iterator it;
- for (it = container.begin(); it != container.end(); ++it) {
- (*it)->build();
+ try {
+ for (it = container.begin(); it != container.end(); ++it) {
+ (*it)->build();
+ }
+ } catch (...) {
+ typename Container::iterator jt;
+ for (jt = container.begin(); jt != it; ++it) {
+ (*it)->clear();
+ }
+ throw;
}
}
@@ -335,232 +359,6 @@
}
};
-
- /// \brief Class to extend a graph with the functionality of alteration
- /// observing.
- ///
- /// AlterableGraphExtender extends the _Base graphs functionality with
- /// the possibility of alteration observing. It defines two observer
- /// registrys for the nodes and mapes.
- ///
- /// \todo Document what "alteration observing" is. And probably find a
- /// better (shorter) name.
- ///
- /// \param _Base is the base class to extend.
- ///
- /// \pre _Base is conform to the BaseGraphComponent concept.
- ///
- /// \post AlterableGraphExtender<_Base> is conform to the
- /// AlterableGraphComponent concept.
- ///
- /// \author Balazs Dezso
-
- template <typename _Base>
- class AlterableGraphExtender : public _Base {
- public:
-
- typedef AlterableGraphExtender Graph;
- typedef _Base Parent;
-
- typedef typename Parent::Node Node;
- typedef typename Parent::Edge Edge;
-
- /// The edge observer registry.
- typedef AlterationNotifier<Edge> EdgeNotifier;
- /// The node observer registry.
- typedef AlterationNotifier<Node> NodeNotifier;
-
-
- protected:
-
- mutable EdgeNotifier edge_notifier;
-
- mutable NodeNotifier node_notifier;
-
- public:
-
- /// \brief Gives back the edge alteration notifier.
- ///
- /// Gives back the edge alteration notifier.
- EdgeNotifier& getNotifier(Edge) const {
- return edge_notifier;
- }
-
- /// \brief Gives back the node alteration notifier.
- ///
- /// Gives back the node alteration notifier.
- NodeNotifier& getNotifier(Node) const {
- return node_notifier;
- }
-
- ~AlterableGraphExtender() {
- node_notifier.clear();
- edge_notifier.clear();
- }
-
- };
-
-
- template <typename _Base>
- class AlterableEdgeSetExtender : public _Base {
- public:
-
- typedef AlterableEdgeSetExtender Graph;
- typedef _Base Parent;
-
- typedef typename Parent::Edge Edge;
-
- /// The edge observer registry.
- typedef AlterationNotifier<Edge> EdgeNotifier;
-
- protected:
-
- mutable EdgeNotifier edge_notifier;
-
- public:
-
- /// \brief Gives back the edge alteration notifier.
- ///
- /// Gives back the edge alteration notifier.
- EdgeNotifier& getNotifier(Edge) const {
- return edge_notifier;
- }
-
- ~AlterableEdgeSetExtender() {
- edge_notifier.clear();
- }
-
- };
-
- /// \brief Class to extend an undirected graph with the functionality of
- /// alteration observing.
- ///
- /// \todo Document.
- ///
- /// \sa AlterableGraphExtender
- ///
- /// \bug This should be done some other way. Possibilities: template
- /// specialization (not very easy, if at all possible); some kind of
- /// enable_if boost technique?
-
- template <typename _Base>
- class AlterableUGraphExtender
- : public AlterableGraphExtender<_Base> {
- public:
-
- typedef AlterableUGraphExtender Graph;
- typedef AlterableGraphExtender<_Base> Parent;
-
- typedef typename Parent::UEdge UEdge;
-
- /// The edge observer registry.
- typedef AlterationNotifier<UEdge> UEdgeNotifier;
-
- protected:
-
- mutable UEdgeNotifier u_edge_notifier;
-
- public:
-
- using Parent::getNotifier;
- UEdgeNotifier& getNotifier(UEdge) const {
- return u_edge_notifier;
- }
-
- ~AlterableUGraphExtender() {
- u_edge_notifier.clear();
- }
- };
-
- template <typename _Base>
- class AlterableUEdgeSetExtender
- : public AlterableEdgeSetExtender<_Base> {
- public:
-
- typedef AlterableUEdgeSetExtender Graph;
- typedef AlterableEdgeSetExtender<_Base> Parent;
-
- typedef typename Parent::UEdge UEdge;
-
- typedef AlterationNotifier<UEdge> UEdgeNotifier;
-
- protected:
-
- mutable UEdgeNotifier u_edge_notifier;
-
- public:
-
- using Parent::getNotifier;
- UEdgeNotifier& getNotifier(UEdge) const {
- return u_edge_notifier;
- }
-
- ~AlterableUEdgeSetExtender() {
- u_edge_notifier.clear();
- }
- };
-
-
-
- template <typename _Base>
- class AlterableBpUGraphExtender : public _Base {
- public:
-
- typedef _Base Parent;
- typedef AlterableBpUGraphExtender Graph;
-
- typedef typename Parent::Node Node;
- typedef typename Parent::BNode BNode;
- typedef typename Parent::ANode ANode;
- typedef typename Parent::Edge Edge;
- typedef typename Parent::UEdge UEdge;
-
-
- typedef AlterationNotifier<Node> NodeNotifier;
- typedef AlterationNotifier<BNode> BNodeNotifier;
- typedef AlterationNotifier<ANode> ANodeNotifier;
- typedef AlterationNotifier<Edge> EdgeNotifier;
- typedef AlterationNotifier<UEdge> UEdgeNotifier;
-
- protected:
-
- mutable NodeNotifier nodeNotifier;
- mutable BNodeNotifier bNodeNotifier;
- mutable ANodeNotifier aNodeNotifier;
- mutable EdgeNotifier edgeNotifier;
- mutable UEdgeNotifier uEdgeNotifier;
-
- public:
-
- NodeNotifier& getNotifier(Node) const {
- return nodeNotifier;
- }
-
- BNodeNotifier& getNotifier(BNode) const {
- return bNodeNotifier;
- }
-
- ANodeNotifier& getNotifier(ANode) const {
- return aNodeNotifier;
- }
-
- EdgeNotifier& getNotifier(Edge) const {
- return edgeNotifier;
- }
-
- UEdgeNotifier& getNotifier(UEdge) const {
- return uEdgeNotifier;
- }
-
- ~AlterableBpUGraphExtender() {
- nodeNotifier.clear();
- bNodeNotifier.clear();
- aNodeNotifier.clear();
- edgeNotifier.clear();
- uEdgeNotifier.clear();
- }
-
- };
/// @}
Modified: hugo/trunk/lemon/bits/default_map.h
==============================================================================
--- hugo/trunk/lemon/bits/default_map.h (original)
+++ hugo/trunk/lemon/bits/default_map.h Wed Feb 22 19:26:56 2006
@@ -22,6 +22,7 @@
#include <lemon/bits/array_map.h>
#include <lemon/bits/vector_map.h>
+#include <lemon/bits/static_map.h>
///\ingroup graphmapfactory
///\file
@@ -30,7 +31,8 @@
namespace lemon {
-#ifndef GLIBCXX_DEBUG
+
+#ifndef _GLIBCXX_DEBUG
template <typename _Graph, typename _Item, typename _Value>
struct DefaultMapSelector {
@@ -167,483 +169,6 @@
};
-
- /// \e
- template <typename _Base>
- class MappableGraphExtender : public _Base {
- public:
-
- typedef MappableGraphExtender<_Base> Graph;
- typedef _Base Parent;
-
- typedef typename Parent::Node Node;
- typedef typename Parent::NodeIt NodeIt;
-
- typedef typename Parent::Edge Edge;
- typedef typename Parent::EdgeIt EdgeIt;
-
-
- template <typename _Value>
- class NodeMap
- : public IterableMapExtender<DefaultMap<Graph, Node, _Value> > {
- public:
- typedef MappableGraphExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, Node, _Value> > Parent;
-
- NodeMap(const Graph& _g)
- : Parent(_g) {}
- NodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- NodeMap& operator=(const NodeMap& cmap) {
- return operator=<NodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concecpt and could be indiced by the current item set of
- /// the NodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- NodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Node, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Node it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
- template <typename _Value>
- class EdgeMap
- : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
- public:
- typedef MappableGraphExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
-
- EdgeMap(const Graph& _g)
- : Parent(_g) {}
- EdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- EdgeMap& operator=(const EdgeMap& cmap) {
- return operator=<EdgeMap>(cmap);
- }
-
- template <typename CMap>
- EdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Edge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- };
-
- /// \e
- template <typename _Base>
- class MappableEdgeSetExtender : public _Base {
- public:
-
- typedef MappableEdgeSetExtender<_Base> Graph;
- typedef _Base Parent;
-
- typedef typename Parent::Edge Edge;
- typedef typename Parent::EdgeIt EdgeIt;
-
- template <typename _Value>
- class EdgeMap
- : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
- public:
- typedef MappableEdgeSetExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
-
- EdgeMap(const Graph& _g)
- : Parent(_g) {}
- EdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- EdgeMap& operator=(const EdgeMap& cmap) {
- return operator=<EdgeMap>(cmap);
- }
-
- template <typename CMap>
- EdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Edge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- };
-
- /// \e
- template <typename _Base>
- class MappableUGraphExtender :
- public MappableGraphExtender<_Base> {
- public:
-
- typedef MappableUGraphExtender Graph;
- typedef MappableGraphExtender<_Base> Parent;
-
- typedef typename Parent::UEdge UEdge;
-
- template <typename _Value>
- class UEdgeMap
- : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
- public:
- typedef MappableUGraphExtender Graph;
- typedef IterableMapExtender<
- DefaultMap<Graph, UEdge, _Value> > Parent;
-
- UEdgeMap(const Graph& _g)
- : Parent(_g) {}
- UEdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- UEdgeMap& operator=(const UEdgeMap& cmap) {
- return operator=<UEdgeMap>(cmap);
- }
-
- template <typename CMap>
- UEdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- UEdge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
-
- };
-
- /// \e
- template <typename _Base>
- class MappableUEdgeSetExtender :
- public MappableEdgeSetExtender<_Base> {
- public:
-
- typedef MappableUEdgeSetExtender Graph;
- typedef MappableEdgeSetExtender<_Base> Parent;
-
- typedef typename Parent::UEdge UEdge;
-
- template <typename _Value>
- class UEdgeMap
- : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
- public:
- typedef MappableUEdgeSetExtender Graph;
- typedef IterableMapExtender<
- DefaultMap<Graph, UEdge, _Value> > Parent;
-
- UEdgeMap(const Graph& _g)
- : Parent(_g) {}
- UEdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- UEdgeMap& operator=(const UEdgeMap& cmap) {
- return operator=<UEdgeMap>(cmap);
- }
-
- template <typename CMap>
- UEdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- UEdge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
-
- };
-
-
- template <typename _Base>
- class MappableBpUGraphExtender : public _Base {
- public:
-
- typedef _Base Parent;
- typedef MappableBpUGraphExtender Graph;
-
- typedef typename Parent::Node Node;
- typedef typename Parent::ANode ANode;
- typedef typename Parent::BNode BNode;
- typedef typename Parent::Edge Edge;
- typedef typename Parent::UEdge UEdge;
-
- template <typename _Value>
- class ANodeMap
- : public IterableMapExtender<DefaultMap<Graph, ANode, _Value> > {
- public:
- typedef MappableBpUGraphExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, ANode, _Value> >
- Parent;
-
- ANodeMap(const Graph& _g)
- : Parent(_g) {}
- ANodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- ANodeMap& operator=(const ANodeMap& cmap) {
- return operator=<ANodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concept and could be indiced by the current item set of
- /// the ANodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- ANodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- ANode it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
- template <typename _Value>
- class BNodeMap
- : public IterableMapExtender<DefaultMap<Graph, BNode, _Value> > {
- public:
- typedef MappableBpUGraphExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, BNode, _Value> >
- Parent;
-
- BNodeMap(const Graph& _g)
- : Parent(_g) {}
- BNodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- BNodeMap& operator=(const BNodeMap& cmap) {
- return operator=<BNodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concept and could be indiced by the current item set of
- /// the BNodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- BNodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- BNode it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
- protected:
-
- template <typename _Value>
- class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
- public:
- typedef MappableBpUGraphExtender Graph;
-
- typedef Node Key;
- typedef _Value Value;
-
- /// The reference type of the map;
- typedef typename BNodeMap<_Value>::Reference Reference;
- /// The pointer type of the map;
- typedef typename BNodeMap<_Value>::Pointer Pointer;
-
- /// The const value type of the map.
- typedef const Value ConstValue;
- /// The const reference type of the map;
- typedef typename BNodeMap<_Value>::ConstReference ConstReference;
- /// The pointer type of the map;
- typedef typename BNodeMap<_Value>::ConstPointer ConstPointer;
-
- typedef True ReferenceMapTag;
-
- NodeMapBase(const Graph& _g)
- : graph(&_g), bNodeMap(_g), aNodeMap(_g) {
- Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
- }
- NodeMapBase(const Graph& _g, const _Value& _v)
- : graph(&_g), bNodeMap(_g, _v),
- aNodeMap(_g, _v) {
- Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
- }
-
- virtual ~NodeMapBase() {
- if (Parent::NodeNotifier::ObserverBase::attached()) {
- Parent::NodeNotifier::ObserverBase::detach();
- }
- }
-
- ConstReference operator[](const Key& node) const {
- if (Parent::aNode(node)) {
- return aNodeMap[node];
- } else {
- return bNodeMap[node];
- }
- }
-
- Reference operator[](const Key& node) {
- if (Parent::aNode(node)) {
- return aNodeMap[node];
- } else {
- return bNodeMap[node];
- }
- }
-
- void set(const Key& node, const Value& value) {
- if (Parent::aNode(node)) {
- aNodeMap.set(node, value);
- } else {
- bNodeMap.set(node, value);
- }
- }
-
- protected:
-
- virtual void add(const Node&) {}
- virtual void add(const std::vector<Node>&) {}
- virtual void erase(const Node&) {}
- virtual void erase(const std::vector<Node>&) {}
- virtual void clear() {}
- virtual void build() {}
-
- const Graph* getGraph() const { return graph; }
-
- private:
- const Graph* graph;
- BNodeMap<_Value> bNodeMap;
- ANodeMap<_Value> aNodeMap;
- };
-
- public:
-
- template <typename _Value>
- class NodeMap
- : public IterableMapExtender<NodeMapBase<_Value> > {
- public:
- typedef MappableBpUGraphExtender Graph;
- typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
-
- NodeMap(const Graph& _g)
- : Parent(_g) {}
- NodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- NodeMap& operator=(const NodeMap& cmap) {
- return operator=<NodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concept and could be indiced by the current item set of
- /// the NodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- NodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Node, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Node it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
-
-
- template <typename _Value>
- class EdgeMap
- : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
- public:
- typedef MappableBpUGraphExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
-
- EdgeMap(const Graph& _g)
- : Parent(_g) {}
- EdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- EdgeMap& operator=(const EdgeMap& cmap) {
- return operator=<EdgeMap>(cmap);
- }
-
- template <typename CMap>
- EdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Edge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- template <typename _Value>
- class UEdgeMap
- : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
- public:
- typedef MappableBpUGraphExtender Graph;
- typedef IterableMapExtender<DefaultMap<Graph, UEdge, _Value> >
- Parent;
-
- UEdgeMap(const Graph& _g)
- : Parent(_g) {}
- UEdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- UEdgeMap& operator=(const UEdgeMap& cmap) {
- return operator=<UEdgeMap>(cmap);
- }
-
- template <typename CMap>
- UEdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- UEdge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- };
-
}
#endif
Modified: hugo/trunk/lemon/bits/graph_extender.h
==============================================================================
--- hugo/trunk/lemon/bits/graph_extender.h (original)
+++ hugo/trunk/lemon/bits/graph_extender.h Wed Feb 22 19:26:56 2006
@@ -22,15 +22,19 @@
#include <lemon/invalid.h>
#include <lemon/error.h>
+#include <lemon/bits/default_map.h>
+
namespace lemon {
- template <typename _Base>
- class GraphExtender : public _Base {
+ template <typename Base>
+ class GraphExtender : public Base {
public:
- typedef _Base Parent;
+ typedef Base Parent;
typedef GraphExtender Graph;
+ // Base extensions
+
typedef typename Parent::Node Node;
typedef typename Parent::Edge Edge;
@@ -59,24 +63,278 @@
return INVALID;
}
+ // Alterable extension
+
+ typedef AlterationNotifier<Node> NodeNotifier;
+ typedef AlterationNotifier<Edge> EdgeNotifier;
+
+
+ protected:
+
+ mutable NodeNotifier node_notifier;
+ mutable EdgeNotifier edge_notifier;
+
+ public:
+
+ NodeNotifier& getNotifier(Node) const {
+ return node_notifier;
+ }
+
+ EdgeNotifier& getNotifier(Edge) const {
+ return edge_notifier;
+ }
+
+ class NodeIt : public Node {
+ const Graph* graph;
+ public:
+
+ NodeIt() {}
+
+ NodeIt(Invalid i) : Node(i) { }
+
+ explicit NodeIt(const Graph& _graph) : graph(&_graph) {
+ _graph.first(*static_cast<Node*>(this));
+ }
+
+ NodeIt(const Graph& _graph, const Node& node)
+ : Node(node), graph(&_graph) {}
+
+ NodeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+
+ class EdgeIt : public Edge {
+ const Graph* graph;
+ public:
+
+ EdgeIt() { }
+
+ EdgeIt(Invalid i) : Edge(i) { }
+
+ explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
+ _graph.first(*static_cast<Edge*>(this));
+ }
+
+ EdgeIt(const Graph& _graph, const Edge& e) :
+ Edge(e), graph(&_graph) { }
+
+ EdgeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+
+ class OutEdgeIt : public Edge {
+ const Graph* graph;
+ public:
+
+ OutEdgeIt() { }
+
+ OutEdgeIt(Invalid i) : Edge(i) { }
+
+ OutEdgeIt(const Graph& _graph, const Node& node)
+ : graph(&_graph) {
+ _graph.firstOut(*this, node);
+ }
+
+ OutEdgeIt(const Graph& _graph, const Edge& edge)
+ : Edge(edge), graph(&_graph) {}
+
+ OutEdgeIt& operator++() {
+ graph->nextOut(*this);
+ return *this;
+ }
+
+ };
+
+
+ class InEdgeIt : public Edge {
+ const Graph* graph;
+ public:
+
+ InEdgeIt() { }
+
+ InEdgeIt(Invalid i) : Edge(i) { }
+
+ InEdgeIt(const Graph& _graph, const Node& node)
+ : graph(&_graph) {
+ _graph.firstIn(*this, node);
+ }
+
+ InEdgeIt(const Graph& _graph, const Edge& edge) :
+ Edge(edge), graph(&_graph) {}
+
+ InEdgeIt& operator++() {
+ graph->nextIn(*this);
+ return *this;
+ }
+
+ };
+
+ /// \brief Base node of the iterator
+ ///
+ /// Returns the base node (ie. the source in this case) of the iterator
+ Node baseNode(const OutEdgeIt &e) const {
+ return Parent::source(e);
+ }
+ /// \brief Running node of the iterator
+ ///
+ /// Returns the running node (ie. the target in this case) of the
+ /// iterator
+ Node runningNode(const OutEdgeIt &e) const {
+ return Parent::target(e);
+ }
+
+ /// \brief Base node of the iterator
+ ///
+ /// Returns the base node (ie. the target in this case) of the iterator
+ Node baseNode(const InEdgeIt &e) const {
+ return Parent::target(e);
+ }
+ /// \brief Running node of the iterator
+ ///
+ /// Returns the running node (ie. the source in this case) of the
+ /// iterator
+ Node runningNode(const InEdgeIt &e) const {
+ return Parent::source(e);
+ }
+
+
+ template <typename _Value>
+ class NodeMap
+ : public IterableMapExtender<DefaultMap<Graph, Node, _Value> > {
+ public:
+ typedef GraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, Node, _Value> > Parent;
+
+ NodeMap(const Graph& _g)
+ : Parent(_g) {}
+ NodeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ NodeMap& operator=(const NodeMap& cmap) {
+ return operator=<NodeMap>(cmap);
+ }
+
+
+ /// \brief Template assign operator.
+ ///
+ /// The given parameter should be conform to the ReadMap
+ /// concecpt and could be indiced by the current item set of
+ /// the NodeMap. In this case the value for each item
+ /// is assigned by the value of the given ReadMap.
+ template <typename CMap>
+ NodeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<Node, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ Node it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+
+ };
+
+ template <typename _Value>
+ class EdgeMap
+ : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
+ public:
+ typedef GraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
+
+ EdgeMap(const Graph& _g)
+ : Parent(_g) {}
+ EdgeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ EdgeMap& operator=(const EdgeMap& cmap) {
+ return operator=<EdgeMap>(cmap);
+ }
+
+ template <typename CMap>
+ EdgeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ Edge it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+ };
+
+
+ Node addNode() {
+ Node node = Parent::addNode();
+ getNotifier(Node()).add(node);
+ return node;
+ }
+
+ Edge addEdge(const Node& from, const Node& to) {
+ Edge edge = Parent::addEdge(from, to);
+ getNotifier(Edge()).add(edge);
+ return edge;
+ }
+
+ void clear() {
+ getNotifier(Edge()).clear();
+ getNotifier(Node()).clear();
+ Parent::clear();
+ }
+
+
+ void erase(const Node& node) {
+ Edge edge;
+ Parent::firstOut(edge, node);
+ while (edge != INVALID ) {
+ erase(edge);
+ Parent::firstOut(edge, node);
+ }
+
+ Parent::firstIn(edge, node);
+ while (edge != INVALID ) {
+ erase(edge);
+ Parent::firstIn(edge, node);
+ }
+
+ getNotifier(Node()).erase(node);
+ Parent::erase(node);
+ }
+
+ void erase(const Edge& edge) {
+ getNotifier(Edge()).erase(edge);
+ Parent::erase(edge);
+ }
+
+
+ ~GraphExtender() {
+ getNotifier(Edge()).clear();
+ getNotifier(Node()).clear();
+ }
};
- template <typename _Base>
- class UGraphExtender : public _Base {
- typedef _Base Parent;
- typedef UGraphExtender Graph;
+ template <typename Base>
+ class UGraphBaseExtender : public Base {
public:
+ typedef Base Parent;
typedef typename Parent::Edge UEdge;
typedef typename Parent::Node Node;
+ typedef True UndirectedTag;
+
class Edge : public UEdge {
- friend class UGraphExtender;
+ friend class UGraphBaseExtender;
protected:
- // FIXME: Marci use opposite logic in his graph adaptors. It would
- // be reasonable to syncronize...
bool forward;
Edge(const UEdge &ue, bool _forward) :
@@ -101,16 +359,7 @@
};
- /// \brief Edge of opposite direction.
- ///
- /// Returns the Edge of opposite direction.
- Edge oppositeEdge(const Edge &e) const {
- return Edge(e,!e.forward);
- }
- public:
- /// \todo Shouldn't the "source" of an undirected edge be called "aNode"
- /// or something???
using Parent::source;
/// Source of the given Edge.
@@ -118,8 +367,6 @@
return e.forward ? Parent::source(e) : Parent::target(e);
}
- /// \todo Shouldn't the "target" of an undirected edge be called "bNode"
- /// or something???
using Parent::target;
/// Target of the given Edge.
@@ -127,24 +374,6 @@
return e.forward ? Parent::target(e) : Parent::source(e);
}
- Node oppositeNode(const Node &n, const UEdge &e) const {
- if( n == Parent::source(e))
- return Parent::target(e);
- else if( n == Parent::target(e))
- return Parent::source(e);
- else
- return INVALID;
- }
-
- /// \brief Directed edge from an undirected edge and a source node.
- ///
- /// Returns a (directed) Edge corresponding to the specified UEdge
- /// and source Node.
- ///
- Edge direct(const UEdge &ue, const Node &s) const {
- return Edge(ue, s == source(ue));
- }
-
/// \brief Directed edge from an undirected edge.
///
/// Returns a directed edge corresponding to the specified UEdge.
@@ -163,12 +392,13 @@
using Parent::first;
+ using Parent::next;
+
void first(Edge &e) const {
Parent::first(e);
e.forward=true;
}
- using Parent::next;
void next(Edge &e) const {
if( e.forward ) {
e.forward = false;
@@ -179,8 +409,6 @@
}
}
- public:
-
void firstOut(Edge &e, const Node &n) const {
Parent::firstIn(e,n);
if( UEdge(e) != INVALID ) {
@@ -229,21 +457,6 @@
}
}
- void firstInc(UEdge &e, const Node &n) const {
- Parent::firstOut(e, n);
- if (e != INVALID) return;
- Parent::firstIn(e, n);
- }
- void nextInc(UEdge &e, const Node &n) const {
- if (Parent::source(e) == n) {
- Parent::nextOut(e);
- if (e != INVALID) return;
- Parent::firstIn(e, n);
- } else {
- Parent::nextIn(e);
- }
- }
-
void firstInc(UEdge &e, bool &d, const Node &n) const {
d = true;
Parent::firstOut(e, n);
@@ -251,6 +464,7 @@
d = false;
Parent::firstIn(e, n);
}
+
void nextInc(UEdge &e, bool &d) const {
if (d) {
Node s = Parent::source(e);
@@ -263,14 +477,17 @@
}
}
- // Miscellaneous stuff:
+ Node nodeFromId(int id) const {
+ return Parent::nodeFromId(id);
+ }
- /// \todo these methods (id, maxEdgeId) should be moved into separate
- /// Extender
+ Edge edgeFromId(int id) const {
+ return direct(Parent::edgeFromId(id >> 1), bool(id & 1));
+ }
- // using Parent::id;
- // Using "using" is not a good idea, cause it could be that there is
- // no "id" in Parent...
+ UEdge uEdgeFromId(int id) const {
+ return Parent::edgeFromId(id >> 1);
+ }
int id(const Node &n) const {
return Parent::id(n);
@@ -296,16 +513,6 @@
return Parent::maxEdgeId();
}
- int maxId(Node) const {
- return maxNodeId();
- }
-
- int maxId(Edge) const {
- return maxEdgeId();
- }
- int maxId(UEdge) const {
- return maxUEdgeId();
- }
int edgeNum() const {
return 2 * Parent::edgeNum();
@@ -315,31 +522,6 @@
return Parent::edgeNum();
}
- Node nodeFromId(int id) const {
- return Parent::nodeFromId(id);
- }
-
- Edge edgeFromId(int id) const {
- return direct(Parent::edgeFromId(id >> 1), bool(id & 1));
- }
-
- UEdge uEdgeFromId(int id) const {
- return Parent::edgeFromId(id >> 1);
- }
-
- Node fromId(int id, Node) const {
- return nodeFromId(id);
- }
-
- Edge fromId(int id, Edge) const {
- return edgeFromId(id);
- }
-
- UEdge fromId(int id, UEdge) const {
- return uEdgeFromId(id);
- }
-
-
Edge findEdge(Node source, Node target, Edge prev) const {
if (prev == INVALID) {
UEdge edge = Parent::findEdge(source, target);
@@ -375,168 +557,444 @@
}
return INVALID;
}
-
};
- template <typename _Base>
- class BpUGraphExtender : public _Base {
+ template <typename Base>
+ class UGraphExtender : public Base {
public:
- typedef _Base Parent;
- typedef BpUGraphExtender Graph;
+
+ typedef Base Parent;
+ typedef UGraphExtender Graph;
typedef typename Parent::Node Node;
- typedef typename Parent::Edge UEdge;
-
- using Parent::first;
- using Parent::next;
+ typedef typename Parent::Edge Edge;
+ typedef typename Parent::UEdge UEdge;
- using Parent::id;
+ // UGraph extension
- Node source(const UEdge& edge) const {
- return aNode(edge);
- }
- Node target(const UEdge& edge) const {
- return bNode(edge);
+ int maxId(Node) const {
+ return Parent::maxNodeId();
}
- void firstInc(UEdge& edge, bool& direction, const Node& node) const {
- if (Parent::aNode(node)) {
- Parent::firstOut(edge, node);
- direction = true;
- } else {
- Parent::firstIn(edge, node);
- direction = static_cast<UEdge&>(edge) == INVALID;
- }
+ int maxId(Edge) const {
+ return Parent::maxEdgeId();
}
- void nextInc(UEdge& edge, bool& direction) const {
- if (direction) {
- Parent::nextOut(edge);
- } else {
- Parent::nextIn(edge);
- if (edge == INVALID) direction = true;
- }
+
+ int maxId(UEdge) const {
+ return Parent::maxUEdgeId();
}
- int maxUEdgeId() const {
- return Parent::maxEdgeId();
+ Node fromId(int id, Node) const {
+ return Parent::nodeFromId(id);
}
- UEdge uEdgeFromId(int id) const {
+ Edge fromId(int id, Edge) const {
return Parent::edgeFromId(id);
}
- class Edge : public UEdge {
- friend class BpUGraphExtender;
- protected:
- bool forward;
-
- Edge(const UEdge& edge, bool _forward)
- : UEdge(edge), forward(_forward) {}
-
- public:
- Edge() {}
- Edge (Invalid) : UEdge(INVALID), forward(true) {}
- bool operator==(const Edge& i) const {
- return UEdge::operator==(i) && forward == i.forward;
- }
- bool operator!=(const Edge& i) const {
- return UEdge::operator!=(i) || forward != i.forward;
- }
- bool operator<(const Edge& i) const {
- return UEdge::operator<(i) ||
- (!(i.forward<forward) && UEdge(*this)<UEdge(i));
- }
- };
+ UEdge fromId(int id, UEdge) const {
+ return Parent::uEdgeFromId(id);
+ }
- void first(Edge& edge) const {
- Parent::first(static_cast<UEdge&>(edge));
- edge.forward = true;
+ Node oppositeNode(const Node &n, const UEdge &e) const {
+ if( n == Parent::source(e))
+ return Parent::target(e);
+ else if( n == Parent::target(e))
+ return Parent::source(e);
+ else
+ return INVALID;
}
- void next(Edge& edge) const {
- if (!edge.forward) {
- Parent::next(static_cast<UEdge&>(edge));
- }
- edge.forward = !edge.forward;
+ Edge oppositeEdge(const Edge &e) const {
+ return Parent::direct(e, !Parent::direction(e));
}
- void firstOut(Edge& edge, const Node& node) const {
- if (Parent::aNode(node)) {
- Parent::firstOut(edge, node);
- edge.forward = true;
- } else {
- Parent::firstIn(edge, node);
- edge.forward = static_cast<UEdge&>(edge) == INVALID;
- }
+ using Parent::direct;
+ Edge direct(const UEdge &ue, const Node &s) const {
+ return Parent::direct(ue, Parent::source(ue) == s);
}
- void nextOut(Edge& edge) const {
- if (edge.forward) {
- Parent::nextOut(edge);
- } else {
- Parent::nextIn(edge);
- edge.forward = static_cast<UEdge&>(edge) == INVALID;
- }
+
+ // Alterable extension
+
+ typedef AlterationNotifier<Node> NodeNotifier;
+ typedef AlterationNotifier<Edge> EdgeNotifier;
+ typedef AlterationNotifier<UEdge> UEdgeNotifier;
+
+
+ protected:
+
+ mutable NodeNotifier node_notifier;
+ mutable EdgeNotifier edge_notifier;
+ mutable UEdgeNotifier uedge_notifier;
+
+ public:
+
+ NodeNotifier& getNotifier(Node) const {
+ return node_notifier;
+ }
+
+ EdgeNotifier& getNotifier(Edge) const {
+ return edge_notifier;
}
- void firstIn(Edge& edge, const Node& node) const {
- if (Parent::bNode(node)) {
- Parent::firstIn(edge, node);
- edge.forward = true;
- } else {
- Parent::firstOut(edge, node);
- edge.forward = static_cast<UEdge&>(edge) == INVALID;
- }
+ UEdgeNotifier& getNotifier(UEdge) const {
+ return uedge_notifier;
}
- void nextIn(Edge& edge) const {
- if (edge.forward) {
- Parent::nextIn(edge);
- } else {
- Parent::nextOut(edge);
- edge.forward = static_cast<UEdge&>(edge) == INVALID;
+
+
+
+ class NodeIt : public Node {
+ const Graph* graph;
+ public:
+
+ NodeIt() {}
+
+ NodeIt(Invalid i) : Node(i) { }
+
+ explicit NodeIt(const Graph& _graph) : graph(&_graph) {
+ _graph.first(*static_cast<Node*>(this));
}
- }
- Node source(const Edge& edge) const {
- return edge.forward ? Parent::aNode(edge) : Parent::bNode(edge);
+ NodeIt(const Graph& _graph, const Node& node)
+ : Node(node), graph(&_graph) {}
+
+ NodeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+
+ class EdgeIt : public Edge {
+ const Graph* graph;
+ public:
+
+ EdgeIt() { }
+
+ EdgeIt(Invalid i) : Edge(i) { }
+
+ explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
+ _graph.first(*static_cast<Edge*>(this));
+ }
+
+ EdgeIt(const Graph& _graph, const Edge& e) :
+ Edge(e), graph(&_graph) { }
+
+ EdgeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+
+ class OutEdgeIt : public Edge {
+ const Graph* graph;
+ public:
+
+ OutEdgeIt() { }
+
+ OutEdgeIt(Invalid i) : Edge(i) { }
+
+ OutEdgeIt(const Graph& _graph, const Node& node)
+ : graph(&_graph) {
+ _graph.firstOut(*this, node);
+ }
+
+ OutEdgeIt(const Graph& _graph, const Edge& edge)
+ : Edge(edge), graph(&_graph) {}
+
+ OutEdgeIt& operator++() {
+ graph->nextOut(*this);
+ return *this;
+ }
+
+ };
+
+
+ class InEdgeIt : public Edge {
+ const Graph* graph;
+ public:
+
+ InEdgeIt() { }
+
+ InEdgeIt(Invalid i) : Edge(i) { }
+
+ InEdgeIt(const Graph& _graph, const Node& node)
+ : graph(&_graph) {
+ _graph.firstIn(*this, node);
+ }
+
+ InEdgeIt(const Graph& _graph, const Edge& edge) :
+ Edge(edge), graph(&_graph) {}
+
+ InEdgeIt& operator++() {
+ graph->nextIn(*this);
+ return *this;
+ }
+
+ };
+
+
+ class UEdgeIt : public Parent::UEdge {
+ const Graph* graph;
+ public:
+
+ UEdgeIt() { }
+
+ UEdgeIt(Invalid i) : UEdge(i) { }
+
+ explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
+ _graph.first(*static_cast<UEdge*>(this));
+ }
+
+ UEdgeIt(const Graph& _graph, const UEdge& e) :
+ UEdge(e), graph(&_graph) { }
+
+ UEdgeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+ class IncEdgeIt : public Parent::UEdge {
+ friend class UGraphExtender;
+ const Graph* graph;
+ bool direction;
+ public:
+
+ IncEdgeIt() { }
+
+ IncEdgeIt(Invalid i) : UEdge(i), direction(false) { }
+
+ IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
+ _graph.firstInc(*this, direction, n);
+ }
+
+ IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n)
+ : graph(&_graph), UEdge(ue) {
+ direction = (_graph.source(ue) == n);
+ }
+
+ IncEdgeIt& operator++() {
+ graph->nextInc(*this, direction);
+ return *this;
+ }
+ };
+
+ /// \brief Base node of the iterator
+ ///
+ /// Returns the base node (ie. the source in this case) of the iterator
+ Node baseNode(const OutEdgeIt &e) const {
+ return Parent::source((Edge)e);
}
- Node target(const Edge& edge) const {
- return edge.forward ? Parent::bNode(edge) : Parent::aNode(edge);
+ /// \brief Running node of the iterator
+ ///
+ /// Returns the running node (ie. the target in this case) of the
+ /// iterator
+ Node runningNode(const OutEdgeIt &e) const {
+ return Parent::target((Edge)e);
}
- bool direction(const Edge& edge) const {
- return edge.forward;
+ /// \brief Base node of the iterator
+ ///
+ /// Returns the base node (ie. the target in this case) of the iterator
+ Node baseNode(const InEdgeIt &e) const {
+ return Parent::target((Edge)e);
}
-
- Edge direct(const UEdge& edge, const Node& node) const {
- return Edge(edge, node == Parent::source(edge));
+ /// \brief Running node of the iterator
+ ///
+ /// Returns the running node (ie. the source in this case) of the
+ /// iterator
+ Node runningNode(const InEdgeIt &e) const {
+ return Parent::source((Edge)e);
}
- Edge direct(const UEdge& edge, bool direction) const {
- return Edge(edge, direction);
+ /// Base node of the iterator
+ ///
+ /// Returns the base node of the iterator
+ Node baseNode(const IncEdgeIt &e) const {
+ return e.direction ? source(e) : target(e);
}
-
- Node oppositeNode(const UEdge& edge, const Node& node) const {
- return source(edge) == node ?
- target(edge) : source(edge);
+ /// Running node of the iterator
+ ///
+ /// Returns the running node of the iterator
+ Node runningNode(const IncEdgeIt &e) const {
+ return e.direction ? target(e) : source(e);
}
- Edge oppositeEdge(const Edge& edge) const {
- return Edge(edge, !edge.forward);
- }
+ // Mappable extension
- int id(const Edge& edge) const {
- return (Parent::id(edge) << 1) + (edge.forward ? 0 : 1);
+ template <typename _Value>
+ class NodeMap
+ : public IterableMapExtender<DefaultMap<Graph, Node, _Value> > {
+ public:
+ typedef UGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, Node, _Value> > Parent;
+
+ NodeMap(const Graph& _g)
+ : Parent(_g) {}
+ NodeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ NodeMap& operator=(const NodeMap& cmap) {
+ return operator=<NodeMap>(cmap);
+ }
+
+
+ /// \brief Template assign operator.
+ ///
+ /// The given parameter should be conform to the ReadMap
+ /// concecpt and could be indiced by the current item set of
+ /// the NodeMap. In this case the value for each item
+ /// is assigned by the value of the given ReadMap.
+ template <typename CMap>
+ NodeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<Node, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ Node it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+
+ };
+
+ template <typename _Value>
+ class EdgeMap
+ : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
+ public:
+ typedef UGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
+
+ EdgeMap(const Graph& _g)
+ : Parent(_g) {}
+ EdgeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ EdgeMap& operator=(const EdgeMap& cmap) {
+ return operator=<EdgeMap>(cmap);
+ }
+
+ template <typename CMap>
+ EdgeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ Edge it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+ };
+
+
+ template <typename _Value>
+ class UEdgeMap
+ : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
+ public:
+ typedef UGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > Parent;
+
+ UEdgeMap(const Graph& _g)
+ : Parent(_g) {}
+ UEdgeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ UEdgeMap& operator=(const UEdgeMap& cmap) {
+ return operator=<UEdgeMap>(cmap);
+ }
+
+ template <typename CMap>
+ UEdgeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ UEdge it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+ };
+
+ // Alteration extension
+
+ Node addNode() {
+ Node node = Parent::addNode();
+ getNotifier(Node()).add(node);
+ return node;
+ }
+
+ UEdge addEdge(const Node& from, const Node& to) {
+ UEdge uedge = Parent::addEdge(from, to);
+ getNotifier(UEdge()).add(uedge);
+ getNotifier(Edge()).add(Parent::direct(uedge, true));
+ getNotifier(Edge()).add(Parent::direct(uedge, false));
+ return uedge;
+ }
+
+ void clear() {
+ getNotifier(Edge()).clear();
+ getNotifier(UEdge()).clear();
+ getNotifier(Node()).clear();
+ Parent::clear();
+ }
+
+ void erase(const Node& node) {
+ Edge edge;
+ Parent::firstOut(edge, node);
+ while (edge != INVALID ) {
+ erase(edge);
+ Parent::firstOut(edge, node);
+ }
+
+ Parent::firstIn(edge, node);
+ while (edge != INVALID ) {
+ erase(edge);
+ Parent::firstIn(edge, node);
+ }
+
+ getNotifier(Node()).erase(node);
+ Parent::erase(node);
}
- Edge edgeFromId(int id) const {
- return Edge(Parent::fromId(id >> 1, UEdge()), (id & 1) == 0);
+
+ void erase(const UEdge& uedge) {
+ getNotifier(Edge()).erase(Parent::direct(uedge, true));
+ getNotifier(Edge()).erase(Parent::direct(uedge, false));
+ getNotifier(UEdge()).erase(uedge);
+ Parent::erase(uedge);
}
- int maxEdgeId() const {
- return (Parent::maxId(UEdge()) << 1) + 1;
+
+ ~UGraphExtender() {
+ getNotifier(Edge()).clear();
+ getNotifier(UEdge()).clear();
+ getNotifier(Node()).clear();
}
+ };
+
+
+ template <typename Base>
+ class BpUGraphBaseExtender : public Base {
+ public:
+ typedef Base Parent;
+ typedef BpUGraphBaseExtender Graph;
+
+ typedef typename Parent::Node Node;
+ typedef typename Parent::Edge UEdge;
+
+
+ using Parent::first;
+ using Parent::next;
+
+ using Parent::id;
+
class ANode : public Node {
- friend class BpUGraphExtender;
+ friend class BpUGraphBaseExtender;
public:
ANode() {}
ANode(const Node& node) : Node(node) {
@@ -558,7 +1016,7 @@
}
class BNode : public Node {
- friend class BpUGraphExtender;
+ friend class BpUGraphBaseExtender;
public:
BNode() {}
BNode(const Node& node) : Node(node) {
@@ -579,6 +1037,161 @@
return Parent::aNodeId(node);
}
+ Node source(const UEdge& edge) const {
+ return aNode(edge);
+ }
+ Node target(const UEdge& edge) const {
+ return bNode(edge);
+ }
+
+ void firstInc(UEdge& edge, bool& direction, const Node& node) const {
+ if (Parent::aNode(node)) {
+ Parent::firstOut(edge, node);
+ direction = true;
+ } else {
+ Parent::firstIn(edge, node);
+ direction = static_cast<UEdge&>(edge) == INVALID;
+ }
+ }
+ void nextInc(UEdge& edge, bool& direction) const {
+ if (direction) {
+ Parent::nextOut(edge);
+ } else {
+ Parent::nextIn(edge);
+ if (edge == INVALID) direction = true;
+ }
+ }
+
+ int maxUEdgeId() const {
+ return Parent::maxEdgeId();
+ }
+
+ UEdge uEdgeFromId(int id) const {
+ return Parent::edgeFromId(id);
+ }
+
+ class Edge : public UEdge {
+ friend class BpUGraphBaseExtender;
+ protected:
+ bool forward;
+
+ Edge(const UEdge& edge, bool _forward)
+ : UEdge(edge), forward(_forward) {}
+
+ public:
+ Edge() {}
+ Edge (Invalid) : UEdge(INVALID), forward(true) {}
+ bool operator==(const Edge& i) const {
+ return UEdge::operator==(i) && forward == i.forward;
+ }
+ bool operator!=(const Edge& i) const {
+ return UEdge::operator!=(i) || forward != i.forward;
+ }
+ bool operator<(const Edge& i) const {
+ return UEdge::operator<(i) ||
+ (!(i.forward<forward) && UEdge(*this)<UEdge(i));
+ }
+ };
+
+ void first(Edge& edge) const {
+ Parent::first(static_cast<UEdge&>(edge));
+ edge.forward = true;
+ }
+
+ void next(Edge& edge) const {
+ if (!edge.forward) {
+ Parent::next(static_cast<UEdge&>(edge));
+ }
+ edge.forward = !edge.forward;
+ }
+
+ void firstOut(Edge& edge, const Node& node) const {
+ if (Parent::aNode(node)) {
+ Parent::firstOut(edge, node);
+ edge.forward = true;
+ } else {
+ Parent::firstIn(edge, node);
+ edge.forward = static_cast<UEdge&>(edge) == INVALID;
+ }
+ }
+ void nextOut(Edge& edge) const {
+ if (edge.forward) {
+ Parent::nextOut(edge);
+ } else {
+ Parent::nextIn(edge);
+ edge.forward = static_cast<UEdge&>(edge) == INVALID;
+ }
+ }
+
+ void firstIn(Edge& edge, const Node& node) const {
+ if (Parent::bNode(node)) {
+ Parent::firstIn(edge, node);
+ edge.forward = true;
+ } else {
+ Parent::firstOut(edge, node);
+ edge.forward = static_cast<UEdge&>(edge) == INVALID;
+ }
+ }
+ void nextIn(Edge& edge) const {
+ if (edge.forward) {
+ Parent::nextIn(edge);
+ } else {
+ Parent::nextOut(edge);
+ edge.forward = static_cast<UEdge&>(edge) == INVALID;
+ }
+ }
+
+ Node source(const Edge& edge) const {
+ return edge.forward ? Parent::aNode(edge) : Parent::bNode(edge);
+ }
+ Node target(const Edge& edge) const {
+ return edge.forward ? Parent::bNode(edge) : Parent::aNode(edge);
+ }
+
+ int id(const Edge& edge) const {
+ return (Parent::id(edge) << 1) + (edge.forward ? 0 : 1);
+ }
+ Edge edgeFromId(int id) const {
+ return Edge(Parent::fromId(id >> 1, UEdge()), (id & 1) == 0);
+ }
+ int maxEdgeId() const {
+ return (Parent::maxId(UEdge()) << 1) + 1;
+ }
+
+ bool direction(const Edge& edge) const {
+ return edge.forward;
+ }
+
+ Edge direct(const UEdge& edge, bool direction) const {
+ return Edge(edge, direction);
+ }
+ };
+
+ template <typename Base>
+ class BpUGraphExtender : public Base {
+ public:
+ typedef Base Parent;
+ typedef BpUGraphExtender Graph;
+
+ typedef typename Parent::Node Node;
+ typedef typename Parent::BNode BNode;
+ typedef typename Parent::ANode ANode;
+ typedef typename Parent::Edge Edge;
+ typedef typename Parent::UEdge UEdge;
+
+ Node oppositeNode(const UEdge& edge, const Node& node) const {
+ return source(edge) == node ?
+ target(edge) : source(edge);
+ }
+
+ using Parent::direct;
+ Edge direct(const UEdge& edge, const Node& node) const {
+ return Edge(edge, node == Parent::source(edge));
+ }
+
+ Edge oppositeEdge(const Edge& edge) const {
+ return Parent::direct(edge, !Parent::direction(edge));
+ }
int maxId(Node) const {
@@ -591,10 +1204,10 @@
return Parent::maxANodeId();
}
int maxId(Edge) const {
- return maxEdgeId();
+ return Parent::maxEdgeId();
}
int maxId(UEdge) const {
- return maxUEdgeId();
+ return Parent::maxUEdgeId();
}
@@ -608,12 +1221,605 @@
return Parent::fromBNodeId(id);
}
Edge fromId(int id, Edge) const {
- return edgeFromId(id);
+ return Parent::edgeFromId(id);
}
UEdge fromId(int id, UEdge) const {
- return uEdgeFromId(id);
+ return Parent::uEdgeFromId(id);
+ }
+
+ typedef AlterationNotifier<Node> NodeNotifier;
+ typedef AlterationNotifier<BNode> BNodeNotifier;
+ typedef AlterationNotifier<ANode> ANodeNotifier;
+ typedef AlterationNotifier<Edge> EdgeNotifier;
+ typedef AlterationNotifier<UEdge> UEdgeNotifier;
+
+ protected:
+
+ mutable NodeNotifier nodeNotifier;
+ mutable BNodeNotifier bNodeNotifier;
+ mutable ANodeNotifier aNodeNotifier;
+ mutable EdgeNotifier edgeNotifier;
+ mutable UEdgeNotifier uEdgeNotifier;
+
+ public:
+
+ NodeNotifier& getNotifier(Node) const {
+ return nodeNotifier;
+ }
+
+ BNodeNotifier& getNotifier(BNode) const {
+ return bNodeNotifier;
+ }
+
+ ANodeNotifier& getNotifier(ANode) const {
+ return aNodeNotifier;
}
+ EdgeNotifier& getNotifier(Edge) const {
+ return edgeNotifier;
+ }
+
+ UEdgeNotifier& getNotifier(UEdge) const {
+ return uEdgeNotifier;
+ }
+
+ ~BpUGraphExtender() {
+ getNotifier(UEdge()).clear();
+ getNotifier(Edge()).clear();
+ getNotifier(ANode()).clear();
+ getNotifier(BNode()).clear();
+ getNotifier(Node()).clear();
+ }
+
+
+ class NodeIt : public Node {
+ const Graph* graph;
+ public:
+
+ NodeIt() { }
+
+ NodeIt(Invalid i) : Node(INVALID) { }
+
+ explicit NodeIt(const Graph& _graph) : graph(&_graph) {
+ graph->first(static_cast<Node&>(*this));
+ }
+
+ NodeIt(const Graph& _graph, const Node& node)
+ : Node(node), graph(&_graph) { }
+
+ NodeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+ class ANodeIt : public Node {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ public:
+
+ ANodeIt() { }
+
+ ANodeIt(Invalid i) : Node(INVALID) { }
+
+ explicit ANodeIt(const Graph& _graph) : graph(&_graph) {
+ graph->firstANode(static_cast<Node&>(*this));
+ }
+
+ ANodeIt(const Graph& _graph, const Node& node)
+ : Node(node), graph(&_graph) {}
+
+ ANodeIt& operator++() {
+ graph->nextANode(*this);
+ return *this;
+ }
+ };
+
+ class BNodeIt : public Node {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ public:
+
+ BNodeIt() { }
+
+ BNodeIt(Invalid i) : Node(INVALID) { }
+
+ explicit BNodeIt(const Graph& _graph) : graph(&_graph) {
+ graph->firstBNode(static_cast<Node&>(*this));
+ }
+
+ BNodeIt(const Graph& _graph, const Node& node)
+ : Node(node), graph(&_graph) {}
+
+ BNodeIt& operator++() {
+ graph->nextBNode(*this);
+ return *this;
+ }
+ };
+
+ class EdgeIt : public Edge {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ public:
+
+ EdgeIt() { }
+
+ EdgeIt(Invalid i) : Edge(INVALID) { }
+
+ explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
+ graph->first(static_cast<Edge&>(*this));
+ }
+
+ EdgeIt(const Graph& _graph, const Edge& edge)
+ : Edge(edge), graph(&_graph) { }
+
+ EdgeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+
+ };
+
+ class UEdgeIt : public UEdge {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ public:
+
+ UEdgeIt() { }
+
+ UEdgeIt(Invalid i) : UEdge(INVALID) { }
+
+ explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
+ graph->first(static_cast<UEdge&>(*this));
+ }
+
+ UEdgeIt(const Graph& _graph, const UEdge& edge)
+ : UEdge(edge), graph(&_graph) { }
+
+ UEdgeIt& operator++() {
+ graph->next(*this);
+ return *this;
+ }
+ };
+
+ class OutEdgeIt : public Edge {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ public:
+
+ OutEdgeIt() { }
+
+ OutEdgeIt(Invalid i) : Edge(i) { }
+
+ OutEdgeIt(const Graph& _graph, const Node& node)
+ : graph(&_graph) {
+ graph->firstOut(*this, node);
+ }
+
+ OutEdgeIt(const Graph& _graph, const Edge& edge)
+ : Edge(edge), graph(&_graph) {}
+
+ OutEdgeIt& operator++() {
+ graph->nextOut(*this);
+ return *this;
+ }
+
+ };
+
+
+ class InEdgeIt : public Edge {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ public:
+
+ InEdgeIt() { }
+
+ InEdgeIt(Invalid i) : Edge(i) { }
+
+ InEdgeIt(const Graph& _graph, const Node& node)
+ : graph(&_graph) {
+ graph->firstIn(*this, node);
+ }
+
+ InEdgeIt(const Graph& _graph, const Edge& edge) :
+ Edge(edge), graph(&_graph) {}
+
+ InEdgeIt& operator++() {
+ graph->nextIn(*this);
+ return *this;
+ }
+
+ };
+
+ /// \brief Base node of the iterator
+ ///
+ /// Returns the base node (ie. the source in this case) of the iterator
+ Node baseNode(const OutEdgeIt &e) const {
+ return Parent::source((Edge&)e);
+ }
+ /// \brief Running node of the iterator
+ ///
+ /// Returns the running node (ie. the target in this case) of the
+ /// iterator
+ Node runningNode(const OutEdgeIt &e) const {
+ return Parent::target((Edge&)e);
+ }
+
+ /// \brief Base node of the iterator
+ ///
+ /// Returns the base node (ie. the target in this case) of the iterator
+ Node baseNode(const InEdgeIt &e) const {
+ return Parent::target((Edge&)e);
+ }
+ /// \brief Running node of the iterator
+ ///
+ /// Returns the running node (ie. the source in this case) of the
+ /// iterator
+ Node runningNode(const InEdgeIt &e) const {
+ return Parent::source((Edge&)e);
+ }
+
+ class IncEdgeIt : public Parent::UEdge {
+ friend class BpUGraphExtender;
+ const Graph* graph;
+ bool direction;
+ public:
+
+ IncEdgeIt() { }
+
+ IncEdgeIt(Invalid i) : UEdge(i), direction(true) { }
+
+ IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
+ graph->firstInc(*this, direction, n);
+ }
+
+ IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n)
+ : graph(&_graph), UEdge(ue) {
+ direction = (graph->source(ue) == n);
+ }
+
+ IncEdgeIt& operator++() {
+ graph->nextInc(*this, direction);
+ return *this;
+ }
+ };
+
+
+ /// Base node of the iterator
+ ///
+ /// Returns the base node of the iterator
+ Node baseNode(const IncEdgeIt &e) const {
+ return e.direction ? source(e) : target(e);
+ }
+
+ /// Running node of the iterator
+ ///
+ /// Returns the running node of the iterator
+ Node runningNode(const IncEdgeIt &e) const {
+ return e.direction ? target(e) : source(e);
+ }
+
+ template <typename _Value>
+ class ANodeMap
+ : public IterableMapExtender<DefaultMap<Graph, ANode, _Value> > {
+ public:
+ typedef BpUGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, ANode, _Value> >
+ Parent;
+
+ ANodeMap(const Graph& _g)
+ : Parent(_g) {}
+ ANodeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ ANodeMap& operator=(const ANodeMap& cmap) {
+ return operator=<ANodeMap>(cmap);
+ }
+
+
+ /// \brief Template assign operator.
+ ///
+ /// The given parameter should be conform to the ReadMap
+ /// concept and could be indiced by the current item set of
+ /// the ANodeMap. In this case the value for each item
+ /// is assigned by the value of the given ReadMap.
+ template <typename CMap>
+ ANodeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ ANode it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+
+ };
+
+ template <typename _Value>
+ class BNodeMap
+ : public IterableMapExtender<DefaultMap<Graph, BNode, _Value> > {
+ public:
+ typedef BpUGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, BNode, _Value> >
+ Parent;
+
+ BNodeMap(const Graph& _g)
+ : Parent(_g) {}
+ BNodeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ BNodeMap& operator=(const BNodeMap& cmap) {
+ return operator=<BNodeMap>(cmap);
+ }
+
+
+ /// \brief Template assign operator.
+ ///
+ /// The given parameter should be conform to the ReadMap
+ /// concept and could be indiced by the current item set of
+ /// the BNodeMap. In this case the value for each item
+ /// is assigned by the value of the given ReadMap.
+ template <typename CMap>
+ BNodeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ BNode it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+
+ };
+
+ protected:
+
+ template <typename _Value>
+ class NodeMapBase : public NodeNotifier::ObserverBase {
+ public:
+ typedef BpUGraphExtender Graph;
+
+ typedef Node Key;
+ typedef _Value Value;
+
+ /// The reference type of the map;
+ typedef typename BNodeMap<_Value>::Reference Reference;
+ /// The pointer type of the map;
+ typedef typename BNodeMap<_Value>::Pointer Pointer;
+
+ /// The const value type of the map.
+ typedef const Value ConstValue;
+ /// The const reference type of the map;
+ typedef typename BNodeMap<_Value>::ConstReference ConstReference;
+ /// The pointer type of the map;
+ typedef typename BNodeMap<_Value>::ConstPointer ConstPointer;
+
+ typedef True ReferenceMapTag;
+
+ NodeMapBase(const Graph& _g)
+ : graph(&_g), bNodeMap(_g), aNodeMap(_g) {
+ NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
+ }
+ NodeMapBase(const Graph& _g, const _Value& _v)
+ : graph(&_g), bNodeMap(_g, _v),
+ aNodeMap(_g, _v) {
+ NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
+ }
+
+ virtual ~NodeMapBase() {
+ if (NodeNotifier::ObserverBase::attached()) {
+ NodeNotifier::ObserverBase::detach();
+ }
+ }
+
+ ConstReference operator[](const Key& node) const {
+ if (Parent::aNode(node)) {
+ return aNodeMap[node];
+ } else {
+ return bNodeMap[node];
+ }
+ }
+
+ Reference operator[](const Key& node) {
+ if (Parent::aNode(node)) {
+ return aNodeMap[node];
+ } else {
+ return bNodeMap[node];
+ }
+ }
+
+ void set(const Key& node, const Value& value) {
+ if (Parent::aNode(node)) {
+ aNodeMap.set(node, value);
+ } else {
+ bNodeMap.set(node, value);
+ }
+ }
+
+ protected:
+
+ virtual void add(const Node&) {}
+ virtual void add(const std::vector<Node>&) {}
+ virtual void erase(const Node&) {}
+ virtual void erase(const std::vector<Node>&) {}
+ virtual void clear() {}
+ virtual void build() {}
+
+ const Graph* getGraph() const { return graph; }
+
+ private:
+ const Graph* graph;
+ BNodeMap<_Value> bNodeMap;
+ ANodeMap<_Value> aNodeMap;
+ };
+
+ public:
+
+ template <typename _Value>
+ class NodeMap
+ : public IterableMapExtender<NodeMapBase<_Value> > {
+ public:
+ typedef BpUGraphExtender Graph;
+ typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
+
+ NodeMap(const Graph& _g)
+ : Parent(_g) {}
+ NodeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ NodeMap& operator=(const NodeMap& cmap) {
+ return operator=<NodeMap>(cmap);
+ }
+
+
+ /// \brief Template assign operator.
+ ///
+ /// The given parameter should be conform to the ReadMap
+ /// concept and could be indiced by the current item set of
+ /// the NodeMap. In this case the value for each item
+ /// is assigned by the value of the given ReadMap.
+ template <typename CMap>
+ NodeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<Node, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ Node it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+
+ };
+
+
+
+ template <typename _Value>
+ class EdgeMap
+ : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
+ public:
+ typedef BpUGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
+
+ EdgeMap(const Graph& _g)
+ : Parent(_g) {}
+ EdgeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ EdgeMap& operator=(const EdgeMap& cmap) {
+ return operator=<EdgeMap>(cmap);
+ }
+
+ template <typename CMap>
+ EdgeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ Edge it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+ };
+
+ template <typename _Value>
+ class UEdgeMap
+ : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
+ public:
+ typedef BpUGraphExtender Graph;
+ typedef IterableMapExtender<DefaultMap<Graph, UEdge, _Value> >
+ Parent;
+
+ UEdgeMap(const Graph& _g)
+ : Parent(_g) {}
+ UEdgeMap(const Graph& _g, const _Value& _v)
+ : Parent(_g, _v) {}
+
+ UEdgeMap& operator=(const UEdgeMap& cmap) {
+ return operator=<UEdgeMap>(cmap);
+ }
+
+ template <typename CMap>
+ UEdgeMap& operator=(const CMap& cmap) {
+ checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
+ const typename Parent::Graph* graph = Parent::getGraph();
+ UEdge it;
+ for (graph->first(it); it != INVALID; graph->next(it)) {
+ Parent::set(it, cmap[it]);
+ }
+ return *this;
+ }
+ };
+
+
+ Node addANode() {
+ Node node = Parent::addANode();
+ getNotifier(ANode()).add(node);
+ getNotifier(Node()).add(node);
+ return node;
+ }
+
+ Node addBNode() {
+ Node node = Parent::addBNode();
+ getNotifier(BNode()).add(node);
+ getNotifier(Node()).add(node);
+ return node;
+ }
+
+ UEdge addEdge(const Node& source, const Node& target) {
+ UEdge uedge = Parent::addEdge(source, target);
+ getNotifier(UEdge()).add(uedge);
+
+ std::vector<Edge> edges;
+ edges.push_back(direct(uedge, true));
+ edges.push_back(direct(uedge, false));
+ getNotifier(Edge()).add(edges);
+
+ return uedge;
+ }
+
+ void clear() {
+ getNotifier(Edge()).clear();
+ getNotifier(UEdge()).clear();
+ getNotifier(Node()).clear();
+ getNotifier(BNode()).clear();
+ getNotifier(ANode()).clear();
+ Parent::clear();
+ }
+
+ void erase(const Node& node) {
+ UEdge uedge;
+ bool dir;
+ Parent::firstInc(uedge, dir, node);
+ while (uedge != INVALID ) {
+ erase(uedge);
+ Parent::firstInc(uedge, dir, node);
+ }
+
+ getNotifier(Node()).erase(node);
+ Parent::erase(node);
+ }
+
+ void erase(const UEdge& uedge) {
+ std::vector<Edge> edges;
+ edges.push_back(direct(uedge, true));
+ edges.push_back(direct(uedge, false));
+ getNotifier(Edge()).erase(edges);
+ getNotifier(UEdge()).erase(uedge);
+ Parent::erase(uedge);
+ }
+
+
+ ~BpUGraphExtender() {
+ getNotifier(Edge()).clear();
+ getNotifier(UEdge()).clear();
+ getNotifier(Node()).clear();
+ getNotifier(BNode()).clear();
+ getNotifier(ANode()).clear();
+ }
+
+
};
}
Modified: hugo/trunk/lemon/bits/static_map.h
==============================================================================
--- hugo/trunk/lemon/bits/static_map.h (original)
+++ hugo/trunk/lemon/bits/static_map.h Wed Feb 22 19:26:56 2006
@@ -56,11 +56,11 @@
class StaticMap : public AlterationNotifier<_Item>::ObserverBase {
public:
- /// \brief Exception class for unsinported exceptions.
- class UnsinportedOperation : public lemon::LogicError {
+ /// \brief Exception class for unsupported exceptions.
+ class UnsupportedOperation : public lemon::LogicError {
public:
virtual const char* exceptionName() const {
- return "lemon::StaticMap::UnsinportedOperation";
+ return "lemon::StaticMap::UnsupportedOperation";
}
};
@@ -187,7 +187,7 @@
/// and it overrides the add() member function of the observer base.
void add(const Key&) {
- throw UnsinportedOperation();
+ throw UnsupportedOperation();
}
/// \brief Erases a key from the map.
@@ -195,7 +195,7 @@
/// Erase a key from the map. It called by the observer registry
/// and it overrides the erase() member function of the observer base.
void erase(const Key&) {
- throw UnsinportedOperation();
+ throw UnsupportedOperation();
}
/// Buildes the map.
@@ -224,396 +224,6 @@
};
- /// \e
- template <typename _Base>
- class StaticMappableGraphExtender : public _Base {
- public:
-
- typedef StaticMappableGraphExtender<_Base> Graph;
- typedef _Base Parent;
-
- typedef typename Parent::Node Node;
- typedef typename Parent::NodeIt NodeIt;
-
- typedef typename Parent::Edge Edge;
- typedef typename Parent::EdgeIt EdgeIt;
-
-
- template <typename _Value>
- class NodeMap
- : public IterableMapExtender<StaticMap<Graph, Node, _Value> > {
- public:
- typedef StaticMappableGraphExtender Graph;
- typedef IterableMapExtender<StaticMap<Graph, Node, _Value> > Parent;
-
- NodeMap(const Graph& _g)
- : Parent(_g) {}
- NodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- NodeMap& operator=(const NodeMap& cmap) {
- return operator=<NodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concecpt and could be indiced by the current item set of
- /// the NodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- NodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Node, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Node it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
- template <typename _Value>
- class EdgeMap
- : public IterableMapExtender<StaticMap<Graph, Edge, _Value> > {
- public:
- typedef StaticMappableGraphExtender Graph;
- typedef IterableMapExtender<StaticMap<Graph, Edge, _Value> > Parent;
-
- EdgeMap(const Graph& _g)
- : Parent(_g) {}
- EdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- EdgeMap& operator=(const EdgeMap& cmap) {
- return operator=<EdgeMap>(cmap);
- }
-
- template <typename CMap>
- EdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Edge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- };
-
- /// \e
- template <typename _Base>
- class StaticMappableUGraphExtender :
- public StaticMappableGraphExtender<_Base> {
- public:
-
- typedef StaticMappableUGraphExtender Graph;
- typedef StaticMappableGraphExtender<_Base> Parent;
-
- typedef typename Parent::UEdge UEdge;
-
- template <typename _Value>
- class UEdgeMap
- : public IterableMapExtender<StaticMap<Graph, UEdge, _Value> > {
- public:
- typedef StaticMappableUGraphExtender Graph;
- typedef IterableMapExtender<
- StaticMap<Graph, UEdge, _Value> > Parent;
-
- UEdgeMap(const Graph& _g)
- : Parent(_g) {}
- UEdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- UEdgeMap& operator=(const UEdgeMap& cmap) {
- return operator=<UEdgeMap>(cmap);
- }
-
- template <typename CMap>
- UEdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- UEdge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- };
-
- template <typename _Base>
- class StaticMappableBpUGraphExtender : public _Base {
- public:
-
- typedef _Base Parent;
- typedef StaticMappableBpUGraphExtender Graph;
-
- typedef typename Parent::Node Node;
- typedef typename Parent::ANode ANode;
- typedef typename Parent::BNode BNode;
- typedef typename Parent::Edge Edge;
- typedef typename Parent::UEdge UEdge;
-
- template <typename _Value>
- class ANodeMap
- : public IterableMapExtender<StaticMap<Graph, ANode, _Value> > {
- public:
- typedef StaticMappableBpUGraphExtender Graph;
- typedef IterableMapExtender<StaticMap<Graph, ANode, _Value> >
- Parent;
-
- ANodeMap(const Graph& _g)
- : Parent(_g) {}
- ANodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- ANodeMap& operator=(const ANodeMap& cmap) {
- return operator=<ANodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concept and could be indiced by the current item set of
- /// the ANodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- ANodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- ANode it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
- template <typename _Value>
- class BNodeMap
- : public IterableMapExtender<StaticMap<Graph, BNode, _Value> > {
- public:
- typedef StaticMappableBpUGraphExtender Graph;
- typedef IterableMapExtender<StaticMap<Graph, BNode, _Value> >
- Parent;
-
- BNodeMap(const Graph& _g)
- : Parent(_g) {}
- BNodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- BNodeMap& operator=(const BNodeMap& cmap) {
- return operator=<BNodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concept and could be indiced by the current item set of
- /// the BNodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- BNodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- BNode it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
- protected:
-
- template <typename _Value>
- class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
- public:
- typedef StaticMappableBpUGraphExtender Graph;
-
- typedef Node Key;
- typedef _Value Value;
-
- /// The reference type of the map;
- typedef typename BNodeMap<_Value>::Reference Reference;
- /// The pointer type of the map;
- typedef typename BNodeMap<_Value>::Pointer Pointer;
-
- /// The const value type of the map.
- typedef const Value ConstValue;
- /// The const reference type of the map;
- typedef typename BNodeMap<_Value>::ConstReference ConstReference;
- /// The pointer type of the map;
- typedef typename BNodeMap<_Value>::ConstPointer ConstPointer;
-
- typedef True ReferenceMapTag;
-
- NodeMapBase(const Graph& _g)
- : graph(&_g), bNodeMap(_g), aNodeMap(_g) {
- Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
- }
- NodeMapBase(const Graph& _g, const _Value& _v)
- : graph(&_g), bNodeMap(_g, _v),
- aNodeMap(_g, _v) {
- Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
- }
-
- virtual ~NodeMapBase() {
- if (Parent::NodeNotifier::ObserverBase::attached()) {
- Parent::NodeNotifier::ObserverBase::detach();
- }
- }
-
- ConstReference operator[](const Key& node) const {
- if (Parent::aNode(node)) {
- return aNodeMap[node];
- } else {
- return bNodeMap[node];
- }
- }
-
- Reference operator[](const Key& node) {
- if (Parent::aNode(node)) {
- return aNodeMap[node];
- } else {
- return bNodeMap[node];
- }
- }
-
- void set(const Key& node, const Value& value) {
- if (Parent::aNode(node)) {
- aNodeMap.set(node, value);
- } else {
- bNodeMap.set(node, value);
- }
- }
-
- protected:
-
- virtual void add(const Node&) {}
- virtual void add(const std::vector<Node>&) {}
- virtual void erase(const Node&) {}
- virtual void erase(const std::vector<Node>&) {}
- virtual void clear() {}
- virtual void build() {}
-
- const Graph* getGraph() const { return graph; }
-
- private:
- const Graph* graph;
- BNodeMap<_Value> bNodeMap;
- ANodeMap<_Value> aNodeMap;
- };
-
- public:
-
- template <typename _Value>
- class NodeMap
- : public IterableMapExtender<NodeMapBase<_Value> > {
- public:
- typedef StaticMappableBpUGraphExtender Graph;
- typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
-
- NodeMap(const Graph& _g)
- : Parent(_g) {}
- NodeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- NodeMap& operator=(const NodeMap& cmap) {
- return operator=<NodeMap>(cmap);
- }
-
-
- /// \brief Template assign operator.
- ///
- /// The given parameter should be conform to the ReadMap
- /// concept and could be indiced by the current item set of
- /// the NodeMap. In this case the value for each item
- /// is assigned by the value of the given ReadMap.
- template <typename CMap>
- NodeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Node, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Node it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
-
- };
-
-
-
- template <typename _Value>
- class EdgeMap
- : public IterableMapExtender<StaticMap<Graph, Edge, _Value> > {
- public:
- typedef StaticMappableBpUGraphExtender Graph;
- typedef IterableMapExtender<StaticMap<Graph, Edge, _Value> > Parent;
-
- EdgeMap(const Graph& _g)
- : Parent(_g) {}
- EdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- EdgeMap& operator=(const EdgeMap& cmap) {
- return operator=<EdgeMap>(cmap);
- }
-
- template <typename CMap>
- EdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- Edge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- template <typename _Value>
- class UEdgeMap
- : public IterableMapExtender<StaticMap<Graph, UEdge, _Value> > {
- public:
- typedef StaticMappableBpUGraphExtender Graph;
- typedef IterableMapExtender<StaticMap<Graph, UEdge, _Value> >
- Parent;
-
- UEdgeMap(const Graph& _g)
- : Parent(_g) {}
- UEdgeMap(const Graph& _g, const _Value& _v)
- : Parent(_g, _v) {}
-
- UEdgeMap& operator=(const UEdgeMap& cmap) {
- return operator=<UEdgeMap>(cmap);
- }
-
- template <typename CMap>
- UEdgeMap& operator=(const CMap& cmap) {
- checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
- const typename Parent::Graph* graph = Parent::getGraph();
- UEdge it;
- for (graph->first(it); it != INVALID; graph->next(it)) {
- Parent::set(it, cmap[it]);
- }
- return *this;
- }
- };
-
- };
-
}
#endif
Modified: hugo/trunk/lemon/concept/bpugraph.h
==============================================================================
--- hugo/trunk/lemon/concept/bpugraph.h (original)
+++ hugo/trunk/lemon/concept/bpugraph.h Wed Feb 22 19:26:56 2006
@@ -70,7 +70,7 @@
public:
/// \todo undocumented
///
- typedef True UTag;
+ typedef True UndirectedTag;
/// \brief The base type of node iterators,
/// or in other words, the trivial node iterator.
Modified: hugo/trunk/lemon/concept/graph.h
==============================================================================
--- hugo/trunk/lemon/concept/graph.h (original)
+++ hugo/trunk/lemon/concept/graph.h Wed Feb 22 19:26:56 2006
@@ -44,8 +44,6 @@
public IterableGraphComponent, public MappableGraphComponent {
public:
- typedef False UTag;
-
typedef BaseGraphComponent::Node Node;
typedef BaseGraphComponent::Edge Edge;
@@ -123,10 +121,6 @@
public:
///\e
- ///\todo undocumented
- ///
- typedef False UTag;
-
/// Defalult constructor.
/// Defalult constructor.
Modified: hugo/trunk/lemon/concept/ugraph.h
==============================================================================
--- hugo/trunk/lemon/concept/ugraph.h (original)
+++ hugo/trunk/lemon/concept/ugraph.h Wed Feb 22 19:26:56 2006
@@ -245,7 +245,7 @@
///\todo undocumented
///
- typedef True UTag;
+ typedef True UndirectedTag;
/// \brief The base type of node iterators,
/// or in other words, the trivial node iterator.
Modified: hugo/trunk/lemon/edge_set.h
==============================================================================
--- hugo/trunk/lemon/edge_set.h (original)
+++ hugo/trunk/lemon/edge_set.h Wed Feb 22 19:26:56 2006
@@ -19,13 +19,8 @@
#ifndef LEMON_EDGE_SET_H
#define LEMON_EDGE_SET_H
-#include <lemon/bits/erasable_graph_extender.h>
-#include <lemon/bits/clearable_graph_extender.h>
-#include <lemon/bits/extendable_graph_extender.h>
-#include <lemon/bits/iterable_graph_extender.h>
-#include <lemon/bits/alteration_notifier.h>
-#include <lemon/bits/default_map.h>
-#include <lemon/bits/graph_extender.h>
+
+#include <lemon/bits/edge_set_extender.h>
/// \ingroup graphs
/// \file
@@ -229,26 +224,11 @@
/// In the edge extension and removing it conforms to the
/// \ref concept::ErasableGraph "ErasableGraph" concept.
template <typename _Graph>
- class ListEdgeSet :
- public ErasableEdgeSetExtender<
- ClearableEdgeSetExtender<
- ExtendableEdgeSetExtender<
- MappableEdgeSetExtender<
- IterableGraphExtender<
- AlterableEdgeSetExtender<
- GraphExtender<
- ListEdgeSetBase<_Graph> > > > > > > > {
+ class ListEdgeSet : public EdgeSetExtender<ListEdgeSetBase<_Graph> > {
public:
- typedef ErasableEdgeSetExtender<
- ClearableEdgeSetExtender<
- ExtendableEdgeSetExtender<
- MappableEdgeSetExtender<
- IterableGraphExtender<
- AlterableEdgeSetExtender<
- GraphExtender<
- ListEdgeSetBase<_Graph> > > > > > > > Parent;
+ typedef EdgeSetExtender<ListEdgeSetBase<_Graph> > Parent;
typedef typename Parent::Node Node;
typedef typename Parent::Edge Edge;
@@ -336,26 +316,13 @@
/// In the edge extension and removing it conforms to the
/// \ref concept::ErasableUGraph "ErasableUGraph" concept.
template <typename _Graph>
- class ListUEdgeSet :
- public ErasableUEdgeSetExtender<
- ClearableUEdgeSetExtender<
- ExtendableUEdgeSetExtender<
- MappableUEdgeSetExtender<
- IterableUGraphExtender<
- AlterableUEdgeSetExtender<
- UGraphExtender<
- ListEdgeSetBase<_Graph> > > > > > > > {
+ class ListUEdgeSet
+ : public UEdgeSetExtender<UGraphBaseExtender<ListEdgeSetBase<_Graph> > > {
public:
- typedef ErasableUEdgeSetExtender<
- ClearableUEdgeSetExtender<
- ExtendableUEdgeSetExtender<
- MappableUEdgeSetExtender<
- IterableUGraphExtender<
- AlterableUEdgeSetExtender<
- UGraphExtender<
- ListEdgeSetBase<_Graph> > > > > > > > Parent;
+ typedef UEdgeSetExtender<UGraphBaseExtender<
+ ListEdgeSetBase<_Graph> > > Parent;
typedef typename Parent::Node Node;
typedef typename Parent::Edge Edge;
@@ -567,24 +534,11 @@
/// In the edge extension and removing it conforms to the
/// \ref concept::ExtendableGraph "ExtendableGraph" concept.
template <typename _Graph>
- class SmartEdgeSet :
- public ClearableEdgeSetExtender<
- ExtendableEdgeSetExtender<
- MappableEdgeSetExtender<
- IterableGraphExtender<
- AlterableEdgeSetExtender<
- GraphExtender<
- SmartEdgeSetBase<_Graph> > > > > > > {
+ class SmartEdgeSet : public EdgeSetExtender<SmartEdgeSetBase<_Graph> > {
public:
- typedef ClearableEdgeSetExtender<
- ExtendableEdgeSetExtender<
- MappableEdgeSetExtender<
- IterableGraphExtender<
- AlterableEdgeSetExtender<
- GraphExtender<
- SmartEdgeSetBase<_Graph> > > > > > > Parent;
+ typedef EdgeSetExtender<SmartEdgeSetBase<_Graph> > Parent;
typedef typename Parent::Node Node;
typedef typename Parent::Edge Edge;
@@ -671,24 +625,13 @@
/// In the edge extension and removing it conforms to the
/// \ref concept::ExtendableUGraph "ExtendableUGraph" concept.
template <typename _Graph>
- class SmartUEdgeSet :
- public ClearableUEdgeSetExtender<
- ExtendableUEdgeSetExtender<
- MappableUEdgeSetExtender<
- IterableUGraphExtender<
- AlterableUEdgeSetExtender<
- UGraphExtender<
- SmartEdgeSetBase<_Graph> > > > > > > {
+ class SmartUEdgeSet
+ : public UEdgeSetExtender<UGraphBaseExtender<SmartEdgeSetBase<_Graph> > > {
public:
- typedef ClearableUEdgeSetExtender<
- ExtendableUEdgeSetExtender<
- MappableUEdgeSetExtender<
- IterableUGraphExtender<
- AlterableUEdgeSetExtender<
- UGraphExtender<
- SmartEdgeSetBase<_Graph> > > > > > > Parent;
+ typedef UEdgeSetExtender<UGraphBaseExtender<
+ SmartEdgeSetBase<_Graph> > > Parent;
typedef typename Parent::Node Node;
typedef typename Parent::Edge Edge;
Modified: hugo/trunk/lemon/euler.h
==============================================================================
--- hugo/trunk/lemon/euler.h (original)
+++ hugo/trunk/lemon/euler.h Wed Feb 22 19:26:56 2006
@@ -233,7 +233,7 @@
#ifdef DOXYGEN
bool
#else
- typename enable_if<typename Graph::UTag,bool>::type
+ typename enable_if<UndirectedTagIndicator<Graph>,bool>::type
euler(const Graph &g)
{
for(typename Graph::NodeIt n(g);n!=INVALID;++n)
@@ -241,7 +241,7 @@
return connected(g);
}
template<class Graph>
- typename disable_if<typename Graph::UTag,bool>::type
+ typename disable_if<UndirectedTagIndicator<Graph>,bool>::type
#endif
euler(const Graph &g)
{
Modified: hugo/trunk/lemon/fredman_tarjan.h
==============================================================================
--- hugo/trunk/lemon/fredman_tarjan.h (original)
+++ hugo/trunk/lemon/fredman_tarjan.h Wed Feb 22 19:26:56 2006
@@ -504,7 +504,7 @@
Create ft(graph,cost);
ft.treeMap(tree);
ft.run();
- };
+ }
} //END OF NAMESPACE LEMON
Modified: hugo/trunk/lemon/full_graph.h
==============================================================================
--- hugo/trunk/lemon/full_graph.h (original)
+++ hugo/trunk/lemon/full_graph.h Wed Feb 22 19:26:56 2006
@@ -22,11 +22,9 @@
#include <cmath>
-#include <lemon/bits/iterable_graph_extender.h>
-#include <lemon/bits/alteration_notifier.h>
-#include <lemon/bits/static_map.h>
#include <lemon/bits/graph_extender.h>
+
#include <lemon/invalid.h>
#include <lemon/utility.h>
@@ -191,10 +189,7 @@
};
- typedef StaticMappableGraphExtender<
- IterableGraphExtender<
- AlterableGraphExtender<
- GraphExtender<FullGraphBase> > > > ExtendedFullGraphBase;
+ typedef GraphExtender<FullGraphBase> ExtendedFullGraphBase;
/// \ingroup graphs
///
@@ -211,7 +206,21 @@
class FullGraph : public ExtendedFullGraphBase {
public:
+ typedef ExtendedFullGraphBase Parent;
+
+ /// \brief Constructor
+ ///
FullGraph(int n) { construct(n); }
+
+ /// \brief Resize the graph
+ ///
+ void resize(int n) {
+ Parent::getNotifier(Edge()).clear();
+ Parent::getNotifier(Node()).clear();
+ construct(n);
+ Parent::getNotifier(Node()).build();
+ Parent::getNotifier(Edge()).build();
+ }
};
@@ -379,10 +388,8 @@
};
- typedef StaticMappableUGraphExtender<
- IterableUGraphExtender<
- AlterableUGraphExtender<
- UGraphExtender<FullUGraphBase> > > > ExtendedFullUGraphBase;
+ typedef UGraphExtender<UGraphBaseExtender<FullUGraphBase> >
+ ExtendedFullUGraphBase;
/// \ingroup graphs
///
@@ -401,7 +408,23 @@
/// \author Balazs Dezso
class FullUGraph : public ExtendedFullUGraphBase {
public:
+
+ typedef ExtendedFullUGraphBase Parent;
+
+ /// \brief Constructor
FullUGraph(int n) { construct(n); }
+
+ /// \brief Resize the graph
+ ///
+ void resize(int n) {
+ Parent::getNotifier(Edge()).clear();
+ Parent::getNotifier(UEdge()).clear();
+ Parent::getNotifier(Node()).clear();
+ construct(n);
+ Parent::getNotifier(Node()).build();
+ Parent::getNotifier(UEdge()).build();
+ Parent::getNotifier(Edge()).build();
+ }
};
@@ -577,12 +600,8 @@
};
- typedef StaticMappableBpUGraphExtender<
- IterableBpUGraphExtender<
- AlterableBpUGraphExtender<
- BpUGraphExtender <
- FullBpUGraphBase> > > >
- ExtendedFullBpUGraphBase;
+ typedef BpUGraphExtender< BpUGraphBaseExtender<
+ FullBpUGraphBase> > ExtendedFullBpUGraphBase;
/// \ingroup graphs
@@ -599,10 +618,23 @@
class FullBpUGraph :
public ExtendedFullBpUGraphBase {
public:
+
typedef ExtendedFullBpUGraphBase Parent;
+
FullBpUGraph(int aNodeNum, int bNodeNum) {
Parent::construct(aNodeNum, bNodeNum);
}
+ /// \brief Resize the graph
+ ///
+ void resize(int n, int m) {
+ Parent::getNotifier(Edge()).clear();
+ Parent::getNotifier(UEdge()).clear();
+ Parent::getNotifier(Node()).clear();
+ construct(n, m);
+ Parent::getNotifier(Node()).build();
+ Parent::getNotifier(UEdge()).build();
+ Parent::getNotifier(Edge()).build();
+ }
};
} //namespace lemon
Modified: hugo/trunk/lemon/graph_adaptor.h
==============================================================================
--- hugo/trunk/lemon/graph_adaptor.h (original)
+++ hugo/trunk/lemon/graph_adaptor.h Wed Feb 22 19:26:56 2006
@@ -29,13 +29,10 @@
#include <lemon/invalid.h>
#include <lemon/maps.h>
-#include <lemon/bits/erasable_graph_extender.h>
-#include <lemon/bits/clearable_graph_extender.h>
-#include <lemon/bits/extendable_graph_extender.h>
-#include <lemon/bits/iterable_graph_extender.h>
-#include <lemon/bits/alteration_notifier.h>
-#include <lemon/bits/default_map.h>
+
+#include <lemon/bits/graph_adaptor_extender.h>
#include <lemon/bits/graph_extender.h>
+
#include <iostream>
namespace lemon {
@@ -117,10 +114,6 @@
int id(const Node& v) const { return graph->id(v); }
int id(const Edge& e) const { return graph->id(e); }
- Edge oppositeNode(const Edge& e) const {
- return Edge(graph->opposite(e));
- }
-
template <typename _Value>
class NodeMap : public _Graph::template NodeMap<_Value> {
public:
@@ -145,10 +138,10 @@
template <typename _Graph>
class GraphAdaptor :
- public IterableGraphExtender<GraphAdaptorBase<_Graph> > {
+ public GraphAdaptorExtender<GraphAdaptorBase<_Graph> > {
public:
typedef _Graph Graph;
- typedef IterableGraphExtender<GraphAdaptorBase<_Graph> > Parent;
+ typedef GraphAdaptorExtender<GraphAdaptorBase<_Graph> > Parent;
protected:
GraphAdaptor() : Parent() { }
@@ -198,10 +191,10 @@
template<typename _Graph>
class RevGraphAdaptor :
- public IterableGraphExtender<RevGraphAdaptorBase<_Graph> > {
+ public GraphAdaptorExtender<RevGraphAdaptorBase<_Graph> > {
public:
typedef _Graph Graph;
- typedef IterableGraphExtender<
+ typedef GraphAdaptorExtender<
RevGraphAdaptorBase<_Graph> > Parent;
protected:
RevGraphAdaptor() { }
@@ -322,6 +315,7 @@
///
bool hidden(const Edge& e) const { return !(*edge_filter_map)[e]; }
+ typedef False FindEdgeTag;
typedef False NodeNumTag;
typedef False EdgeNumTag;
};
@@ -428,6 +422,7 @@
///
bool hidden(const Edge& e) const { return !(*edge_filter_map)[e]; }
+ typedef False FindEdgeTag;
typedef False NodeNumTag;
typedef False EdgeNumTag;
};
@@ -496,11 +491,11 @@
template<typename _Graph, typename NodeFilterMap,
typename EdgeFilterMap, bool checked = true>
class SubGraphAdaptor :
- public IterableGraphExtender<
+ public GraphAdaptorExtender<
SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap, checked> > {
public:
typedef _Graph Graph;
- typedef IterableGraphExtender<
+ typedef GraphAdaptorExtender<
SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent;
protected:
SubGraphAdaptor() { }
@@ -703,13 +698,13 @@
};
template <typename _Graph>
- class UGraphAdaptorBase :
- public UGraphExtender<GraphAdaptorBase<_Graph> > {
+ class UndirectGraphAdaptorBase :
+ public UGraphBaseExtender<GraphAdaptorBase<_Graph> > {
public:
typedef _Graph Graph;
- typedef UGraphExtender<GraphAdaptorBase<_Graph> > Parent;
+ typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent;
protected:
- UGraphAdaptorBase() : Parent() { }
+ UndirectGraphAdaptorBase() : Parent() { }
public:
typedef typename Parent::UEdge UEdge;
typedef typename Parent::Edge Edge;
@@ -717,17 +712,17 @@
template <typename T>
class EdgeMap {
protected:
- const UGraphAdaptorBase<_Graph>* g;
+ const UndirectGraphAdaptorBase<_Graph>* g;
template <typename TT> friend class EdgeMap;
typename _Graph::template EdgeMap<T> forward_map, backward_map;
public:
typedef T Value;
typedef Edge Key;
- EdgeMap(const UGraphAdaptorBase<_Graph>& _g) : g(&_g),
+ EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g) : g(&_g),
forward_map(*(g->graph)), backward_map(*(g->graph)) { }
- EdgeMap(const UGraphAdaptorBase<_Graph>& _g, T a) : g(&_g),
+ EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g, T a) : g(&_g),
forward_map(*(g->graph), a), backward_map(*(g->graph), a) { }
void set(Edge e, T a) {
@@ -753,10 +748,10 @@
typedef T Value;
typedef UEdge Key;
- UEdgeMap(const UGraphAdaptorBase<_Graph>& g) :
+ UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g) :
map(*(g.graph)) { }
- UEdgeMap(const UGraphAdaptorBase<_Graph>& g, T a) :
+ UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g, T a) :
map(*(g.graph), a) { }
void set(UEdge e, T a) {
@@ -778,17 +773,17 @@
///
/// \author Marton Makai
template<typename _Graph>
- class UGraphAdaptor :
- public IterableUGraphExtender<
- UGraphAdaptorBase<_Graph> > {
+ class UndirectGraphAdaptor :
+ public UGraphAdaptorExtender<
+ UndirectGraphAdaptorBase<_Graph> > {
public:
typedef _Graph Graph;
- typedef IterableUGraphExtender<
- UGraphAdaptorBase<_Graph> > Parent;
+ typedef UGraphAdaptorExtender<
+ UndirectGraphAdaptorBase<_Graph> > Parent;
protected:
- UGraphAdaptor() { }
+ UndirectGraphAdaptor() { }
public:
- UGraphAdaptor(_Graph& _graph) {
+ UndirectGraphAdaptor(_Graph& _graph) {
setGraph(_graph);
}
};
@@ -1083,11 +1078,11 @@
template<typename _Graph,
typename ForwardFilterMap, typename BackwardFilterMap>
class SubBidirGraphAdaptor :
- public IterableGraphExtender<
+ public GraphAdaptorExtender<
SubBidirGraphAdaptorBase<_Graph, ForwardFilterMap, BackwardFilterMap> > {
public:
typedef _Graph Graph;
- typedef IterableGraphExtender<
+ typedef GraphAdaptorExtender<
SubBidirGraphAdaptorBase<
_Graph, ForwardFilterMap, BackwardFilterMap> > Parent;
protected:
@@ -1341,11 +1336,11 @@
///
template <typename _Graph, typename FirstOutEdgesMap>
class ErasingFirstGraphAdaptor :
- public IterableGraphExtender<
+ public GraphAdaptorExtender<
ErasingFirstGraphAdaptorBase<_Graph, FirstOutEdgesMap> > {
public:
typedef _Graph Graph;
- typedef IterableGraphExtender<
+ typedef GraphAdaptorExtender<
ErasingFirstGraphAdaptorBase<_Graph, FirstOutEdgesMap> > Parent;
ErasingFirstGraphAdaptor(Graph& _graph,
FirstOutEdgesMap& _first_out_edges) {
@@ -1711,9 +1706,9 @@
template <typename _Graph>
class SplitGraphAdaptor
- : public IterableGraphExtender<SplitGraphAdaptorBase<_Graph> > {
+ : public GraphAdaptorExtender<SplitGraphAdaptorBase<_Graph> > {
public:
- typedef IterableGraphExtender<SplitGraphAdaptorBase<_Graph> > Parent;
+ typedef GraphAdaptorExtender<SplitGraphAdaptorBase<_Graph> > Parent;
SplitGraphAdaptor(_Graph& graph) {
Parent::setGraph(graph);
Modified: hugo/trunk/lemon/hypercube_graph.h
==============================================================================
--- hugo/trunk/lemon/hypercube_graph.h (original)
+++ hugo/trunk/lemon/hypercube_graph.h Wed Feb 22 19:26:56 2006
@@ -25,9 +25,6 @@
#include <lemon/utility.h>
#include <lemon/error.h>
-#include <lemon/bits/iterable_graph_extender.h>
-#include <lemon/bits/alteration_notifier.h>
-#include <lemon/bits/static_map.h>
#include <lemon/bits/graph_extender.h>
///\ingroup graphs
@@ -236,11 +233,7 @@
};
- typedef StaticMappableGraphExtender<
- IterableGraphExtender<
- AlterableGraphExtender<
- GraphExtender<
- HyperCubeGraphBase> > > > ExtendedHyperCubeGraphBase;
+ typedef GraphExtender<HyperCubeGraphBase> ExtendedHyperCubeGraphBase;
/// \ingroup graphs
///
Modified: hugo/trunk/lemon/kruskal.h
==============================================================================
--- hugo/trunk/lemon/kruskal.h (original)
+++ hugo/trunk/lemon/kruskal.h Wed Feb 22 19:26:56 2006
@@ -23,6 +23,7 @@
#include <vector>
#include <lemon/unionfind.h>
#include <lemon/utility.h>
+#include <lemon/traits.h>
/**
@defgroup spantree Minimum Cost Spanning Tree Algorithms
@@ -228,7 +229,7 @@
};
template<class _GR>
- typename enable_if<typename _GR::UTag,void>::type
+ typename enable_if<UndirectedTagIndicator<_GR>,void>::type
fillWithEdges(const _GR& g, const Map& m,dummy<0> = 0)
{
for(typename GR::UEdgeIt e(g);e!=INVALID;++e)
@@ -236,7 +237,7 @@
}
template<class _GR>
- typename disable_if<typename _GR::UTag,void>::type
+ typename disable_if<UndirectedTagIndicator<_GR>,void>::type
fillWithEdges(const _GR& g, const Map& m,dummy<1> = 1)
{
for(typename GR::EdgeIt e(g);e!=INVALID;++e)
Modified: hugo/trunk/lemon/list_graph.h
==============================================================================
--- hugo/trunk/lemon/list_graph.h (original)
+++ hugo/trunk/lemon/list_graph.h Wed Feb 22 19:26:56 2006
@@ -23,16 +23,11 @@
///\file
///\brief ListGraph, ListUGraph classes.
-#include <lemon/bits/erasable_graph_extender.h>
-#include <lemon/bits/clearable_graph_extender.h>
-#include <lemon/bits/extendable_graph_extender.h>
-#include <lemon/bits/iterable_graph_extender.h>
-#include <lemon/bits/alteration_notifier.h>
-#include <lemon/bits/default_map.h>
#include <lemon/bits/graph_extender.h>
#include <lemon/error.h>
+#include <vector>
#include <list>
namespace lemon {
@@ -311,13 +306,7 @@
};
- typedef ErasableGraphExtender<
- ClearableGraphExtender<
- ExtendableGraphExtender<
- MappableGraphExtender<
- IterableGraphExtender<
- AlterableGraphExtender<
- GraphExtender<ListGraphBase> > > > > > > ExtendedListGraphBase;
+ typedef GraphExtender<ListGraphBase> ExtendedListGraphBase;
/// \addtogroup graphs
/// @{
@@ -578,13 +567,8 @@
/**************** Undirected List Graph ****************/
- typedef ErasableUGraphExtender<
- ClearableUGraphExtender<
- ExtendableUGraphExtender<
- MappableUGraphExtender<
- IterableUGraphExtender<
- AlterableUGraphExtender<
- UGraphExtender<ListGraphBase> > > > > > > ExtendedListUGraphBase;
+ typedef UGraphExtender<UGraphBaseExtender<
+ ListGraphBase> > ExtendedListUGraphBase;
/// \addtogroup graphs
/// @{
Modified: hugo/trunk/lemon/prim.h
==============================================================================
--- hugo/trunk/lemon/prim.h (original)
+++ hugo/trunk/lemon/prim.h Wed Feb 22 19:26:56 2006
@@ -788,7 +788,7 @@
Create prm(graph,cost);
prm.treeMap(tree);
prm.run();
- };
+ }
} //END OF NAMESPACE LEMON
Modified: hugo/trunk/lemon/radix_sort.h
==============================================================================
--- hugo/trunk/lemon/radix_sort.h (original)
+++ hugo/trunk/lemon/radix_sort.h Wed Feb 22 19:26:56 2006
@@ -264,7 +264,7 @@
int byte, Functor functor) {
const int size =
(unsigned int)std::numeric_limits<unsigned char>::max() + 1;
- int counter[size];
+ std::vector<int> counter(size);
for (int i = 0; i < size; ++i) {
counter[i] = 0;
}
@@ -290,7 +290,7 @@
int byte, Functor functor) {
const int size =
(unsigned int)std::numeric_limits<unsigned char>::max() + 1;
- int counter[size];
+ std::vector<int> counter(size);
for (int i = 0; i < size; ++i) {
counter[i] = 0;
}
Modified: hugo/trunk/lemon/smart_graph.h
==============================================================================
--- hugo/trunk/lemon/smart_graph.h (original)
+++ hugo/trunk/lemon/smart_graph.h Wed Feb 22 19:26:56 2006
@@ -27,16 +27,13 @@
#include <lemon/invalid.h>
-#include <lemon/bits/clearable_graph_extender.h>
-#include <lemon/bits/extendable_graph_extender.h>
-#include <lemon/bits/iterable_graph_extender.h>
-#include <lemon/bits/alteration_notifier.h>
-#include <lemon/bits/default_map.h>
#include <lemon/bits/graph_extender.h>
#include <lemon/utility.h>
#include <lemon/error.h>
+#include <lemon/bits/graph_extender.h>
+
namespace lemon {
class SmartGraph;
@@ -222,12 +219,7 @@
};
- typedef ClearableGraphExtender<
- ExtendableGraphExtender<
- MappableGraphExtender<
- IterableGraphExtender<
- AlterableGraphExtender<
- GraphExtender<SmartGraphBase> > > > > > ExtendedSmartGraphBase;
+ typedef GraphExtender<SmartGraphBase> ExtendedSmartGraphBase;
/// \ingroup graphs
@@ -244,7 +236,9 @@
///\author Alpar Juttner
class SmartGraph : public ExtendedSmartGraphBase {
public:
-
+
+ typedef ExtendedSmartGraphBase Parent;
+
class Snapshot;
friend class Snapshot;
@@ -355,12 +349,8 @@
/**************** Undirected List Graph ****************/
- typedef ClearableUGraphExtender<
- ExtendableUGraphExtender<
- MappableUGraphExtender<
- IterableUGraphExtender<
- AlterableUGraphExtender<
- UGraphExtender<SmartGraphBase> > > > > > ExtendedSmartUGraphBase;
+ typedef UGraphExtender<UGraphBaseExtender<SmartGraphBase> >
+ ExtendedSmartUGraphBase;
/// \ingroup graphs
///
@@ -587,14 +577,8 @@
};
- typedef ClearableBpUGraphExtender<
- ExtendableBpUGraphExtender<
- MappableBpUGraphExtender<
- IterableBpUGraphExtender<
- AlterableBpUGraphExtender<
- BpUGraphExtender <
- SmartBpUGraphBase> > > > > >
- ExtendedSmartBpUGraphBase;
+ typedef BpUGraphExtender< BpUGraphBaseExtender<
+ SmartBpUGraphBase> > ExtendedSmartBpUGraphBase;
/// \ingroup graphs
///
Modified: hugo/trunk/lemon/sub_graph.h
==============================================================================
--- hugo/trunk/lemon/sub_graph.h (original)
+++ hugo/trunk/lemon/sub_graph.h Wed Feb 22 19:26:56 2006
@@ -386,9 +386,9 @@
/// \see EdgeSubGraphBase
template <typename Graph>
class SubGraph
- : public IterableGraphExtender< SubGraphBase<Graph> > {
+ : public GraphAdaptorExtender< SubGraphBase<Graph> > {
public:
- typedef IterableGraphExtender< SubGraphBase<Graph> > Parent;
+ typedef GraphAdaptorExtender< SubGraphBase<Graph> > Parent;
public:
/// \brief Constructor for sub-graph.
///
@@ -683,9 +683,9 @@
/// \see EdgeSubGraphBase
template <typename Graph>
class EdgeSubGraph
- : public IterableGraphExtender< EdgeSubGraphBase<Graph> > {
+ : public GraphAdaptorExtender< EdgeSubGraphBase<Graph> > {
public:
- typedef IterableGraphExtender< EdgeSubGraphBase<Graph> > Parent;
+ typedef GraphAdaptorExtender< EdgeSubGraphBase<Graph> > Parent;
public:
/// \brief Constructor for sub-graph.
///
Modified: hugo/trunk/lemon/topology.h
==============================================================================
--- hugo/trunk/lemon/topology.h (original)
+++ hugo/trunk/lemon/topology.h Wed Feb 22 19:26:56 2006
@@ -1417,7 +1417,7 @@
if(bfs.dist(graph.source(i))==bfs.dist(graph.target(i)))return false;
}
return true;
- };
+ }
/// \ingroup topology
///
@@ -1459,7 +1459,7 @@
if(bfs.dist(graph.source(i)) == bfs.dist(graph.target(i)))return false;
}
return true;
- };
+ }
} //namespace lemon
Modified: hugo/trunk/lemon/traits.h
==============================================================================
--- hugo/trunk/lemon/traits.h (original)
+++ hugo/trunk/lemon/traits.h Wed Feb 22 19:26:56 2006
@@ -209,6 +209,19 @@
static const bool value = true;
};
+ template <typename Graph, typename Enable = void>
+ struct UndirectedTagIndicator {
+ static const bool value = false;
+ };
+
+ template <typename Graph>
+ struct UndirectedTagIndicator<
+ Graph,
+ typename enable_if<typename Graph::UndirectedTag, void>::type
+ > {
+ static const bool value = true;
+ };
+
}
Modified: hugo/trunk/test/graph_adaptor_test.cc
==============================================================================
--- hugo/trunk/test/graph_adaptor_test.cc (original)
+++ hugo/trunk/test/graph_adaptor_test.cc Wed Feb 22 19:26:56 2006
@@ -67,9 +67,7 @@
Graph::NodeMap<Graph::Edge> > >();
/// \bug why does not compile with StaticGraph
- checkConcept<BaseIterableUGraphConcept, UGraphAdaptor<ListGraph> >();
- checkConcept<IterableUGraphConcept, UGraphAdaptor<ListGraph> >();
- checkConcept<MappableUGraphConcept, UGraphAdaptor<ListGraph> >();
+ checkConcept<UGraph, UndirectGraphAdaptor<ListGraph> >();
}
std::cout << __FILE__ ": All tests passed.\n";
Modified: hugo/trunk/test/ugraph_test.cc
==============================================================================
--- hugo/trunk/test/ugraph_test.cc (original)
+++ hugo/trunk/test/ugraph_test.cc Wed Feb 22 19:26:56 2006
@@ -21,7 +21,7 @@
#include <lemon/list_graph.h>
#include <lemon/smart_graph.h>
#include <lemon/full_graph.h>
-#include <lemon/grid_graph.h>
+#include <lemon/grid_ugraph.h>
#include <lemon/graph_utils.h>
@@ -32,25 +32,6 @@
using namespace lemon::concept;
void check_concepts() {
- typedef UGraphExtender<ListGraphBase> ListUGraphBase;
-
- typedef IterableUGraphExtender<
- AlterableUGraphExtender<ListUGraphBase> > IterableListUGraph;
-
- typedef MappableUGraphExtender<IterableListUGraph>
- MappableListUGraph;
-
- typedef ErasableUGraphExtender<
- ClearableUGraphExtender<
- ExtendableUGraphExtender<MappableListUGraph> > > Graph;
-
- checkConcept<BaseIterableUGraphConcept, Graph>();
- checkConcept<IterableUGraphConcept, Graph>();
- checkConcept<MappableUGraphConcept, Graph>();
-
- checkConcept<UGraph, Graph>();
- checkConcept<ErasableUGraph, Graph>();
-
checkConcept<UGraph, ListUGraph>();
checkConcept<ErasableUGraph, ListUGraph>();
@@ -61,7 +42,7 @@
checkConcept<UGraph, UGraph>();
- checkConcept<UGraph, GridGraph>();
+ checkConcept<UGraph, GridUGraph>();
}
template <typename Graph>
@@ -150,7 +131,7 @@
check_item_counts(g,3,2);
}
-void checkGridGraph(const GridGraph& g, int w, int h) {
+void checkGridUGraph(const GridUGraph& g, int w, int h) {
check(g.width() == w, "Wrong width");
check(g.height() == h, "Wrong height");
@@ -206,9 +187,9 @@
}
{
- GridGraph g(5, 6);
+ GridUGraph g(5, 6);
check_item_counts(g, 30, 49);
- checkGridGraph(g, 5, 6);
+ checkGridUGraph(g, 5, 6);
}
std::cout << __FILE__ ": All tests passed.\n";
More information about the Lemon-commits
mailing list