Commit d53b4271 authored by Roland Levillain's avatar Roland Levillain
Browse files

Miscellaneous changes in graphs and graph-based images.

	* mln/util/graph.hh,
	* mln/util/line_graph.hh,
	* mln/core/image/vertex_image.hh,
	* mln/core/image/edge_image.hh:
	Fix the Doxygen documentation.
	* mln/util/vertex.hh: Aesthetic changes.
	* mln/util/edge.hh: Aesthetic changes.
	(util::edge<G>::invalidate): Remove dead code.
	* tests/morpho/line_graph_image_morpho.cc:
	Fix (non) Doxygen comments.
parent 17734ea5
2010-05-11 Roland Levillain <roland@lrde.epita.fr>
Miscellaneous changes in graphs and graph-based images.
* mln/util/graph.hh,
* mln/util/line_graph.hh,
* mln/core/image/vertex_image.hh,
* mln/core/image/edge_image.hh:
Fix the Doxygen documentation.
* mln/util/vertex.hh: Aesthetic changes.
* mln/util/edge.hh: Aesthetic changes.
(util::edge<G>::invalidate): Remove dead code.
* tests/morpho/line_graph_image_morpho.cc:
Fix (non) Doxygen comments.
2010-05-11 Roland Levillain <roland@lrde.epita.fr> 2010-05-11 Roland Levillain <roland@lrde.epita.fr>
   
Fix make::edge_image. Fix make::edge_image.
...@@ -160,7 +160,7 @@ namespace mln ...@@ -160,7 +160,7 @@ namespace mln
/// Constructors. /// Constructors.
/// @{ /// \{
edge_image(); edge_image();
edge_image(const p_edges<G, site_function_t>& pe); edge_image(const p_edges<G, site_function_t>& pe);
edge_image(const Graph<G>& g, edge_image(const Graph<G>& g,
...@@ -178,13 +178,13 @@ namespace mln ...@@ -178,13 +178,13 @@ namespace mln
template <typename FV> template <typename FV>
edge_image(const p_edges<G,site_function_t>& pe, edge_image(const p_edges<G,site_function_t>& pe,
const Function_v2v<FV>& edge_values); const Function_v2v<FV>& edge_values);
/// @} /// \}
/// Value accessors/operators overloads. /// Value accessors/operators overloads.
/// @{ /// \{
rvalue operator()(unsigned e_id) const; rvalue operator()(unsigned e_id) const;
lvalue operator()(unsigned e_id); lvalue operator()(unsigned e_id);
/// @} /// \}
// Just to help g++-2.95... // Just to help g++-2.95...
rvalue operator()(const psite& p) const; rvalue operator()(const psite& p) const;
......
...@@ -167,7 +167,7 @@ namespace mln ...@@ -167,7 +167,7 @@ namespace mln
/// Constructors. /// Constructors.
/// @{ /// \{
vertex_image(); vertex_image();
vertex_image(const p_vertices<G, site_function_t>& pv); vertex_image(const p_vertices<G, site_function_t>& pv);
vertex_image(const p_vertices<G, site_function_t>& pv, vertex_image(const p_vertices<G, site_function_t>& pv,
...@@ -175,13 +175,13 @@ namespace mln ...@@ -175,13 +175,13 @@ namespace mln
template <typename FV> template <typename FV>
vertex_image(const p_vertices<G, site_function_t>& pv, vertex_image(const p_vertices<G, site_function_t>& pv,
const Function_v2v<FV>& vertex_values); const Function_v2v<FV>& vertex_values);
/// @} /// \}
/// Value accessors/operators overloads. /// Value accessors/operators overloads.
/// @{ /// \{
rvalue operator()(unsigned v_id) const; rvalue operator()(unsigned v_id) const;
lvalue operator()(unsigned v_id); lvalue operator()(unsigned v_id);
/// @} /// \}
// Just to help g++-2.95... // Just to help g++-2.95...
......
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) // Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
// //
// This file is part of Olena. // This file is part of Olena.
// //
...@@ -174,7 +175,7 @@ namespace mln ...@@ -174,7 +175,7 @@ namespace mln
namespace internal namespace internal
{ {
/// subject_impl specialization (Proxy) /// subject_impl specialization (Proxy).
/// \{ /// \{
template <typename G, typename E> template <typename G, typename E>
...@@ -199,7 +200,7 @@ namespace mln ...@@ -199,7 +200,7 @@ namespace mln
}; };
template <typename G, typename E> template <typename G, typename E>
struct subject_impl< util::edge<G>, E > : struct subject_impl< util::edge<G>, E > :
subject_impl< const util::edge<G>, E > subject_impl< const util::edge<G>, E >
{ {
void update_id(const util::edge_id_t& id); void update_id(const util::edge_id_t& id);
...@@ -218,10 +219,6 @@ namespace mln ...@@ -218,10 +219,6 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY # ifndef MLN_INCLUDE_ONLY
/*---------------------.
| Operators on edges. |
`---------------------*/
namespace util namespace util
{ {
...@@ -308,7 +305,6 @@ namespace mln ...@@ -308,7 +305,6 @@ namespace mln
void void
edge<G>::invalidate() edge<G>::invalidate()
{ {
//id_ = mln_max(unsigned);
id_.invalidate(); id_.invalidate();
} }
...@@ -391,9 +387,9 @@ namespace mln ...@@ -391,9 +387,9 @@ namespace mln
namespace internal namespace internal
{ {
/*----------------------------------` /*-----------------------------------------.
| subject_impl< const util::edge<G> | | subject_impl< const util::edge<G>, E >. |
\----------------------------------*/ `-----------------------------------------*/
template <typename G, typename E> template <typename G, typename E>
inline inline
...@@ -460,14 +456,14 @@ namespace mln ...@@ -460,14 +456,14 @@ namespace mln
} }
/*----------------------------------` /*-----------------------------------.
| subject_impl< util::edge<G> | | subject_impl< util::edge<G>, E >. |
\----------------------------------*/ `-----------------------------------*/
template <typename G, typename E> template <typename G, typename E>
inline inline
void void
subject_impl< util::edge<G>, E >::update_id(const util::edge_id_t& id) subject_impl< util::edge<G>, E >::update_id(const util::edge_id_t& id)
{ {
return exact_().get_subject().update_id(id); return exact_().get_subject().update_id(id);
} }
...@@ -475,7 +471,7 @@ namespace mln ...@@ -475,7 +471,7 @@ namespace mln
template <typename G, typename E> template <typename G, typename E>
inline inline
void void
subject_impl< util::edge<G>, E >::change_graph(const mlc_const(G)& g) subject_impl< util::edge<G>, E >::change_graph(const mlc_const(G)& g)
{ {
return exact_().get_subject().change_graph(g); return exact_().get_subject().change_graph(g);
} }
...@@ -483,7 +479,7 @@ namespace mln ...@@ -483,7 +479,7 @@ namespace mln
template <typename G, typename E> template <typename G, typename E>
inline inline
void void
subject_impl< util::edge<G>, E >::invalidate() subject_impl< util::edge<G>, E >::invalidate()
{ {
return exact_().get_subject().invalidate(); return exact_().get_subject().invalidate();
} }
......
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) // Copyright (C) 2007, 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
// //
// This file is part of Olena. // This file is part of Olena.
// //
...@@ -47,7 +48,7 @@ namespace mln ...@@ -47,7 +48,7 @@ namespace mln
namespace internal namespace internal
{ {
/// Data structure for \c mln::image2d<T>. /// Data structure for mln::util::graph.
template <> template <>
struct data<util::graph> struct data<util::graph>
{ {
...@@ -165,9 +166,11 @@ namespace mln ...@@ -165,9 +166,11 @@ namespace mln
/// \} /// \}
/// Return the number of vertices in the graph. /// Return the number of vertices in the graph.
// FIXME: Rename as nvertices.
size_t v_nmax() const; size_t v_nmax() const;
/// Check whether a vertex id \p id_v exists in the graph. /// Check whether a vertex id \p id_v exists in the graph.
// FIXME: Is the `_v' suffix really needed?
bool has_v(const vertex_id_t& id_v) const; bool has_v(const vertex_id_t& id_v) const;
...@@ -205,12 +208,12 @@ namespace mln ...@@ -205,12 +208,12 @@ namespace mln
const std::vector<util::ord_pair<vertex_id_t> >& edges() const; const std::vector<util::ord_pair<vertex_id_t> >& edges() const;
/// Return the number of edges in the graph. /// Return the number of edges in the graph.
// FIXME: Rename as nedges.
size_t e_nmax() const; size_t e_nmax() const;
/// Return whether \p id_e is in the graph. /// Return whether \p id_e is in the graph.
/// \@{ // FIXME: Is the `_e' suffix really needed?
bool has_e(const edge_id_t& id_e) const; bool has_e(const edge_id_t& id_e) const;
/// \@}
/// Return the corresponding edge id if exists. If it is not, returns /// Return the corresponding edge id if exists. If it is not, returns
/// an invalid edge. /// an invalid edge.
...@@ -287,9 +290,9 @@ namespace mln ...@@ -287,9 +290,9 @@ namespace mln
this->data_ = new mln::internal::data<util::graph>(nvertices); this->data_ = new mln::internal::data<util::graph>(nvertices);
} }
/*---------------. /*--------------------------.
| Vertex related | | Vertex-related services. |
`---------------*/ `--------------------------*/
inline inline
unsigned unsigned
...@@ -374,9 +377,9 @@ namespace mln ...@@ -374,9 +377,9 @@ namespace mln
} }
/*--------------. /*-------------------------.
| Edges related | | Edges-related services. |
`---------------*/ `-------------------------*/
inline inline
edge_id_t edge_id_t
...@@ -388,6 +391,8 @@ namespace mln ...@@ -388,6 +391,8 @@ namespace mln
// Does this edge already exist in the graph? // Does this edge already exist in the graph?
edge_data_t edge(id_v1, id_v2); edge_data_t edge(id_v1, id_v2);
/* FIXME: This is not sound: the behavior of the algorithm
changes when NDEBUG is defined. */
# ifndef NDEBUG # ifndef NDEBUG
if (data_->edges_set_.find(edge) != data_->edges_set_.end ()) if (data_->edges_set_.find(edge) != data_->edges_set_.end ())
{ {
......
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) // Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// Laboratory (LRDE)
// //
// This file is part of Olena. // This file is part of Olena.
// //
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
/// \file /// \file
/// ///
/// Definitions of undirected graphs. /// Definition of an (undirected) line graph (adaptor).
# include <mln/util/internal/graph_base.hh> # include <mln/util/internal/graph_base.hh>
# include <mln/util/internal/graph_iter.hh> # include <mln/util/internal/graph_iter.hh>
...@@ -49,7 +50,7 @@ namespace mln ...@@ -49,7 +50,7 @@ namespace mln
namespace internal namespace internal
{ {
/// Data structure for \c mln::image2d<T>. /// Data structure for mln::util::line_graph<G>.
template <typename G> template <typename G>
struct data< util::line_graph<G> > struct data< util::line_graph<G> >
{ {
...@@ -157,11 +158,14 @@ namespace mln ...@@ -157,11 +158,14 @@ namespace mln
/// \} /// \}
/// Return the number of vertices in the graph. /// Return the number of vertices in the graph.
// FIXME: Rename as nvertices.
size_t v_nmax() const; size_t v_nmax() const;
/// Check whether a vertex id \p id_v exists in the graph. /// Check whether a vertex id \p id_v exists in the line graph.
// FIXME: Is the `_v' suffix really needed?
bool has_v(const vertex_id_t& id_v) const; bool has_v(const vertex_id_t& id_v) const;
/// Check whether an edge \p v exists in the graph.
/// Check whether a vertex \p v exists in the line graph.
template <typename G2> template <typename G2>
bool has(const util::vertex<G2>& v) const; bool has(const util::vertex<G2>& v) const;
...@@ -188,12 +192,14 @@ namespace mln ...@@ -188,12 +192,14 @@ namespace mln
edge_t edge(const edge_id_t& e) const; edge_t edge(const edge_id_t& e) const;
/// Return the number of edges in the graph. /// Return the number of edges in the graph.
// FIXME: Rename as nedges.
size_t e_nmax() const; size_t e_nmax() const;
/// Return whether \p id_e is in the graph. /// Return whether \p id_e is in the line graph.
// FIXME: Is the `_e' suffix really needed?
bool has_e(const util::edge_id_t& id_e) const; bool has_e(const util::edge_id_t& id_e) const;
/// Return whether \p e is in the graph. /// Return whether \p e is in the line graph.
template <typename G2> template <typename G2>
bool has(const util::edge<G2>& e) const; bool has(const util::edge<G2>& e) const;
......
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory // Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// (LRDE) // Laboratory (LRDE)
// //
// This file is part of Olena. // This file is part of Olena.
// //
...@@ -165,8 +165,8 @@ namespace mln ...@@ -165,8 +165,8 @@ namespace mln
namespace internal namespace internal
{ {
/// subject_impl specialization (Proxy).
/// \{ /// \{
/// subject_impl specialization (Proxy)
template <typename G, typename E> template <typename G, typename E>
struct subject_impl< const util::vertex<G>, E > struct subject_impl< const util::vertex<G>, E >
...@@ -174,6 +174,8 @@ namespace mln ...@@ -174,6 +174,8 @@ namespace mln
// Can't be provided since there is an ambiguity with the iterator's // Can't be provided since there is an ambiguity with the iterator's
// member. // member.
// //
// FIXME: Check the above statement again, as a naive test does
// not exhibit its conclusion.
// bool is_valid() const; // bool is_valid() const;
const G& graph() const; const G& graph() const;
...@@ -191,7 +193,7 @@ namespace mln ...@@ -191,7 +193,7 @@ namespace mln
}; };
template <typename G, typename E> template <typename G, typename E>
struct subject_impl< util::vertex<G>, E > : struct subject_impl< util::vertex<G>, E > :
subject_impl< const util::vertex<G>, E > subject_impl< const util::vertex<G>, E >
{ {
void invalidate(); void invalidate();
...@@ -396,6 +398,10 @@ namespace mln ...@@ -396,6 +398,10 @@ namespace mln
namespace internal namespace internal
{ {
/*-------------------------------------------.
| subject_impl< const util::vertex<G>, E >. |
`-------------------------------------------*/
template <typename G, typename E> template <typename G, typename E>
inline inline
const E& const E&
...@@ -471,10 +477,14 @@ namespace mln ...@@ -471,10 +477,14 @@ namespace mln
} }
/*-------------------------------------.
| subject_impl< util::vertex<G>, E >. |
`-------------------------------------*/
template <typename G, typename E> template <typename G, typename E>
inline inline
E& E&
subject_impl< util::vertex<G>, E >::exact_() subject_impl< util::vertex<G>, E >::exact_()
{ {
return internal::force_exact<E>(*this); return internal::force_exact<E>(*this);
} }
...@@ -482,7 +492,7 @@ namespace mln ...@@ -482,7 +492,7 @@ namespace mln
template <typename G, typename E> template <typename G, typename E>
inline inline
void void
subject_impl< util::vertex<G>, E >::invalidate() subject_impl< util::vertex<G>, E >::invalidate()
{ {
exact_().get_subject().invalidate(); exact_().get_subject().invalidate();
} }
...@@ -490,7 +500,7 @@ namespace mln ...@@ -490,7 +500,7 @@ namespace mln
template <typename G, typename E> template <typename G, typename E>
inline inline
void void
subject_impl< util::vertex<G>, E >::change_graph(const G& g) subject_impl< util::vertex<G>, E >::change_graph(const G& g)
{ {
exact_().get_subject().change_graph(g); exact_().get_subject().change_graph(g);
} }
...@@ -498,7 +508,7 @@ namespace mln ...@@ -498,7 +508,7 @@ namespace mln
template <typename G, typename E> template <typename G, typename E>
inline inline
void void
subject_impl< util::vertex<G>, E >::update_id(const util::vertex_id_t& id) subject_impl< util::vertex<G>, E >::update_id(const util::vertex_id_t& id)
{ {
exact_().get_subject().update_id(id); exact_().get_subject().update_id(id);
}; };
......
...@@ -77,8 +77,8 @@ int main() ...@@ -77,8 +77,8 @@ int main()
g.add_edge(3, 4); g.add_edge(3, 4);
g.add_edge(4, 2); g.add_edge(4, 2);
/// Create the corresponding line graph. // Create the corresponding line graph.
/// Edges are now considered as vertices. // Edges are now considered as vertices.
util::line_graph<util::graph> lg(g); util::line_graph<util::graph> lg(g);
// Points associated to the line graph vertices (edges in the graph). // Points associated to the line graph vertices (edges in the graph).
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment