[Lemon-commits] [lemon_svn] marci: r1056 - in hugo/branches/hugo++/src: hugo work/marci
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:59 CET 2006
Author: marci
Date: Fri Aug 27 18:49:24 2004
New Revision: 1056
Modified:
hugo/branches/hugo++/src/hugo/graph_wrapper.h
hugo/branches/hugo++/src/work/marci/iterator_bfs_demo.cc
Log:
SubBidirGraphWrapper hugo-0.2-++
Modified: hugo/branches/hugo++/src/hugo/graph_wrapper.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/graph_wrapper.h (original)
+++ hugo/branches/hugo++/src/hugo/graph_wrapper.h Fri Aug 27 18:49:24 2004
@@ -116,7 +116,7 @@
friend class GraphWrapper<Graph>;
public:
NodeIt() { }
- NodeIt(const Node& n) : Node(n) { }
+ // NodeIt(const NodeIt& n) : Node(n), gw(n.gw) { }
NodeIt(Invalid i) : Node(i) { }
NodeIt(const GraphWrapper<Graph>& _gw) :
Node(typename Graph::NodeIt(*(_gw.graph))), gw(&_gw) { }
@@ -141,7 +141,7 @@
friend class GraphWrapper<Graph>;
public:
OutEdgeIt() { }
- OutEdgeIt(const Edge& e) : Edge(e) { }
+ //OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }
OutEdgeIt(Invalid i) : Edge(i) { }
OutEdgeIt(const GraphWrapper<Graph>& _gw, const Node& n) :
Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
@@ -158,7 +158,7 @@
friend class GraphWrapper<Graph>;
public:
InEdgeIt() { }
- InEdgeIt(const Edge& e) : Edge(e) { }
+ //InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }
InEdgeIt(Invalid i) : Edge(i) { }
InEdgeIt(const GraphWrapper<Graph>& _gw, const Node& n) :
Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
@@ -176,7 +176,7 @@
friend class GraphWrapper<Graph>;
public:
EdgeIt() { }
- EdgeIt(const Edge& e) : Node(e) { }
+ //EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { }
EdgeIt(Invalid i) : Edge(i) { }
EdgeIt(const GraphWrapper<Graph>& _gw) :
Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { }
@@ -289,7 +289,7 @@
friend class GraphWrapper<Graph>;
public:
OutEdgeIt() { }
- OutEdgeIt(const Edge& e) : Edge(e) { }
+ //OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }
OutEdgeIt(Invalid i) : Edge(i) { }
OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) :
Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
@@ -306,7 +306,7 @@
friend class GraphWrapper<Graph>;
public:
InEdgeIt() { }
- InEdgeIt(const Edge& e) : Edge(e) { }
+ //InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }
InEdgeIt(Invalid i) : Edge(i) { }
InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) :
Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
@@ -662,9 +662,6 @@
public:
typedef GraphWrapper<Graph> Parent;
protected:
- //const CapacityMap* capacity;
- //FlowMap* flow;
-
ForwardFilterMap* forward_filter;
BackwardFilterMap* backward_filter;
@@ -683,6 +680,11 @@
BackwardFilterMap& _backward_filter) :
GraphWrapper<Graph>(_graph),
forward_filter(&_forward_filter), backward_filter(&_backward_filter) { }
+ SubBidirGraphWrapper(const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>& gw) :
+ Parent(gw),
+ forward_filter(gw.forward_filter),
+ backward_filter(gw.backward_filter) { }
class Edge;
class OutEdgeIt;
@@ -693,8 +695,9 @@
template<typename T> class EdgeMap;
typedef typename GraphWrapper<Graph>::Node Node;
- typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
+ //typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
+ typedef typename Graph::Edge GraphEdge;
class Edge : public Graph::Edge {
friend class SubBidirGraphWrapper<Graph,
ForwardFilterMap, BackwardFilterMap>;
@@ -707,116 +710,196 @@
public:
Edge() { }
///\bug =false kell-e? zsoltnak kell az addEdge miatt
- Edge(const typename Graph::Edge& _e, bool _backward=false) :
- Graph::Edge(_e), backward(_backward) { }
- Edge(const Invalid& i) : Graph::Edge(i), backward(true) { }
+ Edge(const typename Graph::Edge& e, bool _backward/*=false*/) :
+ Graph::Edge(e), backward(_backward) { }
+ Edge(Invalid i) : Graph::Edge(i), backward(true) { }
//the unique invalid iterator
- friend bool operator==(const Edge& u, const Edge& v) {
- return (v.backward==u.backward &&
- static_cast<typename Graph::Edge>(u)==
+// friend bool operator==(const Edge& u, const Edge& v) {
+// return (u.backward==v.backward &&
+// static_cast<typename Graph::Edge>(u)==
+// static_cast<typename Graph::Edge>(v));
+// }
+// friend bool operator!=(const Edge& u, const Edge& v) {
+// return (u.backward!=v.backward ||
+// static_cast<typename Graph::Edge>(u)!=
+// static_cast<typename Graph::Edge>(v));
+// }
+ bool operator==(const Edge& v) const {
+ return (this->backward==v.backward &&
+ static_cast<typename Graph::Edge>(*this)==
static_cast<typename Graph::Edge>(v));
}
- friend bool operator!=(const Edge& u, const Edge& v) {
- return (v.backward!=u.backward ||
- static_cast<typename Graph::Edge>(u)!=
+ bool operator!=(const Edge& v) const {
+ return (this->backward!=v.backward ||
+ static_cast<typename Graph::Edge>(*this)!=
static_cast<typename Graph::Edge>(v));
- }
+ }
};
- class OutEdgeIt {
+ class OutEdgeIt : public Edge {
friend class SubBidirGraphWrapper<Graph,
ForwardFilterMap, BackwardFilterMap>;
protected:
- typename Graph::OutEdgeIt out;
- typename Graph::InEdgeIt in;
- bool backward;
+ const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>* gw;
public:
OutEdgeIt() { }
- //FIXME
-// OutEdgeIt(const Edge& e) : Edge(e) { }
- OutEdgeIt(const Invalid& i) : out(i), in(i), backward(true) { }
+ OutEdgeIt(Invalid i) : Edge(i) { }
//the unique invalid iterator
OutEdgeIt(const SubBidirGraphWrapper<Graph,
- ForwardFilterMap, BackwardFilterMap>& _G, Node v) {
- backward=false;
- _G.graph->first(out, v);
- while(_G.graph->valid(out) && !(*_G.forward_filter)[*this]) { _G.graph->next(out); }
- if (!_G.graph->valid(out)) {
- backward=true;
- _G.graph->first(in, v);
- while(_G.graph->valid(in) && !(*_G.backward_filter)[*this]) { _G.graph->next(in); }
- }
+ ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) :
+ Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), false), gw(&_gw) {
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->forward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+ if (*static_cast<GraphEdge*>(this)==INVALID)
+ *static_cast<Edge*>(this)=
+ Edge(typename Graph::InEdgeIt(*(_gw.graph), n), true);
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
}
- operator Edge() const {
-// Edge e;
-// e.forward=this->forward;
-// if (this->forward) e=out; else e=in;
-// return e;
- if (this->backward)
- return Edge(in, this->backward);
- else
- return Edge(out, this->backward);
+ OutEdgeIt(const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) :
+ Edge(e), gw(&_gw) { }
+ OutEdgeIt& operator++() {
+ if (!this->backward) {
+ Node n=gw->tail(*this);
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->forward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+ if (*static_cast<GraphEdge*>(this)==INVALID)
+ *static_cast<Edge*>(this)=
+ Edge(typename Graph::InEdgeIt(*(gw->graph), n), true);
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+ } else {
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+ }
+ return *this;
}
};
- class InEdgeIt {
+ class InEdgeIt : public Edge {
friend class SubBidirGraphWrapper<Graph,
ForwardFilterMap, BackwardFilterMap>;
protected:
- typename Graph::OutEdgeIt out;
- typename Graph::InEdgeIt in;
- bool backward;
+ const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>* gw;
public:
InEdgeIt() { }
- //FIXME
-// OutEdgeIt(const Edge& e) : Edge(e) { }
- InEdgeIt(const Invalid& i) : out(i), in(i), backward(true) { }
+ InEdgeIt(Invalid i) : Edge(i) { }
//the unique invalid iterator
InEdgeIt(const SubBidirGraphWrapper<Graph,
- ForwardFilterMap, BackwardFilterMap>& _G, Node v) {
- backward=false;
- _G.graph->first(in, v);
- while(_G.graph->valid(in) && !(*_G.forward_filter)[*this]) { _G.graph->next(in); }
- if (!_G.graph->valid(in)) {
- backward=true;
- _G.graph->first(out, v);
- while(_G.graph->valid(out) && !(*_G.backward_filter)[*this]) { _G.graph->next(out); }
- }
+ ForwardFilterMap, BackwardFilterMap>& _gw, const Node& n) :
+ Edge(typename Graph::InEdgeIt(*(_gw.graph), n), false), gw(&_gw) {
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->forward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+ if (*static_cast<GraphEdge*>(this)==INVALID)
+ *static_cast<Edge*>(this)=
+ Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), true);
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
}
- operator Edge() const {
-// Edge e;
-// e.forward=this->forward;
-// if (this->forward) e=out; else e=in;
-// return e;
- if (this->backward)
- return Edge(out, this->backward);
- else
- return Edge(in, this->backward);
+ InEdgeIt(const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) :
+ Edge(e), gw(&_gw) { }
+ InEdgeIt& operator++() {
+ if (!this->backward) {
+ Node n=gw->head(*this);
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->forward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+ if (*static_cast<GraphEdge*>(this)==INVALID)
+ *static_cast<Edge*>(this)=
+ Edge(typename Graph::OutEdgeIt(*(gw->graph), n), true);
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+ } else {
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+ }
+ return *this;
}
};
- class EdgeIt {
+ class EdgeIt : public Edge {
friend class SubBidirGraphWrapper<Graph,
ForwardFilterMap, BackwardFilterMap>;
protected:
- typename Graph::EdgeIt e;
- bool backward;
+ const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>* gw;
public:
EdgeIt() { }
- EdgeIt(const Invalid& i) : e(i), backward(true) { }
+ EdgeIt(Invalid i) : Edge(i) { }
+//the unique invalid iterator
EdgeIt(const SubBidirGraphWrapper<Graph,
- ForwardFilterMap, BackwardFilterMap>& _G) {
- backward=false;
- _G.graph->first(e);
- while (_G.graph->valid(e) && !(*_G.forward_filter)[*this]) _G.graph->next(e);
- if (!_G.graph->valid(e)) {
- backward=true;
- _G.graph->first(e);
- while (_G.graph->valid(e) && !(*_G.backward_filter)[*this]) _G.graph->next(e);
- }
+ ForwardFilterMap, BackwardFilterMap>& _gw) :
+ Edge(typename Graph::EdgeIt(*(_gw.graph)), false), gw(&_gw) {
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->forward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
+ if (*static_cast<GraphEdge*>(this)==INVALID)
+ *static_cast<Edge*>(this)=
+ Edge(typename Graph::EdgeIt(*(_gw.graph)), true);
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
}
- operator Edge() const {
- return Edge(e, this->backward);
+ EdgeIt(const SubBidirGraphWrapper<Graph,
+ ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) :
+ Edge(e), gw(&_gw) { }
+ EdgeIt& operator++() {
+ if (!this->backward) {
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->forward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
+ if (*static_cast<GraphEdge*>(this)==INVALID)
+ *static_cast<Edge*>(this)=
+ Edge(typename Graph::EdgeIt(*(gw->graph)), true);
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
+ } else {
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
+ while (*static_cast<GraphEdge*>(this)!=INVALID &&
+ !(*(gw->backward_filter))[*this])
+ *(static_cast<GraphEdge*>(this))=
+ ++(typename Graph::EdgeIt(*(gw->graph), *this));
+ }
+ return *this;
}
};
@@ -835,84 +918,84 @@
i=EdgeIt(*this); return i;
}
- using GraphWrapper<Graph>::next;
-// NodeIt& next(NodeIt& n) const { GraphWrapper<Graph>::next(n); return n; }
- OutEdgeIt& next(OutEdgeIt& e) const {
- if (!e.backward) {
- Node v=this->graph->aNode(e.out);
- this->graph->next(e.out);
- while(this->graph->valid(e.out) && !(*forward_filter)[e]) {
- this->graph->next(e.out); }
- if (!this->graph->valid(e.out)) {
- e.backward=true;
- this->graph->first(e.in, v);
- while(this->graph->valid(e.in) && !(*backward_filter)[e]) {
- this->graph->next(e.in); }
- }
- } else {
- this->graph->next(e.in);
- while(this->graph->valid(e.in) && !(*backward_filter)[e]) {
- this->graph->next(e.in); }
- }
- return e;
- }
-// FIXME Not tested
- InEdgeIt& next(InEdgeIt& e) const {
- if (!e.backward) {
- Node v=this->graph->aNode(e.in);
- this->graph->next(e.in);
- while(this->graph->valid(e.in) && !(*forward_filter)[e]) {
- this->graph->next(e.in); }
- if (!this->graph->valid(e.in)) {
- e.backward=true;
- this->graph->first(e.out, v);
- while(this->graph->valid(e.out) && !(*backward_filter)[e]) {
- this->graph->next(e.out); }
- }
- } else {
- this->graph->next(e.out);
- while(this->graph->valid(e.out) && !(*backward_filter)[e]) {
- this->graph->next(e.out); }
- }
- return e;
- }
- EdgeIt& next(EdgeIt& e) const {
- if (!e.backward) {
- this->graph->next(e.e);
- while(this->graph->valid(e.e) && !(*forward_filter)[e]) {
- this->graph->next(e.e); }
- if (!this->graph->valid(e.e)) {
- e.backward=true;
- this->graph->first(e.e);
- while(this->graph->valid(e.e) && !(*backward_filter)[e]) {
- this->graph->next(e.e); }
- }
- } else {
- this->graph->next(e.e);
- while(this->graph->valid(e.e) && !(*backward_filter)[e]) {
- this->graph->next(e.e); }
- }
- return e;
- }
+// using GraphWrapper<Graph>::next;
+// // NodeIt& next(NodeIt& n) const { GraphWrapper<Graph>::next(n); return n; }
+// OutEdgeIt& next(OutEdgeIt& e) const {
+// if (!e.backward) {
+// Node v=this->graph->aNode(e.out);
+// this->graph->next(e.out);
+// while(this->graph->valid(e.out) && !(*forward_filter)[e]) {
+// this->graph->next(e.out); }
+// if (!this->graph->valid(e.out)) {
+// e.backward=true;
+// this->graph->first(e.in, v);
+// while(this->graph->valid(e.in) && !(*backward_filter)[e]) {
+// this->graph->next(e.in); }
+// }
+// } else {
+// this->graph->next(e.in);
+// while(this->graph->valid(e.in) && !(*backward_filter)[e]) {
+// this->graph->next(e.in); }
+// }
+// return e;
+// }
+// // FIXME Not tested
+// InEdgeIt& next(InEdgeIt& e) const {
+// if (!e.backward) {
+// Node v=this->graph->aNode(e.in);
+// this->graph->next(e.in);
+// while(this->graph->valid(e.in) && !(*forward_filter)[e]) {
+// this->graph->next(e.in); }
+// if (!this->graph->valid(e.in)) {
+// e.backward=true;
+// this->graph->first(e.out, v);
+// while(this->graph->valid(e.out) && !(*backward_filter)[e]) {
+// this->graph->next(e.out); }
+// }
+// } else {
+// this->graph->next(e.out);
+// while(this->graph->valid(e.out) && !(*backward_filter)[e]) {
+// this->graph->next(e.out); }
+// }
+// return e;
+// }
+// EdgeIt& next(EdgeIt& e) const {
+// if (!e.backward) {
+// this->graph->next(e.e);
+// while(this->graph->valid(e.e) && !(*forward_filter)[e]) {
+// this->graph->next(e.e); }
+// if (!this->graph->valid(e.e)) {
+// e.backward=true;
+// this->graph->first(e.e);
+// while(this->graph->valid(e.e) && !(*backward_filter)[e]) {
+// this->graph->next(e.e); }
+// }
+// } else {
+// this->graph->next(e.e);
+// while(this->graph->valid(e.e) && !(*backward_filter)[e]) {
+// this->graph->next(e.e); }
+// }
+// return e;
+// }
Node tail(Edge e) const {
return ((!e.backward) ? this->graph->tail(e) : this->graph->head(e)); }
Node head(Edge e) const {
return ((!e.backward) ? this->graph->head(e) : this->graph->tail(e)); }
- Node aNode(OutEdgeIt e) const {
- return ((!e.backward) ? this->graph->aNode(e.out) :
- this->graph->aNode(e.in)); }
- Node bNode(OutEdgeIt e) const {
- return ((!e.backward) ? this->graph->bNode(e.out) :
- this->graph->bNode(e.in)); }
-
- Node aNode(InEdgeIt e) const {
- return ((!e.backward) ? this->graph->aNode(e.in) :
- this->graph->aNode(e.out)); }
- Node bNode(InEdgeIt e) const {
- return ((!e.backward) ? this->graph->bNode(e.in) :
- this->graph->bNode(e.out)); }
+// Node aNode(OutEdgeIt e) const {
+// return ((!e.backward) ? this->graph->aNode(e.out) :
+// this->graph->aNode(e.in)); }
+// Node bNode(OutEdgeIt e) const {
+// return ((!e.backward) ? this->graph->bNode(e.out) :
+// this->graph->bNode(e.in)); }
+
+// Node aNode(InEdgeIt e) const {
+// return ((!e.backward) ? this->graph->aNode(e.in) :
+// this->graph->aNode(e.out)); }
+// Node bNode(InEdgeIt e) const {
+// return ((!e.backward) ? this->graph->bNode(e.in) :
+// this->graph->bNode(e.out)); }
/// Gives back the opposite edge.
Edge opposite(const Edge& e) const {
@@ -929,11 +1012,11 @@
// int id(Node v) const { return graph->id(v); }
- bool valid(Node n) const { return GraphWrapper<Graph>::valid(n); }
- bool valid(Edge e) const {
- return this->graph->valid(e);
- //return e.forward ? graph->valid(e.out) : graph->valid(e.in);
- }
+// bool valid(Node n) const { return GraphWrapper<Graph>::valid(n); }
+// bool valid(Edge e) const {
+// return this->graph->valid(e);
+// //return e.forward ? graph->valid(e.out) : graph->valid(e.in);
+// }
bool forward(const Edge& e) const { return !e.backward; }
bool backward(const Edge& e) const { return e.backward; }
@@ -975,11 +1058,11 @@
typedef T ValueType;
typedef Edge KeyType;
EdgeMap(const SubBidirGraphWrapper<Graph,
- ForwardFilterMap, BackwardFilterMap>& _G) :
- forward_map(*(_G.graph)), backward_map(*(_G.graph)) { }
+ ForwardFilterMap, BackwardFilterMap>& g) :
+ forward_map(*(g.graph)), backward_map(*(g.graph)) { }
EdgeMap(const SubBidirGraphWrapper<Graph,
- ForwardFilterMap, BackwardFilterMap>& _G, T a) :
- forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { }
+ ForwardFilterMap, BackwardFilterMap>& g, T a) :
+ forward_map(*(g.graph), a), backward_map(*(g.graph), a) { }
void set(Edge e, T a) {
if (!e.backward)
forward_map.set(e/*.out*/, a);
Modified: hugo/branches/hugo++/src/work/marci/iterator_bfs_demo.cc
==============================================================================
--- hugo/branches/hugo++/src/work/marci/iterator_bfs_demo.cc (original)
+++ hugo/branches/hugo++/src/work/marci/iterator_bfs_demo.cc Fri Aug 27 18:49:24 2004
@@ -28,8 +28,8 @@
int main (int, char*[])
{
- //typedef SmartGraph Graph;
- typedef SageGraph Graph;
+ typedef SmartGraph Graph;
+ //typedef SageGraph Graph;
typedef Graph::Node Node;
typedef Graph::Edge Edge;
@@ -316,84 +316,87 @@
-// {
-// typedef BidirGraphWrapper<const Graph> GW;
-// GW gw(G);
+ {
+ typedef BidirGraphWrapper<const Graph> GW;
+ GW gw(G);
-// EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
+ EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
-// cout << "bfs and dfs iterator demo on the undirected graph" << endl;
-// for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) {
-// cout << node_name[GW::Node(n)] << ": ";
-// cout << "out edges: ";
-// for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e))
-// cout << edge_name[e] << " ";
-// cout << "in edges: ";
-// for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e))
-// cout << edge_name[e] << " ";
-// cout << endl;
+ cout << "bfs and dfs iterator demo on the bidirected graph" << endl;
+// for(GW::EdgeIt e(gw); e!=INVALID; ++e) {
+// cout << node_name[gw.tail(e)] << "->" << node_name[gw.head(e)] << " ";
+// }
+ for(GW::NodeIt n(gw); n!=INVALID; ++n) {
+ cout << node_name[GW::Node(n)] << ": ";
+ cout << "out edges: ";
+ for(GW::OutEdgeIt e(gw, n); e!=INVALID; ++e)
+ cout << edge_name[e] << " ";
+ cout << "in edges: ";
+ for(GW::InEdgeIt e(gw, n); e!=INVALID; ++e)
+ cout << edge_name[e] << " ";
+ cout << endl;
+ }
+// for(GW::EdgeIt e=gw.first<GW::EdgeIt>(); gw.valid(e); gw.next(e)) {
+// cout << edge_name.get(e) << " ";
// }
-// // for(GW::EdgeIt e=gw.first<GW::EdgeIt>(); gw.valid(e); gw.next(e)) {
-// // cout << edge_name.get(e) << " ";
-// // }
-// // cout << endl;
+// cout << endl;
-// cout << "bfs from t ..." << endl;
-// BfsIterator< GW, GW::NodeMap<bool> > bfs(gw);
-// bfs.pushAndSetReached(t);
-// while (!bfs.finished()) {
-// //cout << "edge: ";
-// if (gw.valid(GW::OutEdgeIt(bfs))) {
-// cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " <<
-// node_name[gw.aNode(bfs)] <<
-// (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
-// node_name[gw.bNode(bfs)] <<
-// (bfs.isBNodeNewlyReached() ? ": is newly reached." :
-// ": is not newly reached.");
-// } else {
-// cout << "invalid" << /*endl*/", " <<
-// node_name[bfs.aNode()] <<
-// (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
+ cout << "bfs from t ..." << endl;
+ BfsIterator< GW, GW::NodeMap<bool> > bfs(gw);
+ bfs.pushAndSetReached(t);
+ while (!bfs.finished()) {
+ //cout << "edge: ";
+ if (GW::OutEdgeIt(bfs)!=INVALID) {
+ cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " <<
+ node_name[gw.tail(bfs)] <<
+ (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
+ node_name[gw.head(bfs)] <<
+ (bfs.isBNodeNewlyReached() ? ": is newly reached." :
+ ": is not newly reached.");
+ } else {
+ cout << "invalid" << /*endl*/", " <<
+ node_name[bfs.aNode()] <<
+ (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
-// "invalid.";
-// }
-// cout << endl;
-// ++bfs;
-// }
+ "invalid.";
+ }
+ cout << endl;
+ ++bfs;
+ }
-// cout << " /--> -------------> "<< endl;
-// cout << " / /-- v1 <-\\ /---- v3-\\ "<< endl;
-// cout << " / | | / /-> \\ "<< endl;
-// cout << " / | | / | ^ \\ "<< endl;
-// cout << "s | | / | | \\-> t "<< endl;
-// cout << " \\ | | / | | /-> "<< endl;
-// cout << " \\ | --/ / | | / "<< endl;
-// cout << " \\ \\-> v2 <--/ \\-- v4 -/ "<< endl;
-// cout << " \\--> -------------> "<< endl;
+ cout << " /--> -------------> "<< endl;
+ cout << " / /-- v1 <-\\ /---- v3-\\ "<< endl;
+ cout << " / | | / /-> \\ "<< endl;
+ cout << " / | | / | ^ \\ "<< endl;
+ cout << "s | | / | | \\-> t "<< endl;
+ cout << " \\ | | / | | /-> "<< endl;
+ cout << " \\ | --/ / | | / "<< endl;
+ cout << " \\ \\-> v2 <--/ \\-- v4 -/ "<< endl;
+ cout << " \\--> -------------> "<< endl;
-// cout << "dfs from t ..." << endl;
-// DfsIterator< GW, GW::NodeMap<bool> > dfs(gw);
-// dfs.pushAndSetReached(t);
-// while (!dfs.finished()) {
-// ++dfs;
-// //cout << "edge: ";
-// if (gw.valid(GW::OutEdgeIt(dfs))) {
-// cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " <<
-// node_name[gw.aNode(dfs)] <<
-// (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
-// node_name[gw.bNode(dfs)] <<
-// (dfs.isBNodeNewlyReached() ? ": is newly reached." :
-// ": is not newly reached.");
-// } else {
-// cout << "invalid" << /*endl*/", " <<
-// node_name[dfs.aNode()] <<
-// (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
+ cout << "dfs from t ..." << endl;
+ DfsIterator< GW, GW::NodeMap<bool> > dfs(gw);
+ dfs.pushAndSetReached(t);
+ while (!dfs.finished()) {
+ ++dfs;
+ //cout << "edge: ";
+ if (GW::OutEdgeIt(dfs)!=INVALID) {
+ cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " <<
+ node_name[gw.tail(dfs)] <<
+ (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
+ node_name[gw.head(dfs)] <<
+ (dfs.isBNodeNewlyReached() ? ": is newly reached." :
+ ": is not newly reached.");
+ } else {
+ cout << "invalid" << /*endl*/", " <<
+ node_name[dfs.aNode()] <<
+ (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
-// "invalid.";
-// }
-// cout << endl;
-// }
-// }
+ "invalid.";
+ }
+ cout << endl;
+ }
+ }
return 0;
}
More information about the Lemon-commits
mailing list