Commit 2ccc8ecd authored by Roland Levillain's avatar Roland Levillain
Browse files

Rename graphs' nodes as vertices .

	* mln/util/graph.hh,
	* mln/util/internal/graph_base.hh,
	* mln/accu/count_adjacent_vertices.hh,
	* mln/core/graph_elt_neighborhood.hh,
	* mln/core/graph_elt_window.hh,
	* mln/core/graph_image.hh,
	* mln/core/graph_psite.hh,
	* mln/core/internal/graph_vicinity_piter.hh,
	* mln/core/line_graph_elt_neighborhood.hh,
	* mln/core/line_graph_elt_window.hh,
	* mln/core/line_graph_image.hh,
	* mln/core/line_graph_psite.hh,
	* mln/core/p_graph.hh,
	* mln/core/p_graph_piter.hh,
	* mln/core/p_line_graph.hh,
	* mln/draw/graph.hh,
	* mln/morpho/line_gradient.hh,
	* tests/core/graph_elt_neighborhood.cc,
	* tests/core/graph_elt_window.cc,
	* tests/core/graph_image.cc,
	* tests/core/line_graph_elt_neighborhood.cc,
	* tests/core/line_graph_elt_window.cc,
	* tests/core/line_graph_image.cc,
	* tests/core/line_graph_image_wst.cc,
	* tests/core/point_set_compatibility.cc,
	* tests/morpho/artificial_line_graph_image_wst.cc,
	* tests/morpho/lena_line_graph_image_wst1.cc,
	* tests/morpho/lena_line_graph_image_wst2.cc:
	s/nodes/vertices/.
	s/node/vertex/.
	s/link/edge/.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1993 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent e4ab17b1
2008-06-03 Roland Levillain <roland@lrde.epita.fr>
Rename graphs' nodes as vertices .
* mln/util/graph.hh,
* mln/util/internal/graph_base.hh,
* mln/accu/count_adjacent_vertices.hh,
* mln/core/graph_elt_neighborhood.hh,
* mln/core/graph_elt_window.hh,
* mln/core/graph_image.hh,
* mln/core/graph_psite.hh,
* mln/core/internal/graph_vicinity_piter.hh,
* mln/core/line_graph_elt_neighborhood.hh,
* mln/core/line_graph_elt_window.hh,
* mln/core/line_graph_image.hh,
* mln/core/line_graph_psite.hh,
* mln/core/p_graph.hh,
* mln/core/p_graph_piter.hh,
* mln/core/p_line_graph.hh,
* mln/draw/graph.hh,
* mln/morpho/line_gradient.hh,
* tests/core/graph_elt_neighborhood.cc,
* tests/core/graph_elt_window.cc,
* tests/core/graph_image.cc,
* tests/core/line_graph_elt_neighborhood.cc,
* tests/core/line_graph_elt_window.cc,
* tests/core/line_graph_image.cc,
* tests/core/line_graph_image_wst.cc,
* tests/core/point_set_compatibility.cc,
* tests/morpho/artificial_line_graph_image_wst.cc,
* tests/morpho/lena_line_graph_image_wst1.cc,
* tests/morpho/lena_line_graph_image_wst2.cc:
s/nodes/vertices/.
s/node/vertex/.
s/link/edge/.
2008-06-03 Roland Levillain <roland@lrde.epita.fr>
Clean up accumulators related to connected filters.
......
......@@ -82,7 +82,7 @@ namespace mln
/// The value of the counter.
std::size_t count__;
/// The set of adjacent vertices.
std::set<util::node_id> vertices_;
std::set<util::vertex_id> vertices_;
};
......
......@@ -70,9 +70,9 @@ namespace mln
typedef P point;
/// The type of psite corresponding to the neighborhood.
typedef graph_psite<P> psite;
// The type of the set of neighbors (node ids adjacent to the
// The type of the set of neighbors (vertex ids adjacent to the
// reference psite).
typedef std::set<util::node_id> sites_t;
typedef std::set<util::vertex_id> sites_t;
// FIXME: This is a dummy value.
typedef void dpoint;
......@@ -107,26 +107,27 @@ namespace mln
graph_elt_neighborhood<P>::compute_sites_(Point_Iterator<Piter>& piter_) const
{
Piter& piter = exact(piter_);
util::node_id ref_node_id = piter.p_ref().id();
const util::node<P>& ref_node = piter.pg().gr_->node(ref_node_id);
util::vertex_id ref_vertex_id = piter.p_ref().id();
const util::vertex<P>& ref_vertex = piter.pg().gr_->vertex(ref_vertex_id);
sites_t& sites = piter.sites();
sites.clear();
/* FIXME: Move this computation out of the neighborhood. In fact,
this should be a service of the graph, also proposed by the
p_line_graph. */
// Adjacent vertices.
for (std::vector<util::edge_id>::const_iterator e = ref_node.edges.begin();
e != ref_node.edges.end(); ++e)
for (std::vector<util::edge_id>::const_iterator e =
ref_vertex.edges.begin();
e != ref_vertex.edges.end(); ++e)
{
util::node_id n1 = piter.pg().gr_->edges()[*e]->n1();
// We explicitly enforce that the reference piter node id is
util::vertex_id v1 = piter.pg().gr_->edges()[*e]->v1();
// We explicitly enforce that the reference piter vertex id is
// *not* inserted into SITES.
if (n1 != ref_node_id)
sites.insert(n1);
util::node_id n2 = piter.pg().gr_->edges()[*e]->n2();
if (v1 != ref_vertex_id)
sites.insert(v1);
util::vertex_id v2 = piter.pg().gr_->edges()[*e]->v2();
// Likewise.
if (n2 != ref_node_id)
sites.insert(n2);
if (v2 != ref_vertex_id)
sites.insert(v2);
}
}
......
......@@ -69,9 +69,9 @@ namespace mln
typedef P point;
/// The type of psite corresponding to the window.
typedef graph_psite<P> psite;
// The type of the set of window sites (node ids adjacent to the
// The type of the set of window sites (vertex ids adjacent to the
// reference psite).
typedef std::set<util::node_id> sites_t;
typedef std::set<util::vertex_id> sites_t;
// FIXME: This is a dummy value.
typedef void dpoint;
......@@ -109,7 +109,7 @@ namespace mln
/* FIXME: This method returns a dummy value (0), since the delta
of a window on a graph
1. is not constant (graph nodes are not necessarily aligned on
1. is not constant (graph vertices are not necessarily aligned on
a regular grid);
2. depends on the underlying graph, too.
......@@ -132,25 +132,27 @@ namespace mln
graph_elt_window<P>::compute_sites_(Point_Iterator<Piter>& piter_) const
{
Piter& piter = exact(piter_);
util::node_id ref_node_id = piter.p_ref().id();
const util::node<P>& ref_node = piter.pg().gr_->node(ref_node_id);
util::vertex_id ref_vertex_id = piter.p_ref().id();
const util::vertex<P>& ref_vertex = piter.pg().gr_->vertex(ref_vertex_id);
sites_t& sites = piter.sites();
sites.clear();
/* FIXME: Move this computation out of the window. In fact,
this should be a service of the graph, also proposed by the
p_line_graph. */
// Adjacent vertices.
/* We don't need to explicitely insert the reference piter (node
id) itself into SITES, since it is part of the set of nodes
adjacent to NODE1 and NODE2, and will therefore be
/* Adjacent vertices.
We don't need to explicitely insert the reference piter (vertex
id) itself into SITES, since it is part of the set of vertices
adjacent to V1 and V2, and will therefore be
automatically added. */
for (std::vector<util::edge_id>::const_iterator e = ref_node.edges.begin();
e != ref_node.edges.end(); ++e)
for (std::vector<util::edge_id>::const_iterator e =
ref_vertex.edges.begin();
e != ref_vertex.edges.end(); ++e)
{
util::node_id n1 = piter.pg().gr_->edges()[*e]->n1();
sites.insert(n1);
util::node_id n2 = piter.pg().gr_->edges()[*e]->n2();
sites.insert(n2);
util::vertex_id v1 = piter.pg().gr_->edges()[*e]->v1();
sites.insert(v1);
util::vertex_id v2 = piter.pg().gr_->edges()[*e]->v2();
sites.insert(v2);
}
}
......
......@@ -139,19 +139,19 @@ namespace mln
/// Return the domain of values of the image.
const vset& values() const;
/// Return the array of values associated to the nodes.
const std::vector<V>& node_values() const;
/// Return the array of values associated to the vertices.
const std::vector<V>& vertex_values() const;
/// \}
/* FIXME: Do we want to provide these two methods? (at least, in
the interface of the class? */
/// Return the point of the first node adjacent to the edge with
/// Return the point of the first vertex adjacent to the edge with
/// id \a e.
const P& node1(const util::edge_id& e) const;
/// Return the point of the second node adjacent to the edge with
const P& vertex1(const util::edge_id& e) const;
/// Return the point of the second vertex adjacent to the edge with
/// id \a e.
const P& node2(const util::edge_id& e) const;
const P& vertex2(const util::edge_id& e) const;
};
// Fwd decl.
......@@ -172,7 +172,7 @@ namespace mln
graph_image<P, V>& target, const graph_image<P, W>& model)
{
target.init_(model.domain(),
std::vector<V>(model.node_values().size()));
std::vector<V>(model.vertex_values().size()));
}
/*-------.
......@@ -206,7 +206,7 @@ namespace mln
inline
graph_image<P, V>::graph_image(const p_graph<P>& g)
{
init_(g, std::vector<V>(g.nnodes()));
init_(g, std::vector<V>(g.nvertices()));
}
template <typename P, typename V>
......@@ -260,7 +260,7 @@ namespace mln
template <typename P, typename V>
inline
const std::vector<V>&
graph_image<P, V>::node_values() const
graph_image<P, V>::vertex_values() const
{
return this->data_->val_;
}
......@@ -277,17 +277,17 @@ namespace mln
template <typename P, typename V>
inline
const P&
graph_image<P, V>::node1(const util::edge_id& e) const
graph_image<P, V>::vertex1(const util::edge_id& e) const
{
return this->domain().node1(e);
return this->domain().vertex1(e);
}
template <typename P, typename V>
inline
const P&
graph_image<P, V>::node2(const util::edge_id& e) const
graph_image<P, V>::vertex2(const util::edge_id& e) const
{
return this->domain().node2(e);
return this->domain().vertex2(e);
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -74,8 +74,8 @@ namespace mln
/// Return the p_graph this point site belongs to.
const p_graph<P>& pg() const;
/// Return the node id of this point site.
util::node_id id() const;
/// Return the vertex id of this point site.
util::vertex_id id() const;
/// Is this psite valid?
bool is_valid() const;
......@@ -83,8 +83,8 @@ namespace mln
private:
/// The p_graph this point site belongs to.
const p_graph<P>* pg_;
/// The id of the node this psite is pointing towards.
util::node_id id_;
/// The id of the vertex this psite is pointing towards.
util::vertex_id id_;
};
/// Compare two mln::graph_psite<P> instances.
......@@ -109,7 +109,7 @@ namespace mln
template<typename P>
inline
graph_psite<P>::graph_psite(const p_graph<P>& g, util::node_id id)
graph_psite<P>::graph_psite(const p_graph<P>& g, util::vertex_id id)
: super_(),
pg_(&g),
id_(id)
......@@ -142,7 +142,7 @@ namespace mln
bool
graph_psite<P>::is_valid() const
{
return pg_ && id_ < pg_->gr_->nnodes();
return pg_ && id_ < pg_->gr_->nvertices();
}
template<typename P>
......@@ -181,7 +181,7 @@ namespace mln
template<typename P>
inline
util::node_id
util::vertex_id
graph_psite<P>::id() const
{
return id_;
......
......@@ -78,7 +78,7 @@ namespace mln
typedef void mesh;
// The type of the set of vicinity sites (adjacent vertex ids).
typedef std::set<util::node_id> sites_t;
typedef std::set<util::vertex_id> sites_t;
public:
/// Conversion and accessors.
......@@ -111,8 +111,8 @@ namespace mln
/// Internals, used by the vicinity.
/// \{
public:
/// An internal iterator on the set of nodes of the underlying graph.
util::node_id id_;
/// An internal iterator on the set of vertices of the underlying graph.
util::vertex_id id_;
/// \}
protected:
......@@ -198,7 +198,7 @@ namespace mln
template <typename P, typename E>
inline
std::set<util::node_id>&
std::set<util::vertex_id>&
graph_vicinity_piter_<P, E>::sites()
{
return sites_;
......
......@@ -116,20 +116,20 @@ namespace mln
/* FIXME: Move this computation out of the neighborhood. In fact,
this should be a service of the graph, also proposed by the
p_line_graph. */
// Ajacent edges connected through node 1.
util::node_id id1 = piter.p_ref().first_id();
const util::node<P>& node1 = piter.plg().gr_->node(id1);
// Ajacent edges connected through vertex 1.
util::vertex_id id1 = piter.p_ref().first_id();
const util::vertex<P>& vertex1 = piter.plg().gr_->vertex(id1);
for (std::vector<util::edge_id>::const_iterator e =
node1.edges.begin(); e != node1.edges.end(); ++e)
vertex1.edges.begin(); e != vertex1.edges.end(); ++e)
// We explicitly enforce that the reference piter edge id is
// *not* inserted into SITES.
if (*e != ref_edge_id)
sites.insert(*e);
// Ajacent edges connected through node 2.
util::node_id id2 = piter.p_ref().second_id();
const util::node<P>& node2 = piter.plg().gr_->node(id2);
// Ajacent edges connected through vertex 2.
util::vertex_id id2 = piter.p_ref().second_id();
const util::vertex<P>& vertex2 = piter.plg().gr_->vertex(id2);
for (std::vector<util::edge_id>::const_iterator e =
node2.edges.begin(); e != node2.edges.end(); ++e)
vertex2.edges.begin(); e != vertex2.edges.end(); ++e)
// Same remark as above.
if (*e != ref_edge_id)
sites.insert(*e);
......
......@@ -137,21 +137,21 @@ namespace mln
/* FIXME: Move this computation out of the window. In fact,
this should be a service of the graph, also proposed by the
p_line_graph. */
// Ajacent edges connected through node 1.
// Ajacent edges connected through vertex 1.
/* We don't need to explicitely insert the reference piter (edge
id) itself into SITES, since it is part of the set of edges
adjacent to NODE1 and NODE2, and will therefore be
adjacent to VERTEX1 and VERTEX2, and will therefore be
automatically added. */
util::node_id id1 = piter.p_ref().first_id();
const util::node<P>& node1 = piter.plg().gr_->node(id1);
util::vertex_id id1 = piter.p_ref().first_id();
const util::vertex<P>& vertex1 = piter.plg().gr_->vertex(id1);
for (std::vector<util::edge_id>::const_iterator e =
node1.edges.begin(); e != node1.edges.end(); ++e)
vertex1.edges.begin(); e != vertex1.edges.end(); ++e)
sites.insert(*e);
// Ajacent edges connected through node 2.
util::node_id id2 = piter.p_ref().second_id();
const util::node<P>& node2 = piter.plg().gr_->node(id2);
// Ajacent edges connected through vertex 2.
util::vertex_id id2 = piter.p_ref().second_id();
const util::vertex<P>& vertex2 = piter.plg().gr_->vertex(id2);
for (std::vector<util::edge_id>::const_iterator e =
node2.edges.begin(); e != node2.edges.end(); ++e)
vertex2.edges.begin(); e != vertex2.edges.end(); ++e)
sites.insert(*e);
}
......
......@@ -44,14 +44,14 @@
possible. */
/* FIXME: This is only a very naive prototype. For instance, this
image associates values to both the nodes and the edges of the
image associates values to both the vertices and the edges of the
graph, but only values on edges are accessible. We probably want
to fork this class to have a pure image of line graph (with no data
on nodes) and one having data on both nodes and edges.
on vertices) and one having data on both vertices and edges.
Moreover, in the current implementation, the type of values on
nodes and edges is necessarily the same (V). We should allow
different data types for nodes and edges. */
vertices and edges is necessarily the same (V). We should allow
different data types for vertices and edges. */
namespace mln
......@@ -68,9 +68,9 @@ namespace mln
struct data_< line_graph_image<P, V> >
{
data_(const p_line_graph<P>& g,
const std::vector<V>& node_val, const std::vector<V>& edge_val);
const std::vector<V>& vertex_val, const std::vector<V>& edge_val);
std::vector<V> node_val_;
std::vector<V> vertex_val_;
std::vector<V> edge_val_;
const p_line_graph<P> plg_;
};
......@@ -139,13 +139,13 @@ namespace mln
line_graph_image();
line_graph_image(const p_line_graph<P>& g);
line_graph_image(const p_line_graph<P>& g,
const std::vector<V>& node_val,
const std::vector<V>& vertex_val,
const std::vector<V>& edge_val);
/// \}
/// Initialize an empty image.
void init_(const p_line_graph<P>& g,
const std::vector<V>& node_val,
const std::vector<V>& vertex_val,
const std::vector<V>& edge_val);
/// Read-only access of pixel value at point site \p p.
......@@ -163,19 +163,19 @@ namespace mln
/// Return the array of values associated to the edges.
const std::vector<V>& edge_values() const;
/// Return the array of values associated to the nodes.
const std::vector<V>& node_values() const;
/// Return the array of values associated to the vertices.
const std::vector<V>& vertex_values() const;
/// \}
/* FIXME: Do we want to provide these two methods? (at least, in
the interface of the class? */
/// Return the point of the first node adjacent to the edge with
/// Return the point of the first vertex adjacent to the edge with
/// id \a e.
const P& node1(const util::edge_id& e) const;
/// Return the point of the second node adjacent to the edge with
const P& vertex1(const util::edge_id& e) const;
/// Return the point of the second vertex adjacent to the edge with
/// id \a e.
const P& node2(const util::edge_id& e) const;
const P& vertex2(const util::edge_id& e) const;
};
// Fwd decl.
......@@ -198,7 +198,7 @@ namespace mln
const line_graph_image<P, W>& model)
{
target.init_(model.domain(),
std::vector<V>(model.node_values().size()),
std::vector<V>(model.vertex_values().size()),
std::vector<V>(model.edge_values().size()));
}
......@@ -211,9 +211,9 @@ namespace mln
template <typename P, typename V>
inline
data_< line_graph_image<P, V> >::data_(const p_line_graph<P>& g,
const std::vector<V>& node_val,
const std::vector<V>& vertex_val,
const std::vector<V>& edge_val)
: node_val_(node_val),
: vertex_val_(vertex_val),
edge_val_(edge_val),
plg_(g)
{
......@@ -235,28 +235,28 @@ namespace mln
inline
line_graph_image<P, V>::line_graph_image(const p_line_graph<P>& g)
{
init_(g, std::vector<V>(g.nnodes()), std::vector<V>(g.nedges()));
init_(g, std::vector<V>(g.nvertices()), std::vector<V>(g.nedges()));
}
template <typename P, typename V>
inline
line_graph_image<P, V>::line_graph_image(const p_line_graph<P>& g,
const std::vector<V>& node_val,
const std::vector<V>& vertex_val,
const std::vector<V>& edge_val)
{
init_(g, node_val, edge_val);
init_(g, vertex_val, edge_val);
}
template <typename P, typename V>
inline
void
line_graph_image<P, V>::init_(const p_line_graph<P>& g,
const std::vector<V>& node_val,
const std::vector<V>& vertex_val,
const std::vector<V>& edge_val)
{
mln_precondition(! this->has_data());
this->data_ =
new internal::data_< line_graph_image<P, V> >(g, node_val, edge_val);
new internal::data_< line_graph_image<P, V> >(g, vertex_val, edge_val);
}
/*---------------.
......@@ -302,9 +302,9 @@ namespace mln
template <typename P, typename V>
inline
const std::vector<V>&
line_graph_image<P, V>::node_values() const
line_graph_image<P, V>::vertex_values() const
{
return this->data_->node_val_;
return this->data_->vertex_val_;
}
template <typename P, typename V>
......@@ -319,23 +319,23 @@ namespace mln
template <typename P, typename V>
inline
const P&
line_graph_image<P, V>::node1(const util::edge_id& e) const
line_graph_image<P, V>::vertex1(const util::edge_id& e) const
{
// FIXME: Improve the interface of graph to avoid these low-level
// manipulations.
util::node_id n1 = this->domain().gr_.edge(e).n1();
return this->domain().gr_.node_data(n1);
util::vertex_id v1 = this->domain().gr_.edge(e).v1();
return this->domain().gr_.vertex_data(v1);
}
template <typename P, typename V>
inline
const P&
line_graph_image<P, V>::node2(const util::edge_id& e) const
line_graph_image<P, V>::vertex2(const util::edge_id& e) const
{
// FIXME: Improve the interface of graph to avoid these low-level
// manipulations.
util::node_id n2 = this->domain().gr_.edge(e).n2();
return this->domain().gr_.node_data(n2);
util::vertex_id v2 = this->domain().gr_.edge(e).v2();
return this->domain().gr_.vertex_data(v2);
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -86,9 +86,9 @@ namespace mln
P second() const;
/// Return the id of the first associated vertex.
util::node_id first_id() const;
util::vertex_id first_id() const;
/// Return the id of the second associated vertex.
util::node_id second_id() const;
util::vertex_id second_id() const;
/// Is this psite valid?
bool is_valid() const;
......@@ -103,7 +103,7 @@ namespace mln
Contrary to mln::graph_psite, this information is actually
stored in the mln::line_graph_psite. In mln::graph_psite, the
point is retrieved from the data associated with the
corresponding node in the graph. We cannot do this here,
corresponding vertex in the graph. We cannot do this here,
since points associated to edges are computed on the fly
(storing them in the graph could be possible, but too costly
in space). */
......@@ -224,7 +224,7 @@ namespace mln
template<typename P>
inline
util::node_id
util::vertex_id
line_graph_psite<P>::id() const
{
return id_;
......@@ -236,7 +236,7 @@ namespace mln
line_graph_psite<P>::first() const
{
mln_assertion(is_valid());
return plg().gr_->node_data(first_id());
return plg().gr_->vertex_data(first_id());
}
template<typename P>
......@@ -245,26 +245,26 @@ namespace mln
line_graph_psite<P>::second() const
{
mln_assertion(is_valid());
return plg().gr_->node_data(second_id());
return plg().gr_->vertex_data(second_id());
}
template<typename P>
inline
util::node_id
util::vertex_id
line_graph_psite<P>::first_id() const
{
mln_assertion(is_valid());
return plg().gr_->edge(id_).n1();
return plg().gr_->edge(id_).v1();
}