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; }
69 class edge :
public internal::edge_impl_<G>
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>
168 std::cout <<
"YES: specialization change_target(edge, graph)" << std::endl;
181 template <
typename G,
typename E>
182 struct subject_impl< const util::
edge<G>, E >
184 util::edge_id_t id()
const;
185 const G& graph()
const;
194 size_t nmax_nbh_edges()
const;
195 util::edge_id_t ith_nbh_edge(
unsigned i)
const;
199 const E& exact_()
const;
202 template <
typename G,
typename E>
203 struct subject_impl< util::
edge<G>, E > :
204 subject_impl< const util::edge<G>, E >
206 void update_id(
const util::edge_id_t&
id);
207 void change_graph(
const mlc_const(G)& g);
220 # ifndef MLN_INCLUDE_ONLY
225 template <
typename G>
232 template <
typename G>
240 template <
typename G>
245 mln_precondition(g_.is_valid() && g.has_e(
id));
248 template <
typename G>
253 mln_precondition(g_.is_valid() && g.has_e(
id));
256 template <
typename G>
264 template <
typename G>
272 template <
typename G>
279 template <
typename G>
287 template <
typename G>
295 template <
typename G>
300 return g_.is_valid() && id_.is_valid() && g_.has_e(id_);
303 template <
typename G>
312 template <
typename G>
317 mln_precondition(v1() == id_v || v2() == id_v);
318 return g_.v_other(id_, id_v);
321 template <
typename G>
326 mln_precondition(g_.has_e(id_));
330 template <
typename G>
335 mln_precondition(g_.has_e(id_));
339 template <
typename G>
344 mln_precondition(g_.has_e(id_));
345 return g_.e_nmax_nbh_edges(id_);
348 template <
typename G>
353 mln_precondition(g_.has_e(id_));
354 return g_.e_ith_nbh_edge(id_, i);
357 template <
typename G>
360 operator<<(std::ostream& ostr, const edge<G>& p)
362 return ostr <<
"(" << p.v1() <<
"," << p.v2() <<
")";
365 template <
typename G>
368 operator==(
const edge<G>& lhs,
const edge<G>& rhs)
370 return lhs.id() == rhs.id()
371 && (lhs.graph().is_subgraph_of(rhs.graph())
372 || rhs.graph().is_subgraph_of(lhs.graph()));
375 template <
typename G>
378 operator<(const edge<G>& lhs,
const edge<G>& rhs)
380 return lhs.id() < rhs.id();
394 template <
typename G,
typename E>
397 subject_impl< const util::edge<G>, E >::exact_()
const
399 return internal::force_exact<const E>(*this);
402 template <
typename G,
typename E>
405 subject_impl< const util::edge<G>, E >::id()
const
407 return exact_().get_subject().id();
410 template <
typename G,
typename E>
413 subject_impl< const util::edge<G>, E >::graph()
const
415 return exact_().get_subject().graph();
418 template <
typename G,
typename E>
421 subject_impl< const util::edge<G>, E >::v_other(
const util::vertex_id_t& id_v)
const
423 return exact_().get_subject().v_other(id_v);
426 template <
typename G,
typename E>
429 subject_impl< const util::edge<G>, E >::v1()
const
431 return exact_().get_subject().v1();
434 template <
typename G,
typename E>
437 subject_impl< const util::edge<G>, E >::v2()
const
439 return exact_().get_subject().v2();
442 template <
typename G,
typename E>
445 subject_impl< const util::edge<G>, E >::nmax_nbh_edges()
const
447 return exact_().get_subject().nmax_nbh_edges();
450 template <
typename G,
typename E>
453 subject_impl< const util::edge<G>, E >::ith_nbh_edge(
unsigned i)
const
455 return exact_().get_subject().ith_nbh_edge(i);
463 template <
typename G,
typename E>
466 subject_impl< util::edge<G>, E >::update_id(
const util::edge_id_t&
id)
468 return exact_().get_subject().update_id(
id);
471 template <
typename G,
typename E>
474 subject_impl< util::edge<G>, E >::change_graph(
const mlc_const(G)& g)
476 return exact_().get_subject().change_graph(g);
479 template <
typename G,
typename E>
482 subject_impl< util::edge<G>, E >::invalidate()
484 return exact_().get_subject().invalidate();
489 # endif // ! MLN_INCLUDE_ONLY
494 #endif // ! MLN_UTIL_EDGE_HH