27 #ifndef MLN_UTIL_VERTEX_HH
28 # define MLN_UTIL_VERTEX_HH
31 # include <mln/util/graph_ids.hh>
32 # include <mln/util/internal/vertex_impl.hh>
33 # include <mln/core/concept/proxy.hh>
34 # include <mln/core/concept/site.hh>
35 # include <mln/util/graph_ids.hh>
36 # include <mln/util/edge.hh>
48 namespace util {
template<
typename G>
class vertex; }
49 namespace util {
template<
typename G>
class edge; }
72 :
public Site< vertex<G> >,
73 public internal::vertex_impl_<G>
91 explicit vertex(
const G& g);
128 const G&
graph()
const;
144 template <
typename G>
146 operator<<(std::ostream& ostr, const vertex<G>& v);
158 operator<(const vertex<G>& lhs,
const vertex<G>& rhs);
171 template <
typename G,
typename E>
172 struct subject_impl< const util::vertex<G>, E >
181 const G& graph()
const;
186 unsigned nmax_nbh_edges()
const;
188 unsigned nmax_nbh_vertices()
const;
192 const E& exact_()
const;
195 template <
typename G,
typename E>
196 struct subject_impl< util::vertex<G>, E > :
197 subject_impl< const util::vertex<G>, E >
200 void change_graph(
const G& g);
216 # ifndef MLN_INCLUDE_ONLY
224 template <
typename G>
231 template <
typename G>
260 return id_ != mln_max(
unsigned) && g_.is_valid() && g_.has_v(id_);
268 id_ = mln_max(
unsigned);
276 mln_precondition(g_.has_v(id_));
277 mln_precondition(g_.has_e(id_e));
278 mln_precondition(g_.v1(id_e) == id_ || g_.v2(id_e) == id_);
279 return g_.v_other(id_e, id_);
287 mln_precondition(g_.has_v(id_));
288 return g_.v_ith_nbh_edge(id_, i);
296 mln_precondition(g_.has_v(id_));
297 return g_.v_nmax_nbh_edges(id_);
305 mln_precondition(g_.has_v(id_));
306 return g_.v_ith_nbh_vertex(id_, i);
314 mln_precondition(g_.has_v(id_));
315 return g_.v_nmax_nbh_vertices(id_);
323 mln_precondition(g_.has_v(id_));
324 mln_precondition(g_.has_v(v));
325 return g_.edge(*
this, v);
333 mln_precondition(g.is_valid());
369 template <
typename G>
372 operator<<(std::ostream& ostr, const vertex<G>& v)
374 return ostr << v.id();
382 return v1.
id() == v2.
id()
392 return lhs.id() < rhs.id();
405 template <
typename G,
typename E>
408 subject_impl< const util::vertex<G>, E >::exact_()
const
410 return internal::force_exact<const E>(*this);
413 template <
typename G,
typename E>
416 subject_impl< const util::vertex<G>, E >::graph()
const
418 return exact_().get_subject().graph();
421 template <
typename G,
typename E>
424 subject_impl< const util::vertex<G>, E >::id()
const
426 return exact_().get_subject().id();
431 template <
typename G,
typename E>
434 subject_impl< const util::vertex<G>, E >::other(
const util::edge_id_t& id_e)
const
436 return exact_().get_subject().other(id_e);
439 template <
typename G,
typename E>
442 subject_impl< const util::vertex<G>, E >::ith_nbh_edge(
unsigned i)
const
444 return exact_().get_subject().ith_nbh_edge(i);
447 template <
typename G,
typename E>
450 subject_impl< const util::vertex<G>, E >::nmax_nbh_edges()
const
452 return exact_().get_subject().nmax_nbh_edges();
455 template <
typename G,
typename E>
458 subject_impl< const util::vertex<G>, E >::ith_nbh_vertex(
unsigned i)
const
460 return exact_().get_subject().ith_nbh_vertex(i);
463 template <
typename G,
typename E>
466 subject_impl< const util::vertex<G>, E >::nmax_nbh_vertices()
const
468 return exact_().get_subject().nmax_nbh_vertices();
471 template <
typename G,
typename E>
474 subject_impl< const util::vertex<G>, E >::edge_with(
const util::vertex<G>& v)
const
476 return exact_().get_subject().edge_with(v);
484 template <
typename G,
typename E>
487 subject_impl< util::vertex<G>, E >::exact_()
489 return internal::force_exact<E>(*this);
492 template <
typename G,
typename E>
495 subject_impl< util::vertex<G>, E >::invalidate()
497 exact_().get_subject().invalidate();
500 template <
typename G,
typename E>
503 subject_impl< util::vertex<G>, E >::change_graph(
const G& g)
505 exact_().get_subject().change_graph(g);
508 template <
typename G,
typename E>
513 exact_().get_subject().update_id(
id);
520 # endif // ! MLN_INCLUDE_ONLY
523 #endif // ! MLN_UTIL_VERTEX_HH