# HG changeset patch # User deba # Date 1140684954 0 # Node ID a954b780e3abeab3d88894347eb2e9c1d6c2dab0 # Parent c2992fd74dad819a42e85654910b9ff36b4497ea Renaming to be convient to the naming of the adaptors Concept checking of the ugraph adaptors diff -r c2992fd74dad -r a954b780e3ab lemon/concept/ugraph.h --- a/lemon/concept/ugraph.h Wed Feb 22 18:26:56 2006 +0000 +++ b/lemon/concept/ugraph.h Thu Feb 23 08:55:54 2006 +0000 @@ -864,6 +864,10 @@ void nextIn(Edge&) const {} + void firstInc(UEdge &, bool &, const Node &) const {} + + void nextInc(UEdge &, bool &) const {} + /// \brief Base node of the iterator /// /// Returns the base node (the source in this case) of the iterator diff -r c2992fd74dad -r a954b780e3ab lemon/graph_adaptor.h --- a/lemon/graph_adaptor.h Wed Feb 22 18:26:56 2006 +0000 +++ b/lemon/graph_adaptor.h Thu Feb 23 08:55:54 2006 +0000 @@ -698,13 +698,13 @@ }; template - class UndirectGraphAdaptorBase : + class UndirGraphAdaptorBase : public UGraphBaseExtender > { public: typedef _Graph Graph; typedef UGraphBaseExtender > Parent; protected: - UndirectGraphAdaptorBase() : Parent() { } + UndirGraphAdaptorBase() : Parent() { } public: typedef typename Parent::UEdge UEdge; typedef typename Parent::Edge Edge; @@ -712,17 +712,17 @@ template class EdgeMap { protected: - const UndirectGraphAdaptorBase<_Graph>* g; + const UndirGraphAdaptorBase<_Graph>* g; template friend class EdgeMap; typename _Graph::template EdgeMap forward_map, backward_map; public: typedef T Value; typedef Edge Key; - EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g) : g(&_g), + EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) : g(&_g), forward_map(*(g->graph)), backward_map(*(g->graph)) { } - EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g, T a) : g(&_g), + EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, T a) : g(&_g), forward_map(*(g->graph), a), backward_map(*(g->graph), a) { } void set(Edge e, T a) { @@ -748,10 +748,10 @@ typedef T Value; typedef UEdge Key; - UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g) : + UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g) : map(*(g.graph)) { } - UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g, T a) : + UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, T a) : map(*(g.graph), a) { } void set(UEdge e, T a) { @@ -773,17 +773,17 @@ /// /// \author Marton Makai template - class UndirectGraphAdaptor : + class UndirGraphAdaptor : public UGraphAdaptorExtender< - UndirectGraphAdaptorBase<_Graph> > { + UndirGraphAdaptorBase<_Graph> > { public: typedef _Graph Graph; typedef UGraphAdaptorExtender< - UndirectGraphAdaptorBase<_Graph> > Parent; + UndirGraphAdaptorBase<_Graph> > Parent; protected: - UndirectGraphAdaptor() { } + UndirGraphAdaptor() { } public: - UndirectGraphAdaptor(_Graph& _graph) { + UndirGraphAdaptor(_Graph& _graph) { setGraph(_graph); } }; diff -r c2992fd74dad -r a954b780e3ab lemon/ugraph_adaptor.h --- a/lemon/ugraph_adaptor.h Wed Feb 22 18:26:56 2006 +0000 +++ b/lemon/ugraph_adaptor.h Thu Feb 23 08:55:54 2006 +0000 @@ -511,9 +511,6 @@ /// \brief A graph adaptor for hiding nodes and edges from an undirected /// graph. /// - /// \warning Graph adaptors are in even more experimental state than the - /// other parts of the lib. Use them at you own risk. - /// /// SubUGraphAdaptor shows the undirected graph with filtered node-set and /// edge-set. If the \c checked parameter is true then it filters the edgeset /// to do not get invalid edges without source or target. @@ -528,11 +525,6 @@ /// Note that \c n is of type \c SubGA::NodeIt, but it can be converted to /// \c Graph::Node that is why \c g.id(n) can be applied. /// - /// For examples see also the documentation of NodeSubUGraphAdaptor and - /// EdgeSubUGraphAdaptor. - /// - /// \author Marton Makai - template class SubUGraphAdaptor : @@ -553,13 +545,42 @@ } }; + template + SubUGraphAdaptor + subUGraphAdaptor(const UGraph& graph, + NodeFilterMap& nfm, EdgeFilterMap& efm) { + return SubUGraphAdaptor + (graph, nfm, efm); + } + + template + SubUGraphAdaptor + subUGraphAdaptor(const UGraph& graph, + NodeFilterMap& nfm, EdgeFilterMap& efm) { + return SubUGraphAdaptor + (graph, nfm, efm); + } + + template + SubUGraphAdaptor + subUGraphAdaptor(const UGraph& graph, + NodeFilterMap& nfm, EdgeFilterMap& efm) { + return SubUGraphAdaptor + (graph, nfm, efm); + } + + template + SubUGraphAdaptor + subUGraphAdaptor(const UGraph& graph, + NodeFilterMap& nfm, EdgeFilterMap& efm) { + return SubUGraphAdaptor(graph, nfm, efm); + } + /// \ingroup graph_adaptors /// - /// \brief An adaptor for hiding nodes from an undorected graph. + /// \brief An adaptor for hiding nodes from an undirected graph. /// - /// \warning Graph adaptors are in even more experimental state - /// than the other - /// parts of the lib. Use them at you own risk. /// /// An adaptor for hiding nodes from an undirected graph. /// This adaptor specializes SubUGraphAdaptor in the way that only @@ -567,7 +588,6 @@ /// can be filtered. In usual case the checked parameter is true, we get the /// induced subgraph. But if the checked parameter is false then we can only /// filter only isolated nodes. - /// \author Marton Makai template class NodeSubUGraphAdaptor : public SubUGraphAdaptor<_UGraph, NodeFilterMap, @@ -609,8 +629,6 @@ /// This adaptor specializes SubUGraphAdaptor in the way that /// only the edge-set /// can be filtered. - /// - ///\author Marton Makai template class EdgeSubUGraphAdaptor : public SubUGraphAdaptor<_UGraph, ConstMap, @@ -643,7 +661,7 @@ } template - class DirectUGraphAdaptorBase { + class DirUGraphAdaptorBase { public: typedef _UGraph Graph; @@ -736,19 +754,19 @@ class NodeMap : public _UGraph::template NodeMap<_Value> { public: typedef typename _UGraph::template NodeMap<_Value> Parent; - explicit NodeMap(const DirectUGraphAdaptorBase& ga) + explicit NodeMap(const DirUGraphAdaptorBase& ga) : Parent(*ga.graph) { } - NodeMap(const DirectUGraphAdaptorBase& ga, const _Value& value) + NodeMap(const DirUGraphAdaptorBase& ga, const _Value& value) : Parent(*ga.graph, value) { } }; template class EdgeMap : public _UGraph::template UEdgeMap<_Value> { public: - typedef typename _UGraph::template EdgeMap<_Value> Parent; - explicit EdgeMap(const DirectUGraphAdaptorBase& ga) + typedef typename _UGraph::template UEdgeMap<_Value> Parent; + explicit EdgeMap(const DirUGraphAdaptorBase& ga) : Parent(*ga.graph) { } - EdgeMap(const DirectUGraphAdaptorBase& ga, const _Value& value) + EdgeMap(const DirUGraphAdaptorBase& ga, const _Value& value) : Parent(*ga.graph, value) { } }; @@ -769,33 +787,43 @@ }; - template - class DirectUGraphAdaptor : + /// \ingroup graph_adaptors + /// \brief A directed graph is made from a undirected graph by an adaptor + /// + /// This adaptor gives a direction for each uedge in the undirected graph. + /// The direction of the edges stored in the DirectionMap. This map is + /// a bool map on the undirected edges. If the uedge is mapped to true + /// then the direction of the directed edge will be the same as the + /// default direction of the uedge. The edges can be easily reverted + /// by the reverseEdge member in the adaptor. + template > + class DirUGraphAdaptor : public GraphAdaptorExtender< - DirectUGraphAdaptorBase<_Graph, DirectionMap> > { + DirUGraphAdaptorBase<_Graph, DirectionMap> > { public: typedef _Graph Graph; typedef GraphAdaptorExtender< - DirectUGraphAdaptorBase<_Graph, DirectionMap> > Parent; + DirUGraphAdaptorBase<_Graph, DirectionMap> > Parent; protected: - DirectUGraphAdaptor() { } + DirUGraphAdaptor() { } public: - DirectUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) { + DirUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) { setGraph(_graph); setDirectionMap(_direction_map); } }; template - DirectUGraphAdaptor - directUGraphAdaptor(const UGraph& graph, DirectionMap& dm) { - return DirectUGraphAdaptor(graph, dm); + DirUGraphAdaptor + dirUGraphAdaptor(const UGraph& graph, DirectionMap& dm) { + return DirUGraphAdaptor(graph, dm); } template - DirectUGraphAdaptor - directUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) { - return DirectUGraphAdaptor(graph, dm); + DirUGraphAdaptor + dirUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) { + return DirUGraphAdaptor(graph, dm); } } diff -r c2992fd74dad -r a954b780e3ab test/graph_adaptor_test.cc --- a/test/graph_adaptor_test.cc Wed Feb 22 18:26:56 2006 +0000 +++ b/test/graph_adaptor_test.cc Thu Feb 23 08:55:54 2006 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include #include"test/test_tools.h" #include"test/graph_test.h" @@ -66,8 +67,17 @@ checkConcept > >(); - /// \bug why does not compile with StaticGraph - checkConcept >(); + checkConcept >(); + + checkConcept , UGraph::UEdgeMap > >(); + checkConcept > >(); + checkConcept > >(); + + checkConcept > >(); } std::cout << __FILE__ ": All tests passed.\n";