123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #ifndef BOOST_GRAPH_ITERATION_MACROS_HPP
- #define BOOST_GRAPH_ITERATION_MACROS_HPP
- #include <utility>
- #define BGL_CAT(x, y) x##y
- #define BGL_RANGE(linenum) BGL_CAT(bgl_range_, linenum)
- #define BGL_FIRST(linenum) (BGL_RANGE(linenum).first)
- #define BGL_LAST(linenum) (BGL_RANGE(linenum).second)
- #define BGL_FORALL_VERTICES_T(VNAME, GNAME, GraphType) \
- for (std::pair< \
- typename boost::graph_traits< GraphType >::vertex_iterator, \
- typename boost::graph_traits< GraphType >::vertex_iterator > \
- BGL_RANGE(__LINE__) \
- = vertices(GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (typename boost::graph_traits< GraphType >::vertex_descriptor \
- VNAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (VNAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_VERTICES(VNAME, GNAME, GraphType) \
- for (std::pair< boost::graph_traits< GraphType >::vertex_iterator, \
- boost::graph_traits< GraphType >::vertex_iterator > \
- BGL_RANGE(__LINE__) \
- = vertices(GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (boost::graph_traits< GraphType >::vertex_descriptor VNAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (VNAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_EDGES_T(ENAME, GNAME, GraphType) \
- for (std::pair< typename boost::graph_traits< GraphType >::edge_iterator, \
- typename boost::graph_traits< GraphType >::edge_iterator > \
- BGL_RANGE(__LINE__) \
- = edges(GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (typename boost::graph_traits< GraphType >::edge_descriptor ENAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (ENAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_EDGES(ENAME, GNAME, GraphType) \
- for (std::pair< boost::graph_traits< GraphType >::edge_iterator, \
- boost::graph_traits< GraphType >::edge_iterator > \
- BGL_RANGE(__LINE__) \
- = edges(GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (boost::graph_traits< GraphType >::edge_descriptor ENAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (ENAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_ADJ_T(UNAME, VNAME, GNAME, GraphType) \
- for (std::pair< \
- typename boost::graph_traits< GraphType >::adjacency_iterator, \
- typename boost::graph_traits< GraphType >::adjacency_iterator > \
- BGL_RANGE(__LINE__) \
- = adjacent_vertices(UNAME, GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (typename boost::graph_traits< GraphType >::vertex_descriptor \
- VNAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (VNAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_ADJ(UNAME, VNAME, GNAME, GraphType) \
- for (std::pair< boost::graph_traits< GraphType >::adjacency_iterator, \
- boost::graph_traits< GraphType >::adjacency_iterator > \
- BGL_RANGE(__LINE__) \
- = adjacent_vertices(UNAME, GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (boost::graph_traits< GraphType >::vertex_descriptor VNAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (VNAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_OUTEDGES_T(UNAME, ENAME, GNAME, GraphType) \
- for (std::pair< \
- typename boost::graph_traits< GraphType >::out_edge_iterator, \
- typename boost::graph_traits< GraphType >::out_edge_iterator > \
- BGL_RANGE(__LINE__) \
- = out_edges(UNAME, GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (typename boost::graph_traits< GraphType >::edge_descriptor ENAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (ENAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_OUTEDGES(UNAME, ENAME, GNAME, GraphType) \
- for (std::pair< boost::graph_traits< GraphType >::out_edge_iterator, \
- boost::graph_traits< GraphType >::out_edge_iterator > \
- BGL_RANGE(__LINE__) \
- = out_edges(UNAME, GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (boost::graph_traits< GraphType >::edge_descriptor ENAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (ENAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_INEDGES_T(UNAME, ENAME, GNAME, GraphType) \
- for (std::pair< \
- typename boost::graph_traits< GraphType >::in_edge_iterator, \
- typename boost::graph_traits< GraphType >::in_edge_iterator > \
- BGL_RANGE(__LINE__) \
- = in_edges(UNAME, GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (typename boost::graph_traits< GraphType >::edge_descriptor ENAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (ENAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #define BGL_FORALL_INEDGES(UNAME, ENAME, GNAME, GraphType) \
- for (std::pair< boost::graph_traits< GraphType >::in_edge_iterator, \
- boost::graph_traits< GraphType >::in_edge_iterator > \
- BGL_RANGE(__LINE__) \
- = in_edges(UNAME, GNAME); \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); \
- BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
- for (boost::graph_traits< GraphType >::edge_descriptor ENAME; \
- BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) \
- ? (ENAME = *BGL_FIRST(__LINE__), true) \
- : false; \
- ++BGL_FIRST(__LINE__))
- #endif
|