Check StaticGraphSkeleton, as well.
2 #ifndef HUGO_FOR_EACH_MACROS_H
3 #define HUGO_FOR_EACH_MACROS_H
5 // /// \ingroup gwrappers
7 /// \brief Iteration macros.
9 /// This file contains several macros which make easier writting
10 /// for cycles in HUGO using HUGO iterators.
12 /// \author Marton Makai
16 /// This macro provides a comfortable interface for iterating with HUGO
22 /// h_for_glob(n, g) {
26 /// h_for_glob(e, g) {
30 /// Note that the iterated variables \c n and \c e are global ones.
31 #define h_for_glob(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
34 #define FOR_EACH_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
36 /// This macro provides a comfortable interface for iterating with HUGO
42 /// Graph::OutEdgeIt e;
43 /// h_for_inc_glob(e, g, v) {
46 /// typedef BipartiteGraph<Graph> BGraph;
49 /// BGraph::ClassNodeIt n;
50 /// h_for_inc_glob(BGraph::ClassNodeIt, n, h, h.S_CLASS) {
54 /// Note that iterated variables \c e and \c n are global ones.
55 #define h_for_inc_glob(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
58 #define FOR_EACH_INC_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
61 //#define FOR_EACH_EDGE_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
63 //#define FOR_EACH_NODE_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
65 //#define FOR_EACH_INEDGE_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
67 //#define FOR_EACH_OUTEDGE_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
69 // template<typename It, typename Graph>
70 // It loopFirst(const Graph& g) const {
71 // It e; g.first(e); return e;
74 // template<typename It, typename Graph>
75 // It loopFirst(const Graph& g, const Node& v) const {
76 // It e; g.first(e, v); return e;
79 // template<typename Graph>
80 // typename Graph::NodeIt loopFirstNode(const Graph& g) const {
81 // typename Graph::NodeIt e; g.first(e); return e;
83 // template<typename Graph>
84 // typename Graph::EdgeIt loopFirstEdge(const Graph& g) const {
85 // typename Graph::EdgeIt e; g.first(e); return e;
87 // template<typename Graph>
88 // typename Graph::OutEdgeIt
89 // loopFirstOutEdge(const Graph& g, const Node& n) const {
90 // typename Graph::OutEdgeIt e; g.first(e, n); return e;
92 // template<typename Graph>
93 // typename Graph::InEdgeIt
94 // loopFirstIn Edge(const Graph& g, const Node& n) const {
95 // typename Graph::InEdgeIt e; g.first(e, n); return e;
98 //FIXME ezt hogy a gorcsbe birja levezetni. Csak ugy leveszi a const-ot??
99 template<typename It, typename Graph>
100 It loopFirst(const It&, const Graph& g) {
101 It e; g.first(e); return e;
104 template<typename It, typename Graph, typename Node>
105 It loopFirst(const It&, const Graph& g, const Node& v) {
106 It e; g.first(e, v); return e;
109 // template<typename Graph>
110 // typename Graph::NodeIt loopFirstNode(const Graph& g) const {
111 // typename Graph::NodeIt e; g.first(e); return e;
113 // template<typename Graph>
114 // typename Graph::EdgeIt loopFirstEdge(const Graph& g) const {
115 // typename Graph::EdgeIt e; g.first(e); return e;
117 // template<typename Graph>
118 // typename Graph::OutEdgeIt
119 // loopFirstOutEdge(const Graph& g, const Node& n) const {
120 // typename Graph::OutEdgeIt e; g.first(e, n); return e;
122 // template<typename Graph>
123 // typename Graph::InEdgeIt
124 // loopFirstIn Edge(const Graph& g, const Node& n) const {
125 // typename Graph::InEdgeIt e; g.first(e, n); return e;
128 /// This macro provides a comfortable interface for iterating with HUGO
133 /// h_for(Graph::NodeIt, n, g) {
136 /// h_for(Graph::EdgeIt, e, g) {
140 /// Note that the iterated variables \c n and \c e are local ones.
141 #define h_for(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
144 #define FOR_EACH_LOC(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
146 /// This macro provides a comfortable interface for iterating with HUGO
152 /// h_for_inc(Graph::OutEdgeIt, e, g, v) {
155 /// typedef BipartiteGraph<Graph> BGraph;
158 /// h_for_inc(BGraph::ClassNodeIt, n, h, h.S_CLASS) {
162 /// Note that the iterated variables \c e and \c n are local ones.
163 #define h_for_inc(Ittype, e, g, v) for(Ittype e=loopFirst(Ittype(), (g), (v)); (g).valid(e); (g).next(e))
166 #define FOR_EACH_INC_LOC(Ittype, e, g, v) for(Ittype e=loopFirst(Ittype(), (g), (v)); (g).valid(e); (g).next(e))
168 // #define FOR_EACH_EDGE_LOC(e, g) ezt nem tom hogy kell for((g).first((e)); (g).valid((e)); (g).next((e)))
169 // #define FOR_EACH_NODE_LOC(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
170 // #define FOR_EACH_INEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
171 // #define FOR_EACH_OUTEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
175 #endif //HUGO_FOR_EACH_MACROS_H