Dox readable more even.
3 #include <smart_graph.h>
7 ///\todo This is only a static map!
14 typedef typename GG::Edge Edge;
17 typedef bool ValueType;
20 friend class FalseIterator;
21 friend class TrueIterator;
25 typename Graph::EdgeMap<int> cref;
26 std::vector<Edge> vals;
27 int sep; //map[e] is true <=> cref[e]>=sep
29 bool isTrue(Edge e) {return cref[e]>=sep;}
30 void swap(Edge e, int s)
35 cref[te]=ti; vals[ti]=te;
38 void setTrue(Edge e) { if(cref[e]<sep) { sep--; swap(e,sep); } }
39 void setFalse(Edge e) { if(cref[e]>=sep) { swap(e,sep); sep++; } }
47 FalseIterator(BoolIterEdgeMap &_M) : M(_M), i(0) { }
48 FalseIterator &operator++() { ++i; return *this;}
49 operator Edge() { return i<M.sep ? M.vals[i] : INVALID; }
50 operator bool() { return i<M.sep; }
57 TrueIterator(BoolIterEdgeMap &_M) : M(_M), i(M.vals.size()-1) { }
58 TrueIterator &operator++() { --i; return *this;}
59 operator Edge() { return i>=M.sep ? M.vals[i] : INVALID; }
60 operator bool() { return i>=M.sep; }
68 RefType(BoolIterEdgeMap &_M,Edge _e) : M(_M), e(_e) { }
70 operator ValueType() const
75 ValueType operator = (ValueType v) const
84 BoolIterEdgeMap(Graph &_G) : G(_G), cref(G)
87 for(typename Graph::EdgeIt e(G);G.valid(e);G.next(e)) {
93 RefType operator[] (Edge e) { return RefType(*this,e);}
98 typedef SmartGraph Graph;
99 typedef Graph::NodeIt NodeIt;
100 typedef Graph::OutEdgeIt OutEdgeIt;
101 typedef Graph::EdgeIt EdgeIt;
105 for(int i=0;i<3;i++) G.addNode();
107 for(NodeIt n(G);G.valid(n);G.next(n))
108 for(NodeIt m(G);G.valid(m);G.next(m)) if(n!=m)
111 //for(OutEdgeIt e(G,NodeIt(G));G.valid(e);G.next(e))
113 BoolIterEdgeMap<Graph> map(G);
117 for(EdgeIt e(G);G.valid(e);G.next(e)) {map[e]=b;b=!b;}
119 std::cout << true << '\n';
121 for(EdgeIt e(G);G.valid(e);G.next(e))
122 std::cout << G.id(G.tail(e)) << "->" << G.id(G.head(e))
123 << ": " << map[e] << '\n';
124 std::cout << "True Edges:\n";
125 for(BoolIterEdgeMap<Graph>::TrueIterator i(map);i;++i)
126 std::cout << G.id(G.tail(i)) << "->" << G.id(G.head(i)) << '\n';
127 std::cout << "False Edges:\n";
128 for(BoolIterEdgeMap<Graph>::FalseIterator i(map);i;++i)
129 std::cout << G.id(G.tail(i)) << "->" << G.id(G.head(i)) << '\n';