diff -r a7d5fe18d8f9 -r 3fef334f5f37 src/work/marci/merge_node_graph_wrapper.h --- a/src/work/marci/merge_node_graph_wrapper.h Thu Nov 18 14:37:22 2004 +0000 +++ b/src/work/marci/merge_node_graph_wrapper.h Thu Nov 18 22:31:21 2004 +0000 @@ -22,6 +22,8 @@ #include #include #include +using std::cout; +using std::endl; #include #include @@ -125,24 +127,6 @@ NodeMap(const MergeNodeGraphWrapperBase<_Graph1, _Graph2>& gw, const _Value& value) : ParentMap1(gw, value), ParentMap2(gw, value) { } -// NodeMap(const NodeMap& copy) -// : ParentMap1(copy), -// ParentMap2(copy) { } -// template -// NodeMap(const NodeMap& copy) -// : ParentMap1(copy), -// ParentMap2(copy) { } -// NodeMap& operator=(const NodeMap& copy) { -// ParentMap1::operator=(copy); -// ParentMap2::operator=(copy); -// return *this; -// } -// template -// NodeMap& operator=(const NodeMap& copy) { -// ParentMap1::operator=(copy); -// ParentMap2::operator=(copy); -// return *this; -// } _Value operator[](const Node& n) const { if (!n.backward) return ParentMap1::operator[](n); @@ -161,6 +145,7 @@ }; + //not yet working template class MergeNodeGraphWrapperBase< _Graph1, _Graph2, typename boost::enable_if< @@ -183,6 +168,7 @@ void next() const; }; + //not yet working template class MergeNodeGraphWrapperBase< _Graph1, _Graph2, typename boost::enable_if< @@ -205,6 +191,7 @@ void next() const; }; + //not yet working template class MergeNodeGraphWrapperBase< _Graph1, _Graph2, typename boost::enable_if< @@ -245,6 +232,128 @@ } }; + + template + class NewEdgeSetGraphWrapperBase : public GraphWrapperBase<_Graph> { + public: + typedef GraphWrapperBase<_Graph> Parent; + typedef _Graph Graph; + typedef _EdgeSetGraph EdgeSetGraph; + typedef typename _Graph::Node Node; + typedef typename _EdgeSetGraph::Node ENode; + protected: + EdgeSetGraph* edge_set_graph; + typename Graph::NodeMap* e_node; + typename EdgeSetGraph::NodeMap* n_node; + void setEdgeSetGraph(EdgeSetGraph& _edge_set_graph) { + edge_set_graph=&_edge_set_graph; + } + /// For each node of \c Graph, this gives a node of \c EdgeSetGraph . + void setNodeMap(typename EdgeSetGraph::NodeMap& _n_node) { + n_node=&_n_node; + } + /// For each node of \c EdgeSetGraph, this gives a node of \c Graph . + void setENodeMap(typename Graph::NodeMap& _e_node) { + e_node=&_e_node; + } + public: + class Edge : public EdgeSetGraph::Edge { + typedef typename EdgeSetGraph::Edge Parent; + public: + Edge() { } + Edge(const Parent& e) : Parent(e) { } + Edge(Invalid i) : Parent(i) { } + }; + + using Parent::first; + void first(Edge &e) const { + edge_set_graph->first(e); + } + void firstOut(Edge& e, const Node& n) const { +// cout << e_node << endl; +// cout << n_node << endl; + edge_set_graph->firstOut(e, (*e_node)[n]); + } + void firstIn(Edge& e, const Node& n) const { + edge_set_graph->firstIn(e, (*e_node)[n]); + } + + using Parent::next; + void next(Edge &e) const { + edge_set_graph->next(e); + } + void nextOut(Edge& e) const { + edge_set_graph->nextOut(e); + } + void nextIn(Edge& e) const { + edge_set_graph->nextIn(e); + } + + Node source(const Edge& e) const { + return (*n_node)[edge_set_graph->source(e)]; + } + Node target(const Edge& e) const { + return (*n_node)[edge_set_graph->target(e)]; + } + + int edgeNum() const { return edge_set_graph->edgeNum(); } + + Edge addEdge(const Node& u, const Node& v) { + return edge_set_graph->addEdge((*e_node)[u], (*e_node)[v]); + } + + using Parent::erase; + void erase(const Edge& i) const { edge_set_graph->erase(i); } + + void clear() const { Parent::clear(); edge_set_graph->clear(); } + + bool forward(const Edge& e) const { return edge_set_graph->forward(e); } + bool backward(const Edge& e) const { return edge_set_graph->backward(e); } + + using Parent::id; + int id(const Edge& e) const { return edge_set_graph->id(e); } + + Edge opposite(const Edge& e) const { return edge_set_graph->opposite(e); } + + template + class EdgeMap : public EdgeSetGraph::EdgeMap<_Value> { + public: + typedef typename EdgeSetGraph::EdgeMap<_Value> Parent; + typedef _Value Value; + typedef Edge Key; + EdgeMap(const NewEdgeSetGraphWrapperBase& gw) : + Parent(*(gw.edge_set_graph)) { } + EdgeMap(const NewEdgeSetGraphWrapperBase& gw, const _Value& _value) : + Parent(*(gw.edge_set_graph), _value) { } + }; + + }; + + template + class NewEdgeSetGraphWrapper : + public IterableGraphExtender< + NewEdgeSetGraphWrapperBase<_Graph, _EdgeSetGraph> > { + public: + typedef _Graph Graph; + typedef _EdgeSetGraph EdgeSetGraph; + typedef IterableGraphExtender< + NewEdgeSetGraphWrapper<_Graph, _EdgeSetGraph> > Parent; + protected: + NewEdgeSetGraphWrapper() { } + public: + NewEdgeSetGraphWrapper(_Graph& _graph, + _EdgeSetGraph& _edge_set_graph, + typename _Graph:: + NodeMap& _e_node, + typename _EdgeSetGraph:: + NodeMap& _n_node) { + setGraph(_graph); + setEdgeSetGraph(_edge_set_graph); + setNodeMap(_n_node); + setENodeMap(_e_node); + } + }; + } //namespace lemon #endif //LEMON_MERGE_NODE_GRAPH_WRAPPER_H