27 #ifndef MLN_UTIL_EDGE_HH
28 # define MLN_UTIL_EDGE_HH
35 # include <mln/util/graph_ids.hh>
36 # include <mln/util/internal/edge_impl.hh>
37 # include <mln/core/concept/proxy.hh>
38 # include <mln/core/concept/site.hh>
39 # include <mln/core/internal/pseudo_site_base.hh>
46 namespace util {
template<
typename G>
class edge; }
87 explicit edge(
const G& g);
110 const G&
graph()
const;
147 template <
typename G>
149 operator<<(std::ostream& ostr, const edge<G>&
p);
151 template <
typename G>
155 template <
typename G>
157 operator< (const edge<G>& lhs,
const edge<G>&
rhs);
163 namespace if_possible
165 template <
typename G>
183 template <
typename G,
typename E>
187 const G& graph()
const;
196 size_t nmax_nbh_edges()
const;
201 const E& exact_()
const;
204 template <
typename G,
typename E>
209 void change_graph(
const mlc_const(G)& g);
222 # ifndef MLN_INCLUDE_ONLY
227 template <
typename G>
234 template <
typename G>
242 template <
typename G>
244 edge<G>::edge(
const G& g, id_value_t
id)
247 mln_precondition(g_.is_valid() && g.has_e(
id));
250 template <
typename G>
252 edge<G>::edge(
const G& g,
const edge_id_t&
id)
255 mln_precondition(g_.is_valid() && g.has_e(
id));
258 template <
typename G>
266 template <
typename G>
269 edge<G>::update_id(
const edge_id_t&
id)
274 template <
typename G>
281 template <
typename G>
284 edge<G>::graph()
const
289 template <
typename G>
292 edge<G>::change_graph(
const G& g)
297 template <
typename G>
300 edge<G>::is_valid()
const
302 return g_.
is_valid() && id_.is_valid() && g_.has_e(id_);
305 template <
typename G>
308 edge<G>::invalidate()
314 template <
typename G>
317 edge<G>::v_other(
const vertex_id_t& id_v)
const
319 mln_precondition(v1() == id_v || v2() == id_v);
320 return g_.v_other(id_, id_v);
323 template <
typename G>
328 mln_precondition(g_.has_e(id_));
332 template <
typename G>
337 mln_precondition(g_.has_e(id_));
341 template <
typename G>
344 edge<G>::nmax_nbh_edges()
const
346 mln_precondition(g_.has_e(id_));
347 return g_.e_nmax_nbh_edges(id_);
350 template <
typename G>
353 edge<G>::ith_nbh_edge(
unsigned i)
const
355 mln_precondition(g_.has_e(id_));
356 return g_.e_ith_nbh_edge(id_, i);
359 template <
typename G>
362 operator<<(std::ostream& ostr, const edge<G>&
p)
364 return ostr <<
"(" <<
p.v1() <<
"," <<
p.v2() <<
")";
367 template <
typename G>
372 return lhs.id() == rhs.id()
373 && (lhs.graph().is_subgraph_of(rhs.graph())
374 || rhs.graph().is_subgraph_of(lhs.graph()));
377 template <
typename G>
380 operator<(const edge<G>& lhs,
const edge<G>&
rhs)
382 return lhs.id() < rhs.id();
396 template <
typename G,
typename E>
401 return internal::force_exact<const E>(*this);
404 template <
typename G,
typename E>
409 return exact_().get_subject().id();
412 template <
typename G,
typename E>
417 return exact_().get_subject().graph();
420 template <
typename G,
typename E>
425 return exact_().get_subject().v_other(id_v);
428 template <
typename G,
typename E>
433 return exact_().get_subject().v1();
436 template <
typename G,
typename E>
441 return exact_().get_subject().v2();
444 template <
typename G,
typename E>
449 return exact_().get_subject().nmax_nbh_edges();
452 template <
typename G,
typename E>
457 return exact_().get_subject().ith_nbh_edge(i);
465 template <
typename G,
typename E>
470 return exact_().get_subject().update_id(
id);
473 template <
typename G,
typename E>
478 return exact_().get_subject().change_graph(g);
481 template <
typename G,
typename E>
486 return exact_().get_subject().invalidate();
491 # endif // ! MLN_INCLUDE_ONLY
496 #endif // ! MLN_UTIL_EDGE_HH