42 #ifndef VIGRA_GRAPH_HXX
43 #define VIGRA_GRAPH_HXX
45 #include "metaprogramming.hxx"
46 #include "tinyvector.hxx"
48 #ifdef WITH_BOOST_GRAPH
50 # include <boost/tuple/tuple.hpp>
51 # include <boost/graph/graph_traits.hpp>
52 # include <boost/graph/properties.hpp>
54 #else // not WITH_BOOST_GRAPH
59 struct no_property {};
63 struct directed_tag { };
64 struct undirected_tag { };
65 struct bidirectional_tag :
public directed_tag { };
68 struct incidence_graph_tag { };
69 struct adjacency_graph_tag { };
70 struct bidirectional_graph_tag :
public incidence_graph_tag { };
71 struct vertex_list_graph_tag { };
72 struct edge_list_graph_tag { };
73 struct adjacency_matrix_tag { };
76 struct allow_parallel_edge_tag { };
77 struct disallow_parallel_edge_tag { };
80 struct readable_property_map_tag { };
81 struct writable_property_map_tag { };
82 struct read_write_property_map_tag
83 :
public readable_property_map_tag,
84 public writable_property_map_tag {};
85 struct lvalue_property_map_tag
86 :
public read_write_property_map_tag {};
88 struct vertex_index_t {};
90 struct edge_property_tag {};
92 #ifndef BOOST_TUPLE_HPP
96 template<
class T1,
class T2>
100 tie_adapter(T1 &x, T2 &y)
104 template<
class X,
class Y>
105 tie_adapter & operator=(
const std::pair<X, Y> &pair)
117 template<
class T1,
class T2>
122 return tie_adapter<T1, T2>(t1, t2);
127 template <
typename G>
128 struct graph_traits {
129 typedef typename G::vertex_descriptor vertex_descriptor;
130 typedef typename G::edge_descriptor edge_descriptor;
131 typedef typename G::adjacency_iterator adjacency_iterator;
132 typedef typename G::out_edge_iterator out_edge_iterator;
133 typedef typename G::in_edge_iterator in_edge_iterator;
134 typedef typename G::vertex_iterator vertex_iterator;
135 typedef typename G::edge_iterator edge_iterator;
137 typedef typename G::directed_category directed_category;
138 typedef typename G::edge_parallel_category edge_parallel_category;
139 typedef typename G::traversal_category traversal_category;
141 typedef typename G::vertices_size_type vertices_size_type;
142 typedef typename G::edges_size_type edges_size_type;
143 typedef typename G::degree_size_type degree_size_type;
145 static inline vertex_descriptor null_vertex()
147 return vertex_descriptor(-1);
152 template <
typename PropMap>
153 struct property_traits
155 typedef typename PropMap::key_type key_type;
156 typedef typename PropMap::value_type value_type;
157 typedef typename PropMap::reference reference;
158 typedef typename PropMap::category category;
163 vertex_index_t vertex_index;
169 #endif // WITH_BOOST_GRAPH
172 namespace boost_graph {
175 using namespace boost;
183 namespace vigragraph {
187 template <
class ValueType,
class ReadablePropertyMap>
188 struct get_helper { };
190 template <
class PropertyMap,
class ValueType,
class K>
192 get(
const get_helper<ValueType, PropertyMap>& pa,
const K& k)
194 const ValueType v =
static_cast<const PropertyMap&
>(pa)[k];
205 template<
class GRAPH>
207 std::pair<typename graph_traits<GRAPH>::adjacency_iterator,
208 typename graph_traits<GRAPH>::adjacency_iterator >
209 adjacent_vertices_at_iterator(
typename graph_traits<GRAPH>::vertex_iterator
const &v,
214 std::cout <<
"FB" << std::endl;
222 # include <lemon/core.h>
223 #else // not WITH_LEMON
230 bool operator==(Invalid)
const {
return true; }
231 bool operator!=(Invalid)
const {
return false; }
232 bool operator< (Invalid)
const {
return false; }
234 template <
class T,
int N>
241 static const Invalid INVALID = Invalid();
243 typedef vigra::VigraTrueType True;
244 typedef vigra::VigraFalseType False;
255 return t == T(Invalid());
261 return t == T(Invalid());
267 return t != T(Invalid());
273 return t != T(Invalid());
279 namespace lemon_graph {
282 using namespace lemon;
286 #endif // VIGRA_GRAPH_HXX