26 #ifndef MLN_UTIL_ADJACENCY_MATRIX_HH
27 # define MLN_UTIL_ADJACENCY_MATRIX_HH
39 # include <mln/core/image/image2d.hh>
40 # include <mln/util/set.hh>
41 # include <mln/util/ord_pair.hh>
42 # include <mln/trait/value_.hh>
43 # include <mln/metal/converts_to.hh>
44 # include <mln/debug/println.hh>
58 template <
typename V,
typename Q>
68 void add(
const V& e1,
const V& e2);
71 void remove(
const V& e1,
const V& e2);
80 std::ostream&
print_data_(std::ostream& ostr)
const;
99 void add(
const V& e1,
const V& e2);
102 void remove(
const V& e1,
const V& e2);
111 std::ostream&
print_data_(std::ostream& ostr)
const;
135 template <
typename V = def::coord>
137 :
private mlc_converts_to(V,unsigned)::check_t,
165 template <
typename V>
167 operator<<(std::ostream& ostr, const adjacency_matrix<V>& adj);
171 # ifndef MLN_INCLUDE_ONLY
179 template <
typename V,
typename Q>
181 : adj_(nelements, nelements)
186 template <
typename V,
typename Q>
188 adjacency_matrix_impl_selector<V, Q>::add(
const V& e1,
const V& e2)
190 mln_precondition(adj_.is_valid());
191 mln_precondition(e1 < adj_.nrows());
192 mln_precondition(e2 < adj_.nrows());
200 template <
typename V,
typename Q>
202 adjacency_matrix_impl_selector<V, Q>::remove(
const V& e1,
const V& e2)
204 mln_precondition(adj_.is_valid());
205 mln_precondition(e1 < adj_.nrows());
206 mln_precondition(e2 < adj_.nrows());
214 template <
typename V,
typename Q>
216 adjacency_matrix_impl_selector<V, Q>::clear()
218 mln_precondition(adj_.is_valid());
222 template <
typename V,
typename Q>
224 adjacency_matrix_impl_selector<V, Q>::are_adjacent(
const V& e1,
227 mln_precondition(adj_.is_valid());
228 mln_precondition(e1 < adj_.nrows());
229 mln_precondition(e2 < adj_.nrows());
236 template <
typename V,
typename Q>
238 adjacency_matrix_impl_selector<V, Q>::print_data_(std::ostream& ostr)
const
240 mln_precondition(adj_.is_valid());
250 template <
typename V>
251 adjacency_matrix_impl_selector<V, metal::bool_<false> >
252 ::adjacency_matrix_impl_selector(
const V& nelements)
256 nelements_ = nelements;
260 template <
typename V>
262 adjacency_matrix_impl_selector<V, metal::bool_<false> >
263 ::add(
const V& e1,
const V& e2)
265 mln_precondition(
int(e1) <
int(nelements_));
266 mln_precondition(
int(e2) <
int(nelements_));
270 template <
typename V>
272 adjacency_matrix_impl_selector<V, metal::bool_<false> >
273 ::remove(
const V& e1,
const V& e2)
275 mln_precondition(
int(e1) <
int(nelements_));
276 mln_precondition(
int(e2) <
int(nelements_));
281 template <
typename V>
283 adjacency_matrix_impl_selector<V, metal::bool_<false> >::clear()
288 template <
typename V>
290 adjacency_matrix_impl_selector<V, metal::bool_<false> >
291 ::are_adjacent(
const V& e1,
const V& e2)
const
293 mln_precondition(
int(e1) <
int(nelements_));
294 mln_precondition(
int(e2) <
int(nelements_));
298 template <
typename V>
300 adjacency_matrix_impl_selector<V, metal::bool_<false> >::print_data_(std::ostream& ostr)
const
308 template <
typename V>
309 adjacency_matrix<V>::adjacency_matrix()
315 template <
typename V>
322 template <
typename V>
324 operator<<(std::ostream& ostr, const adjacency_matrix<V>& adj)
326 return adj.print_data_(ostr);
330 # endif // ! MLN_UTIL_ADJACENCY_MATRIX_HH
337 #endif // ! MLN_UTIL_ADJACENCY_MATRIX_HH