# HG changeset patch # User marci # Date 1079957864 0 # Node ID 734dd06499411b5afa41f2f4eaa0ec37737e9b2d # Parent ae5f9ca94be76661f420328c9e6803409939e73b . diff -r ae5f9ca94be7 -r 734dd0649941 src/work/marci/graph_wrapper.h --- a/src/work/marci/graph_wrapper.h Mon Mar 22 10:21:30 2004 +0000 +++ b/src/work/marci/graph_wrapper.h Mon Mar 22 12:17:44 2004 +0000 @@ -103,7 +103,7 @@ typedef typename GraphWrapper::EdgeIt EdgeIt; //GraphWrapperSkeleton() : gw() { } - GraphWrapperSkeleton(GraphWrapper& _gw) : gw(_gw) { } + GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { } void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); } BaseGraph& getGraph() const { return gw.getGraph(); } @@ -160,87 +160,173 @@ }; }; +// template +// class RevGraphWrapper +// { +// protected: +// Graph* graph; + +// public: +// typedef Graph BaseGraph; + +// typedef typename Graph::Node Node; +// typedef typename Graph::NodeIt NodeIt; + +// typedef typename Graph::Edge Edge; +// typedef typename Graph::OutEdgeIt InEdgeIt; +// typedef typename Graph::InEdgeIt OutEdgeIt; +// //typedef typename Graph::SymEdgeIt SymEdgeIt; +// typedef typename Graph::EdgeIt EdgeIt; + +// //RevGraphWrapper() : graph(0) { } +// RevGraphWrapper(Graph& _graph) : graph(&_graph) { } + +// void setGraph(Graph& _graph) { graph = &_graph; } +// Graph& getGraph() const { return (*graph); } + +// template I& first(I& i) const { return graph->first(i); } +// template I& first(I& i, const P& p) const { +// return graph->first(i, p); } + +// template I getNext(const I& i) const { +// return graph->getNext(i); } +// template I& next(I &i) const { return graph->next(i); } + +// template< typename It > It first() const { +// It e; first(e); return e; } + +// template< typename It > It first(const Node& v) const { +// It e; first(e, v); return e; } + +// Node head(const Edge& e) const { return graph->tail(e); } +// Node tail(const Edge& e) const { return graph->head(e); } + +// template bool valid(const I& i) const +// { return graph->valid(i); } + +// //template void setInvalid(const I &i); +// //{ return graph->setInvalid(i); } + +// template Node aNode(const I& e) const { +// return graph->aNode(e); } +// template Node bNode(const I& e) const { +// return graph->bNode(e); } + +// Node addNode() const { return graph->addNode(); } +// Edge addEdge(const Node& tail, const Node& head) const { +// return graph->addEdge(tail, head); } + +// int nodeNum() const { return graph->nodeNum(); } +// int edgeNum() const { return graph->edgeNum(); } + +// template void erase(const I& i) const { graph->erase(i); } + +// void clear() const { graph->clear(); } + +// template class NodeMap : public Graph::NodeMap { +// public: +// NodeMap(const RevGraphWrapper& _G) : +// Graph::NodeMap(_G.getGraph()) { } +// NodeMap(const RevGraphWrapper& _G, T a) : +// Graph::NodeMap(_G.getGraph(), a) { } +// }; + +// template class EdgeMap : public Graph::EdgeMap { +// public: +// EdgeMap(const RevGraphWrapper& _G) : +// Graph::EdgeMap(_G.getGraph()) { } +// EdgeMap(const RevGraphWrapper& _G, T a) : +// Graph::EdgeMap(_G.getGraph(), a) { } +// }; +// }; + template - class RevGraphWrapper - { + class RevGraphWrapper : + public GraphWrapperSkeleton< TrivGraphWrapper > { protected: - Graph* graph; + //Graph* graph; + + public: + //typedef Graph BaseGraph; + + //typedef typename Graph::Node Node; + //typedef typename Graph::NodeIt NodeIt; - public: - typedef Graph BaseGraph; - - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - - typedef typename Graph::Edge Edge; - typedef typename Graph::OutEdgeIt InEdgeIt; - typedef typename Graph::InEdgeIt OutEdgeIt; + //typedef typename Graph::Edge Edge; + typedef typename GraphWrapperSkeleton< TrivGraphWrapper >::OutEdgeIt InEdgeIt; + typedef typename GraphWrapperSkeleton< TrivGraphWrapper >::InEdgeIt OutEdgeIt; //typedef typename Graph::SymEdgeIt SymEdgeIt; - typedef typename Graph::EdgeIt EdgeIt; + //typedef typename Graph::EdgeIt EdgeIt; //RevGraphWrapper() : graph(0) { } - RevGraphWrapper(Graph& _graph) : graph(&_graph) { } + RevGraphWrapper(Graph& _graph) : GraphWrapperSkeleton< TrivGraphWrapper >(TrivGraphWrapper(_graph)) { } + + //void setGraph(Graph& _graph) { graph = &_graph; } + //Graph& getGraph() const { return (*graph); } + + //template I& first(I& i) const { return graph->first(i); } + //template I& first(I& i, const P& p) const { + // return graph->first(i, p); } - void setGraph(Graph& _graph) { graph = &_graph; } - Graph& getGraph() const { return (*graph); } - - template I& first(I& i) const { return graph->first(i); } - template I& first(I& i, const P& p) const { - return graph->first(i, p); } + //template I getNext(const I& i) const { + // return graph->getNext(i); } + //template I& next(I &i) const { return graph->next(i); } - template I getNext(const I& i) const { - return graph->getNext(i); } - template I& next(I &i) const { return graph->next(i); } + //template< typename It > It first() const { + // It e; first(e); return e; } - template< typename It > It first() const { - It e; first(e); return e; } + //template< typename It > It first(const Node& v) const { + // It e; first(e, v); return e; } - template< typename It > It first(const Node& v) const { - It e; first(e, v); return e; } - - Node head(const Edge& e) const { return graph->tail(e); } - Node tail(const Edge& e) const { return graph->head(e); } + //Node head(const Edge& e) const { return graph->tail(e); } + //Node tail(const Edge& e) const { return graph->head(e); } - template bool valid(const I& i) const - { return graph->valid(i); } + //template bool valid(const I& i) const + // { return graph->valid(i); } //template void setInvalid(const I &i); //{ return graph->setInvalid(i); } - template Node aNode(const I& e) const { - return graph->aNode(e); } - template Node bNode(const I& e) const { - return graph->bNode(e); } + //template Node aNode(const I& e) const { + // return graph->aNode(e); } + //template Node bNode(const I& e) const { + // return graph->bNode(e); } - Node addNode() const { return graph->addNode(); } - Edge addEdge(const Node& tail, const Node& head) const { - return graph->addEdge(tail, head); } + //Node addNode() const { return graph->addNode(); } + //Edge addEdge(const Node& tail, const Node& head) const { + // return graph->addEdge(tail, head); } - int nodeNum() const { return graph->nodeNum(); } - int edgeNum() const { return graph->edgeNum(); } + //int nodeNum() const { return graph->nodeNum(); } + //int edgeNum() const { return graph->edgeNum(); } - template void erase(const I& i) const { graph->erase(i); } + //template void erase(const I& i) const { graph->erase(i); } - void clear() const { graph->clear(); } + //void clear() const { graph->clear(); } - template class NodeMap : public Graph::NodeMap { + template class NodeMap : + public GraphWrapperSkeleton< TrivGraphWrapper >::NodeMap + { public: NodeMap(const RevGraphWrapper& _G) : - Graph::NodeMap(_G.getGraph()) { } + GraphWrapperSkeleton< TrivGraphWrapper >::NodeMap(_G) { } NodeMap(const RevGraphWrapper& _G, T a) : - Graph::NodeMap(_G.getGraph(), a) { } + GraphWrapperSkeleton< TrivGraphWrapper >::NodeMap(_G, a) { } }; - - template class EdgeMap : public Graph::EdgeMap { + + template class EdgeMap : + public GraphWrapperSkeleton< TrivGraphWrapper >::EdgeMap { public: EdgeMap(const RevGraphWrapper& _G) : - Graph::EdgeMap(_G.getGraph()) { } + GraphWrapperSkeleton< TrivGraphWrapper >::EdgeMap(_G) { } EdgeMap(const RevGraphWrapper& _G, T a) : - Graph::EdgeMap(_G.getGraph(), a) { } + GraphWrapperSkeleton< TrivGraphWrapper >::EdgeMap(_G, a) { } }; }; + + + template class UndirGraphWrapper { protected: