https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)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/.
mln/accu/count_adjacent_vertices.hh | 2
mln/core/graph_elt_neighborhood.hh | 27 +-
mln/core/graph_elt_window.hh | 34 +--
mln/core/graph_image.hh | 26 +-
mln/core/graph_psite.hh | 14 -
mln/core/internal/graph_vicinity_piter.hh | 8
mln/core/line_graph_elt_neighborhood.hh | 16 -
mln/core/line_graph_elt_window.hh | 18 -
mln/core/line_graph_image.hh | 60 ++---
mln/core/line_graph_psite.hh | 20 -
mln/core/p_graph.hh | 72 +++---
mln/core/p_graph_piter.hh | 10
mln/core/p_line_graph.hh | 20 -
mln/draw/graph.hh | 46 ++--
mln/morpho/line_gradient.hh | 14 -
mln/util/graph.hh | 210 +++++++++----------
mln/util/internal/graph_base.hh | 258 +++++++++++-------------
tests/core/graph_elt_neighborhood.cc | 16 -
tests/core/graph_elt_window.cc | 16 -
tests/core/graph_image.cc | 20 -
tests/core/line_graph_elt_neighborhood.cc | 16 -
tests/core/line_graph_elt_window.cc | 16 -
tests/core/line_graph_image.cc | 24 +-
tests/core/line_graph_image_wst.cc | 30 +-
tests/core/point_set_compatibility.cc | 16 -
tests/morpho/artificial_line_graph_image_wst.cc | 4
tests/morpho/lena_line_graph_image_wst1.cc | 22 +-
tests/morpho/lena_line_graph_image_wst2.cc | 4
28 files changed, 519 insertions(+), 520 deletions(-)
Index: tests/core/graph_elt_neighborhood.cc
--- tests/core/graph_elt_neighborhood.cc (revision 1992)
+++ tests/core/graph_elt_neighborhood.cc (working copy)
@@ -62,19 +62,19 @@
*/
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<p_t> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
mln::util::graph<p_t> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
Index: tests/core/point_set_compatibility.cc
--- tests/core/point_set_compatibility.cc (revision 1992)
+++ tests/core/point_set_compatibility.cc (working copy)
@@ -47,19 +47,19 @@
// Graph.
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<point2d> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
util::graph<point2d> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
Index: tests/core/graph_image.cc
--- tests/core/graph_image.cc (revision 1992)
+++ tests/core/graph_image.cc (working copy)
@@ -63,19 +63,19 @@
*/
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<point2d> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
util::graph<point2d> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -122,14 +122,14 @@
itslef.
An alternative is to use draw::graph (which, again, is misnamed),
- but it doesn't show the values, only the nodes and edges of the
+ but it doesn't show the values, only the vertices and edges of the
graph.
The current solution is a mix between draw::graph and hand-made
iterations. */
image2d<int> ima_rep(ima.bbox());
// We use the value 9 in draw::graph instead of the default (which is
- // 1) to represent edges to distinguish it from nodes holding a
+ // 1) to represent edges to distinguish it from vertices holding a
// value of 1.
draw::graph (ima_rep, ima, 9);
debug::println (ima_rep);
Index: tests/core/graph_elt_window.cc
--- tests/core/graph_elt_window.cc (revision 1992)
+++ tests/core/graph_elt_window.cc (working copy)
@@ -62,19 +62,19 @@
*/
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<p_t> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
mln::util::graph<p_t> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
Index: tests/core/line_graph_image_wst.cc
--- tests/core/line_graph_image_wst.cc (revision 1992)
+++ tests/core/line_graph_image_wst.cc (working copy)
@@ -50,7 +50,7 @@
| Line graph. |
`-------------*/
- /* Actually this graph is from Jean Cousty's PhD dissertation, page 76.
+ /* Actually this graph is from Jean Cousty's PhD thesis, page 76.
0 1 2 3 (rows)
,------------------------
@@ -63,23 +63,23 @@
3 5 2
(cols)
- In G, nodes and egdes are numbered following in the classical
+ In G, vertices and egdes are numbered following in the classical
foward order. */
util::graph<point2d> g;
- // Nodes.
- std::vector<int> node_values;
- // We don't really care about values on nodes, because the algorithm
+ // Vertices.
+ std::vector<int> vertex_values;
+ // We don't really care about values on vertices, because the algorithm
// won't see them. So all are set to 0.
- g.add_node (make::point2d(0, 0)); node_values.push_back (0); // Node 0.
- g.add_node (make::point2d(0, 1)); node_values.push_back (0); // Node 1.
- g.add_node (make::point2d(0, 2)); node_values.push_back (0); // Node 2.
- g.add_node (make::point2d(0, 3)); node_values.push_back (0); // Node 3.
-
- g.add_node (make::point2d(1, 0)); node_values.push_back (0); // Node 4.
- g.add_node (make::point2d(1, 1)); node_values.push_back (0); // Node 5.
- g.add_node (make::point2d(1, 2)); node_values.push_back (0); // Node 6.
- g.add_node (make::point2d(1, 3)); node_values.push_back (0); // Node 7.
+ g.add_vertex (make::point2d(0, 0)); vertex_values.push_back (0); // Vertex 0.
+ g.add_vertex (make::point2d(0, 1)); vertex_values.push_back (0); // Vertex 1.
+ g.add_vertex (make::point2d(0, 2)); vertex_values.push_back (0); // Vertex 2.
+ g.add_vertex (make::point2d(0, 3)); vertex_values.push_back (0); // Vertex 3.
+
+ g.add_vertex (make::point2d(1, 0)); vertex_values.push_back (0); // Vertex 4.
+ g.add_vertex (make::point2d(1, 1)); vertex_values.push_back (0); // Vertex 5.
+ g.add_vertex (make::point2d(1, 2)); vertex_values.push_back (0); // Vertex 6.
+ g.add_vertex (make::point2d(1, 3)); vertex_values.push_back (0); // Vertex 7.
// Edges.
std::vector<int> edge_values;
@@ -103,7 +103,7 @@
/* FIXME: We probably don't want to build line_graph_images by hand;
provide helpers and/or conversion functions. */
typedef line_graph_image<point2d, int> ima_t;
- ima_t ima(plg, node_values, edge_values);
+ ima_t ima(plg, vertex_values, edge_values);
/*------------.
| Iterators. |
Index: tests/core/line_graph_elt_window.cc
--- tests/core/line_graph_elt_window.cc (revision 1992)
+++ tests/core/line_graph_elt_window.cc (working copy)
@@ -60,19 +60,19 @@
*/
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<p_t> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
mln::util::graph<p_t> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
Index: tests/core/line_graph_elt_neighborhood.cc
--- tests/core/line_graph_elt_neighborhood.cc (revision 1992)
+++ tests/core/line_graph_elt_neighborhood.cc (working copy)
@@ -60,19 +60,19 @@
*/
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<p_t> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
mln::util::graph<p_t> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
Index: tests/core/line_graph_image.cc
--- tests/core/line_graph_image.cc (revision 1992)
+++ tests/core/line_graph_image.cc (working copy)
@@ -63,19 +63,19 @@
*/
- // Points associated to nodes.
+ // Points associated to vertices.
std::vector<point2d> points;
- points.push_back(make::point2d(0,0)); // Point associated to node 0.
- points.push_back(make::point2d(2,2)); // Point associated to node 1.
- points.push_back(make::point2d(0,4)); // Point associated to node 2.
- points.push_back(make::point2d(4,3)); // Point associated to node 3.
- points.push_back(make::point2d(4,4)); // Point associated to node 4.
+ points.push_back(make::point2d(0,0)); // Point associated to vertex 0.
+ points.push_back(make::point2d(2,2)); // Point associated to vertex 1.
+ points.push_back(make::point2d(0,4)); // Point associated to vertex 2.
+ points.push_back(make::point2d(4,3)); // Point associated to vertex 3.
+ points.push_back(make::point2d(4,4)); // Point associated to vertex 4.
// Edges.
util::graph<point2d> g;
- // Populate the graph with nodes.
+ // Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_node (points[i]);
+ g.add_vertex (points[i]);
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -101,11 +101,11 @@
`-------------------*/
// Values ("empty" vectors).
- std::vector<int> node_values(5);
+ std::vector<int> vertex_values(5);
std::vector<int> edge_values(5);
// FIXME: hand-made iota's.
- for (unsigned i = 0; i < node_values.size(); ++i)
- node_values[i] = i;
+ for (unsigned i = 0; i < vertex_values.size(); ++i)
+ vertex_values[i] = i;
for (unsigned i = 0; i < edge_values.size(); ++i)
edge_values[i] = i;
@@ -113,7 +113,7 @@
/* FIXME: We probably don't want to build line_graph_images by hand;
provide helpers and/or conversion functions. */
typedef line_graph_image<point2d, int> ima_t;
- ima_t ima(plg, node_values, edge_values);
+ ima_t ima(plg, vertex_values, edge_values);
/*------------.
| Iterators. |
Index: tests/morpho/artificial_line_graph_image_wst.cc
--- tests/morpho/artificial_line_graph_image_wst.cc (revision 1992)
+++ tests/morpho/artificial_line_graph_image_wst.cc (working copy)
@@ -38,7 +38,7 @@
\li create an artificial (checkboard) 2-D image ;
\li convert this 2-D image into a line graph-based one, where values
on edges are computed as the absolute value of the difference
- between the values on the nodes adjacent to the edge, so as to
+ between the values on the vertices adjacent to the edge, so as to
create a (norm of the) gradient ``between the pixels'' of the
input image;
\li perform a WST on this line graph image;
@@ -198,7 +198,7 @@
We should probably solve this when we ``paint'' the watershed
over the ``doubled'' image.
- A better approach is probably to iterate over the set of nodes,
+ A better approach is probably to iterate over the set of vertices,
and ``connect'' edges according to patterns (vertically or
horizontally connected egdes member of the watershed, etc.). */
// Reuse the piter on OUTPUT.
Index: tests/morpho/lena_line_graph_image_wst1.cc
--- tests/morpho/lena_line_graph_image_wst1.cc (revision 1992)
+++ tests/morpho/lena_line_graph_image_wst1.cc (working copy)
@@ -38,7 +38,7 @@
\li compute a morphological gradient of this image;
\li simplify the image to reduce the number of local minima;
\li convert this 2-D image into a line graph-based one, where values
- on edges are computed as the maxmimum of the values on the nodes
+ on edges are computed as the maxmimum of the values on the vertices
adjacent to the edge;
\li perform a WST on the line graph image;
\li create an 2-D, color output image with height and width double
@@ -110,20 +110,20 @@
// Points.
/* FIXME: The need for such a structure during the conversion
exhibits the lack of a service from util::graph (or a another,
- missing tool) regarding the retrieval of node ids from
+ missing tool) regarding the retrieval of vertex ids from
points. */
- std::map<point2d, util::node_id> points;
- util::node_id id = 0;
+ std::map<point2d, util::vertex_id> points;
+ util::vertex_id id = 0;
- // Nodes.
- std::vector<int> node_values;
+ // Vertices.
+ std::vector<int> vertex_values;
mln_fwd_piter_(image2d<input_val_t>) p(work.domain());
for_all (p)
{
- g.add_node (p);
- node_values.push_back (work(p));
+ g.add_vertex (p);
+ vertex_values.push_back (work(p));
/* FIXME: ``Guessing'' the id of the point just being inserted
- is bad. util:graph<N,E>::add_node should return this
+ is bad. util:graph<N,E>::add_vertex should return this
id. */
points[p] = id;
++id;
@@ -149,7 +149,7 @@
/* FIXME: Shouldn't we use `input_val_t' instead of plain `int' as value
type here? */
typedef line_graph_image<point2d, int> ima_t;
- ima_t lg_ima(plg, node_values, edge_values);
+ ima_t lg_ima(plg, vertex_values, edge_values);
/*------.
| WST. |
@@ -234,7 +234,7 @@
We should probably solve this when we ``paint'' the watershed
over the ``doubled'' image.
- A better approach is probably to iterate over the set of nodes,
+ A better approach is probably to iterate over the set of vertices,
and ``connect'' edges according to patterns (vertically or
horizontally connected egdes member of the watershed, etc.). */
// Reuse the piter on OUTPUT.
Index: tests/morpho/lena_line_graph_image_wst2.cc
--- tests/morpho/lena_line_graph_image_wst2.cc (revision 1992)
+++ tests/morpho/lena_line_graph_image_wst2.cc (working copy)
@@ -38,7 +38,7 @@
\li load a 2-D, gray-level image from a PGM file;
\li convert this 2-D image into a line graph-based one, where values
on edges are computed as the absolute value of the difference
- between the values on the nodes adjacent to the edge, so as to
+ between the values on the vertices adjacent to the edge, so as to
create a (norm of the) gradient ``between the pixels'' of the
input image;
\li reduce the number of minima using an area opening (counting the
@@ -194,7 +194,7 @@
We should probably solve this when we ``paint'' the watershed
over the ``doubled'' image.
- A better approach is probably to iterate over the set of nodes,
+ A better approach is probably to iterate over the set of vertices,
and ``connect'' edges according to patterns (vertically or
horizontally connected egdes member of the watershed, etc.). */
// Reuse the piter on OUTPUT.
Index: mln/core/line_graph_elt_neighborhood.hh
--- mln/core/line_graph_elt_neighborhood.hh (revision 1992)
+++ mln/core/line_graph_elt_neighborhood.hh (working copy)
@@ -116,20 +116,20 @@
/* 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);
Index: mln/core/line_graph_image.hh
--- mln/core/line_graph_image.hh (revision 1992)
+++ mln/core/line_graph_image.hh (working copy)
@@ -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 @@
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 @@
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 @@
/// 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 @@
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 @@
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 @@
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 @@
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 @@
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
Index: mln/core/internal/graph_vicinity_piter.hh
--- mln/core/internal/graph_vicinity_piter.hh (revision 1992)
+++ mln/core/internal/graph_vicinity_piter.hh (working copy)
@@ -78,7 +78,7 @@
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 @@
/// 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 @@
template <typename P, typename E>
inline
- std::set<util::node_id>&
+ std::set<util::vertex_id>&
graph_vicinity_piter_<P, E>::sites()
{
return sites_;
Index: mln/core/graph_image.hh
--- mln/core/graph_image.hh (revision 1992)
+++ mln/core/graph_image.hh (working copy)
@@ -139,19 +139,19 @@
/// 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 @@
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 @@
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 @@
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 @@
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
Index: mln/core/line_graph_psite.hh
--- mln/core/line_graph_psite.hh (revision 1992)
+++ mln/core/line_graph_psite.hh (working copy)
@@ -86,9 +86,9 @@
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 @@
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 @@
template<typename P>
inline
- util::node_id
+ util::vertex_id
line_graph_psite<P>::id() const
{
return id_;
@@ -236,7 +236,7 @@
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 @@
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();
}
template<typename P>
inline
- util::node_id
+ util::vertex_id
line_graph_psite<P>::second_id() const
{
mln_assertion(is_valid());
- return plg().gr_->edge(id_).n2();
+ return plg().gr_->edge(id_).v2();
}
Index: mln/core/p_graph_piter.hh
--- mln/core/p_graph_piter.hh (revision 1992)
+++ mln/core/p_graph_piter.hh (working copy)
@@ -100,7 +100,7 @@
private:
/// The p_graph this point site belongs to.
const p_graph<P>* pg_;
- /// The id of the node this psite is pointing towards.
+ /// The id of the vertex this psite is pointing towards.
unsigned id_;
/// The psite corresponding to this iterator.
psite psite_;
@@ -176,7 +176,7 @@
private:
/// The p_graph this point site belongs to.
const p_graph<P>* pg_;
- /// The id of the node this psite is pointing towards.
+ /// The id of the vertex this psite is pointing towards.
unsigned id_;
/// The psite corresponding to this iterator.
psite psite_;
@@ -249,7 +249,7 @@
bool
p_graph_fwd_piter_<P>::is_valid() const
{
- return pg_ && id_ < pg_->nnodes();
+ return pg_ && id_ < pg_->nvertices();
}
template<typename P>
@@ -401,7 +401,7 @@
bool
p_graph_bkd_piter_<P>::is_valid() const
{
- return pg_ && id_ < pg_->nnodes();
+ return pg_ && id_ < pg_->nvertices();
}
template<typename P>
@@ -417,7 +417,7 @@
void
p_graph_bkd_piter_<P>::start()
{
- id_ = pg_->nnodes() - 1;
+ id_ = pg_->nvertices() - 1;
if (is_valid())
update_();
}
Index: mln/core/graph_elt_window.hh
--- mln/core/graph_elt_window.hh (revision 1992)
+++ mln/core/graph_elt_window.hh (working copy)
@@ -69,9 +69,9 @@
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 @@
/* 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 @@
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)
- {
- 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);
+ for (std::vector<util::edge_id>::const_iterator e =
+ ref_vertex.edges.begin();
+ e != ref_vertex.edges.end(); ++e)
+ {
+ 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);
}
}
Index: mln/core/p_line_graph.hh
--- mln/core/p_line_graph.hh (revision 1992)
+++ mln/core/p_line_graph.hh (working copy)
@@ -79,8 +79,8 @@
/// graph.
std::size_t npoints() const;
- /// Return The number of nodes (vertices) in the graph.
- std::size_t nnodes() const;
+ /// Return The number of vertices (vertices) in the graph.
+ std::size_t nvertices() const;
/// Return The number of edges in the graph.
std::size_t nedges() const;
@@ -145,8 +145,8 @@
: gr_ (new util::graph<P>(gr))
{
accu::bbox<P> a;
- for (unsigned i = 0; i < nnodes(); ++i)
- a.take(gr_->node_data(i));
+ for (unsigned i = 0; i < nvertices(); ++i)
+ a.take(gr_->vertex_data(i));
bb_ = a.to_result();
}
@@ -161,9 +161,9 @@
template<typename P>
inline
std::size_t
- p_line_graph<P>::nnodes() const
+ p_line_graph<P>::nvertices() const
{
- return this->gr_->nnodes();
+ return this->gr_->nvertices();
}
template<typename P>
@@ -222,10 +222,10 @@
// RHS share a common vertex.
/* FIXME: This is too low-level. Yet another service the graph
should provide. */
- if (gr_->edge(lhs).n1() == gr_->edge(rhs).n1() ||
- gr_->edge(lhs).n1() == gr_->edge(rhs).n2() ||
- gr_->edge(lhs).n2() == gr_->edge(rhs).n1() ||
- gr_->edge(lhs).n2() == gr_->edge(rhs).n2())
+ if (gr_->edge(lhs).v1() == gr_->edge(rhs).v1() ||
+ gr_->edge(lhs).v1() == gr_->edge(rhs).v2() ||
+ gr_->edge(lhs).v2() == gr_->edge(rhs).v1() ||
+ gr_->edge(lhs).v2() == gr_->edge(rhs).v2())
return true;
return false;
Index: mln/core/line_graph_elt_window.hh
--- mln/core/line_graph_elt_window.hh (revision 1992)
+++ mln/core/line_graph_elt_window.hh (working copy)
@@ -137,21 +137,21 @@
/* 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);
}
Index: mln/core/graph_psite.hh
--- mln/core/graph_psite.hh (revision 1992)
+++ mln/core/graph_psite.hh (working copy)
@@ -74,8 +74,8 @@
/// 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 @@
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 @@
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 @@
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 @@
template<typename P>
inline
- util::node_id
+ util::vertex_id
graph_psite<P>::id() const
{
return id_;
Index: mln/core/p_graph.hh
--- mln/core/p_graph.hh (revision 1992)
+++ mln/core/p_graph.hh (working copy)
@@ -72,8 +72,8 @@
/// number of \em vertices.
std::size_t npoints() const;
- /// Return The number of nodes (vertices) in the graph.
- std::size_t nnodes() const;
+ /// Return The number of vertices (vertices) in the graph.
+ std::size_t nvertices() const;
/// Return The number of edges in the graph.
std::size_t nedges() const;
@@ -83,31 +83,31 @@
bool has(const psite& p) const;
/// Return the graph point (FIXME site?) from an index
- const P& point_from_id(const util::node_id& id) const;
- P& point_from_id(const util::node_id& id);
+ const P& point_from_id(const util::vertex_id& id) const;
+ P& point_from_id(const util::vertex_id& id);
- /// Return the point contained in the first node adjacent
+ /// Return the point contained in the first vertex adjacent
// to the edge id \a e.
- const P& node1(const util::edge_id& e) const;
- /// Return the point contained in the second node adjacent
+ const P& vertex1(const util::edge_id& e) const;
+ /// Return the point contained in the second vertex adjacent
/// to the edge id \a e.
- const P& node2(const util::edge_id& e) const;
+ const P& vertex2(const util::edge_id& e) const;
/// Adjacency tests.
/// \{
/// Return true if the psites \a lhs and \a rhs are adjacent.
/// (If \a lhs and \a rhs are equal, return false).
bool adjacent(const psite& lhs, const psite& rhs) const;
- /// Return true if the nodes \a lhs and \a rhs are adjacent.
+ /// Return true if the vertices \a lhs and \a rhs are adjacent.
/// (If \a lhs and \a rhs are equal, return false).
- bool adjacent(const util::node_id& lhs, const util::node_id& rhs) const;
+ bool adjacent(const util::vertex_id& lhs, const util::vertex_id& rhs) const;
/// Return true if the psites \a lhs and \a rhs are adjacent, or equal.
bool adjacent_or_equal(const psite& lhs, const psite& rhs) const;
- /// Return true if the nodes \a lhs and \a rhs are adjacent, or equal
- bool adjacent_or_equal(const util::node_id& lhs,
- const util::node_id& rhs) const;
+ /// Return true if the vertices \a lhs and \a rhs are adjacent, or equal
+ bool adjacent_or_equal(const util::vertex_id& lhs,
+ const util::vertex_id& rhs) const;
/// \}
/// Return the graph associated to the p_graph domain:
@@ -158,7 +158,7 @@
{
accu::bbox<P> a;
for (unsigned i = 0; i < npoints(); ++i)
- a.take(gr_->node_data(i));
+ a.take(gr_->vertex_data(i));
bb_ = a.to_result();
}
@@ -167,15 +167,15 @@
std::size_t
p_graph<P>::npoints() const
{
- return nnodes();
+ return nvertices();
}
template<typename P>
inline
std::size_t
- p_graph<P>::nnodes() const
+ p_graph<P>::nvertices() const
{
- return this->gr_->nnodes();
+ return this->gr_->nvertices();
}
template<typename P>
@@ -202,38 +202,38 @@
return
// Check whether P is compatible with this psite set.
(&p.pg() == this) &&
- // Check that the node id of P belongs to the range of valid node ids.
- (p.id() < gr_->nnodes());
+ // Check that the vertex id of P belongs to the range of valid vertex ids.
+ (p.id() < gr_->nvertices());
}
template <typename P>
const P&
- p_graph<P>::point_from_id(const util::node_id& id) const
+ p_graph<P>::point_from_id(const util::vertex_id& id) const
{
- return this->gr_->node_data(id);
+ return this->gr_->vertex_data(id);
}
template <typename P>
P&
- p_graph<P>::point_from_id(const util::node_id& id)
+ p_graph<P>::point_from_id(const util::vertex_id& id)
{
- return this->gr_->node_data(id);
+ return this->gr_->vertex_data(id);
}
template <typename P>
const P&
- p_graph<P>::node1(const util::edge_id& e) const
+ p_graph<P>::vertex1(const util::edge_id& e) const
{
- util::node_id n1 = this->gr_->edge(e).n1();
- return this->point_from_id(n1);
+ util::vertex_id v1 = this->gr_->edge(e).v1();
+ return this->point_from_id(v1);
}
template <typename P>
const P&
- p_graph<P>::node2(const util::edge_id& e) const
+ p_graph<P>::vertex2(const util::edge_id& e) const
{
- util::node_id n2 = this->gr_->edge(e).n2();
- return this->point_from_id(n2);
+ util::vertex_id v2 = this->gr_->edge(e).v2();
+ return this->point_from_id(v2);
}
template <typename P>
@@ -250,8 +250,8 @@
template <typename P>
inline
bool
- p_graph<P>::adjacent(const util::node_id& lhs,
- const util::node_id& rhs) const
+ p_graph<P>::adjacent(const util::vertex_id& lhs,
+ const util::vertex_id& rhs) const
{
mln_assertion(lhs < this->npoints());
mln_assertion(rhs < this->npoints());
@@ -263,11 +263,11 @@
// Check whether LHS and RHS are adjacent (i.e., whether RHS is
// among the neighbors of LHS).
typedef std::vector<util::edge_id> edges_t;
- const edges_t& lhs_neighbs = gr_->nodes()[lhs]->edges;
+ const edges_t& lhs_neighbs = gr_->vertices()[lhs]->edges;
for (edges_t::const_iterator e = lhs_neighbs.begin();
e != lhs_neighbs.end(); ++e)
- if (gr_->edges()[*e]->n1() == rhs ||
- gr_->edges()[*e]->n2() == rhs)
+ if (gr_->edges()[*e]->v1() == rhs ||
+ gr_->edges()[*e]->v2() == rhs)
return true;
return false;
@@ -285,8 +285,8 @@
template <typename P>
inline
bool
- p_graph<P>::adjacent_or_equal(const util::node_id& lhs,
- const util::node_id& rhs) const
+ p_graph<P>::adjacent_or_equal(const util::vertex_id& lhs,
+ const util::vertex_id& rhs) const
{
mln_assertion(lhs < this->npoints());
mln_assertion(rhs < this->npoints());
Index: mln/core/graph_elt_neighborhood.hh
--- mln/core/graph_elt_neighborhood.hh (revision 1992)
+++ mln/core/graph_elt_neighborhood.hh (working copy)
@@ -70,9 +70,9 @@
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 @@
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);
}
}
Index: mln/draw/graph.hh
--- mln/draw/graph.hh (revision 1992)
+++ mln/draw/graph.hh (working copy)
@@ -48,38 +48,38 @@
(e.g., in debug::). */
/*! \brief Draw an image \p ima from a mln::p_graph \p pg, with
- * value \p node_v for nodes, value \p link_v for links and 0 for
+ * value \p vertex_v for vertices, value \p edge_v for edges and 0 for
* the background.
*
* \param[in,out] ima The image to be drawn.
- * \param[in] pg The p_graph which contains nodes and links
+ * \param[in] pg The p_graph which contains vertices and edges
* positions.
- * \param[in] node_v The value to assign to pixels which contains
- * nodes.
- * \param[in] link_v The value to assign to pixels which contains
- * links.
+ * \param[in] vertex_v The value to assign to pixels which contains
+ * vertices.
+ * \param[in] edge_v The value to assign to pixels which contains
+ * edges.
*/
template <typename I, typename P>
void
graph(Image<I>& ima, const p_graph<P>& pg,
- mln_value(I) node_v, mln_value(I) link_v);
+ mln_value(I) vertex_v, mln_value(I) edge_v);
/*! \brief Draw an image \p ima from a mln::graph_image \p gi.
*
* The background is filled with value 0.
*
* \param[in,out] ima The image to be drawn.
- * \param[in] gi The graph_image which contains the nodes, links
- * positions and the values of it.
- * \param[in] link_v The value to assign to pixels which contains
- * links, defaulting to 1.
+ * \param[in] gi The graph_image which contains the vertices,
+ * edges positions and the values of it.
+ * \param[in] edge_v The value to assign to pixels which contains
+ * edges, defaulting to 1.
*/
// FIXME: The type of the last argument cannot always been
// constructed from `int'! We should remove this last argument.
template <typename I, typename P, typename V>
void
graph(Image<I>& ima, const graph_image<P, V>& gi,
- mln_value(I) link_v = 1);
+ mln_value(I) edge_v = 1);
# ifndef MLN_INCLUDE_ONLY
@@ -90,7 +90,7 @@
inline
void
graph(Image<I>& ima, const p_graph<P>& pg,
- mln_value(I) node_v, mln_value(I) link_v)
+ mln_value(I) vertex_v, mln_value(I) edge_v)
{
// Draw the background.
level::fill(ima, 0);
@@ -99,28 +99,28 @@
line (exact(ima),
// FIXME: Too low-level. See similar remarks
// in mln/core/graph_image.hh
- pg.gr_->node_data(pg.gr_->edge(l).n1()),
- pg.gr_->node_data(pg.gr_->edge(l).n2()),
- link_v);
- // Draw the points (nodes).
+ pg.gr_->vertex_data(pg.gr_->edge(l).n1()),
+ pg.gr_->vertex_data(pg.gr_->edge(l).n2()),
+ edge_v);
+ // Draw the points (vertices).
for (size_t p = 0; p < pg.npoints(); ++p)
- exact(ima)(pg.gr_->node_data(p)) = node_v;
+ exact(ima)(pg.gr_->vertex_data(p)) = vertex_v;
}
template <typename I, typename P, typename V>
inline
void
graph(Image<I>& ima, const graph_image<P, V>& gi,
- mln_value(I) link_v)
+ mln_value(I) edge_v)
{
// Draw the background.
level::fill(ima, 0);
// Draw the lines (edges).
for (size_t l = 0; l < gi.domain().nedges(); ++l)
- line (exact(ima), gi.node1(l), gi.node2(l), link_v);
- // Draw the points (nodes).
- for (size_t p = 0; p < gi.domain().nnodes(); ++p)
- exact(ima)(gi.domain().point_from_id(p)) = gi.node_values()[p];
+ line (exact(ima), gi.vertex1(l), gi.vertex2(l), edge_v);
+ // Draw the points (vertices).
+ for (size_t p = 0; p < gi.domain().nvertices(); ++p)
+ exact(ima)(gi.domain().point_from_id(p)) = gi.vertex_values()[p];
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/count_adjacent_vertices.hh
--- mln/accu/count_adjacent_vertices.hh (revision 1992)
+++ mln/accu/count_adjacent_vertices.hh (working copy)
@@ -82,7 +82,7 @@
/// 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_;
};
Index: mln/morpho/line_gradient.hh
--- mln/morpho/line_gradient.hh (revision 1992)
+++ mln/morpho/line_gradient.hh (working copy)
@@ -72,17 +72,17 @@
// Points.
/* FIXME: The need for such a structure during the conversion
exhibits the lack of a service from util::graph (or a another,
- missing tool) regarding the retrieval of nodes' ids from
+ missing tool) regarding the retrieval of vertices' ids from
points. */
- std::map<mln::point2d, util::node_id> points;
+ std::map<mln::point2d, util::vertex_id> points;
- // Nodes.
- std::vector<value_t> node_values;
+ // Vertices.
+ std::vector<value_t> vertex_values;
mln_fwd_piter(image2d<value_t>) p(ima.domain());
for_all (p)
{
- util::node_id id = g.add_node (p);
- node_values.push_back (ima(p));
+ util::vertex_id id = g.add_vertex (p);
+ vertex_values.push_back (ima(p));
points[p] = id;
}
@@ -113,7 +113,7 @@
// Line graph image.
typedef line_graph_image<mln::point2d, value_t> ima_t;
- ima_t lg_ima(plg, node_values, edge_values);
+ ima_t lg_ima(plg, vertex_values, edge_values);
return lg_ima;
}
Index: mln/util/graph.hh
--- mln/util/graph.hh (revision 1992)
+++ mln/util/graph.hh (working copy)
@@ -33,8 +33,6 @@
# include <mln/util/internal/graph_base.hh>
-// FIXME: Rename node(s) as vertex (vertices).
-
namespace mln
{
@@ -45,14 +43,14 @@
`-----------*/
/// \brief Undirected graph.
- template<typename N = void, typename E = void>
+ template<typename V = void, typename E = void>
class graph;
/*--------------------.
| graph<void, void>. |
`--------------------*/
- /// Specialization for undirected graphs with no data on nodes nor
+ /// Specialization for undirected graphs with no data on vertices nor
/// on edges.
template <>
class graph<void, void> : public internal::graph_base<void, void>
@@ -61,73 +59,73 @@
/// The super class.
typedef internal::graph_base<void, void> super;
- /// \brief Add a node.
+ /// \brief Add a vertex.
///
- /// \return The id of the new node.
- node_id add_node();
- /// \brief Add an edge between nodes with ids \p n1 and \p n2.
+ /// \return The id of the new vertex.
+ vertex_id add_vertex();
+ /// \brief Add an edge between vertices with ids \p v1 and \p v2.
///
/// \return The id of the new edge if it does not exist yet;
/// otherwise, return <tt>mln_max(edge_id)</tt>.
- edge_id add_edge(node_id n1, node_id n2);
+ edge_id add_edge(vertex_id v1, vertex_id v2);
};
/*-----------------.
- | graph<N, void>. |
+ | graph<V, void>. |
`-----------------*/
- /// Specialization for undirected graphs with data on nodes.
- template <typename N>
- class graph<N, void> : public internal::graph_base<N, void>
+ /// Specialization for undirected graphs with data on vertices.
+ template <typename V>
+ class graph<V, void> : public internal::graph_base<V, void>
{
public:
/// The super class.
- typedef internal::graph_base<N, void> super;
+ typedef internal::graph_base<V, void> super;
- /// \brief Add a node.
+ /// \brief Add a vertex.
///
- /// \return The id of the new node.
- node_id add_node(const N& data);
- /// \brief Add an edge between nodes with ids \p n1 and \p n2.
+ /// \return The id of the new vertex.
+ vertex_id add_vertex(const V& data);
+ /// \brief Add an edge between vertices with ids \p v1 and \p v2.
///
/// \return The id of the new edge if it does not exist yet;
/// otherwise, return <tt>mln_max(edge_id)</tt>.
- edge_id add_edge(node_id n1, node_id n2);
+ edge_id add_edge(vertex_id v1, vertex_id v2);
- /// Return the data associated to node with id \a n.
+ /// Return the data associated to vertex with id \a v.
/// \{
- N& node_data(node_id n);
- const N& node_data(node_id n) const;
+ V& vertex_data(vertex_id v);
+ const V& vertex_data(vertex_id v) const;
/// \}
};
/*--------------.
- | graph<N, E>. |
+ | graph<V, E>. |
`--------------*/
- /// Specialization for undirected graphs with data on nodes and
+ /// Specialization for undirected graphs with data on vertices and
/// edges.
- template <typename N, typename E>
- class graph : public internal::graph_base<N, E>
+ template <typename V, typename E>
+ class graph : public internal::graph_base<V, E>
{
public:
/// The super class.
- typedef internal::graph_base<N, E> super;
+ typedef internal::graph_base<V, E> super;
- /// \brief Add a node.
+ /// \brief Add a vertex.
///
- /// \return The id of the new node.
- node_id add_node(const N& data);
- /// \brief Add an edge between nodes with ids \p n1 and \p n2.
+ /// \return The id of the new vertex.
+ vertex_id add_vertex(const V& data);
+ /// \brief Add an edge between vertices with ids \p v1 and \p v2.
///
/// \return The id of the new edge if it does not exist yet;
/// otherwise, return <tt>mln_max(edge_id)</tt>.
- edge_id add_edge(node_id n1, node_id n2, const E& data);
+ edge_id add_edge(vertex_id v1, vertex_id v2, const E& data);
- /// Return the data associated to node with id \a n.
+ /// Return the data associated to vertex with id \a v.
/// \{
- N& node_data(node_id n);
- const N& node_data(node_id n) const;
+ V& vertex_data(vertex_id v);
+ const V& vertex_data(vertex_id v) const;
/// \}
/// Return the data associated to the edge with id \a e.
@@ -136,11 +134,11 @@
const E& edge_data(edge_id e) const;
/// \}
- /// Return the data associated to the edge between nodes with
- /// ids \a n1 and \a n2.
+ /// Return the data associated to the edge between vertices with
+ /// ids \a v1 and \a v2.
/// \{
- E& edge_data(node_id n1, node_id n2);
- const E& edge_data(node_id n1, node_id n2) const;
+ E& edge_data(vertex_id v1, vertex_id v2);
+ const E& edge_data(vertex_id v1, vertex_id v2) const;
/// \}
};
@@ -155,153 +153,153 @@
/* Note that ddefinition of members from fully specialized
template classes are not preceded by `template<>'. */
inline
- node_id
- graph<void, void>::add_node()
+ vertex_id
+ graph<void, void>::add_vertex()
{
- return super::add_node_(new util::node<void>);
+ return super::add_vertex_(new util::vertex<void>);
}
/* Note that ddefinition of members from fully specialized
template classes are not preceded by `template<>'. */
inline
edge_id
- graph<void, void>::add_edge(node_id n1, node_id n2)
+ graph<void, void>::add_edge(vertex_id v1, vertex_id v2)
{
- mln_assertion(n1 < this->nnodes());
- mln_assertion(n2 < this->nnodes());
- return super::add_edge_(new util::edge<void>(n1, n2));
+ mln_assertion(v1 < this->nvertices());
+ mln_assertion(v2 < this->nvertices());
+ return super::add_edge_(new util::edge<void>(v1, v2));
}
/*-----------------.
- | graph<N, void>. |
+ | graph<V, void>. |
`-----------------*/
- template<typename N>
+ template<typename V>
inline
- node_id
- graph<N, void>::add_node(const N& data)
+ vertex_id
+ graph<V, void>::add_vertex(const V& data)
{
- return super::add_node_(new util::node<N>(data));
+ return super::add_vertex_(new util::vertex<V>(data));
}
- template<typename N>
+ template<typename V>
inline
edge_id
- graph<N, void>::add_edge(node_id n1, node_id n2)
+ graph<V, void>::add_edge(vertex_id v1, vertex_id v2)
{
- mln_assertion(n1 < this->nnodes());
- mln_assertion(n2 < this->nnodes());
- return super::add_edge_(new util::edge<void>(n1, n2));
+ mln_assertion(v1 < this->nvertices());
+ mln_assertion(v2 < this->nvertices());
+ return super::add_edge_(new util::edge<void>(v1, v2));
}
- template <class N>
+ template <class V>
inline
- N&
- graph<N, void>::node_data(node_id n)
+ V&
+ graph<V, void>::vertex_data(vertex_id v)
{
- mln_assertion(n < this->nnodes());
- return this->nodes_[n]->data;
+ mln_assertion(v < this->nvertices());
+ return this->vertices_[v]->data;
}
- template<typename N>
+ template<typename V>
inline
- const N&
- graph<N, void>::node_data(node_id n) const
+ const V&
+ graph<V, void>::vertex_data(vertex_id v) const
{
- mln_assertion(n < this->nnodes());
- return this->nodes_[n]->data;
+ mln_assertion(v < this->nvertices());
+ return this->vertices_[v]->data;
}
/*--------------.
- | graph<N, E>. |
+ | graph<V, E>. |
`--------------*/
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- node_id
- graph<N, E>::add_node(const N& data)
+ vertex_id
+ graph<V, E>::add_vertex(const V& data)
{
- return super::add_node_(new util::node<N>(data));
+ return super::add_vertex_(new util::vertex<V>(data));
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
edge_id
- graph<N, E>::add_edge(node_id n1, node_id n2, const E& data)
+ graph<V, E>::add_edge(vertex_id v1, vertex_id v2, const E& data)
{
- mln_assertion(n1 < this->nnodes());
- mln_assertion(n2 < this->nnodes());
- return super::add_edge_(new util::edge<E>(n1, n2, data));
+ mln_assertion(v1 < this->nvertices());
+ mln_assertion(v2 < this->nvertices());
+ return super::add_edge_(new util::edge<E>(v1, v2, data));
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- N&
- graph<N, E>::node_data(node_id n)
+ V&
+ graph<V, E>::vertex_data(vertex_id v)
{
- mln_assertion(n < this->nnodes());
- return this->nodes_[n]->data;
+ mln_assertion(v < this->nvertices());
+ return this->vertices_[v]->data;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- const N&
- graph<N, E>::node_data(node_id n) const
+ const V&
+ graph<V, E>::vertex_data(vertex_id v) const
{
- mln_assertion(n < this->nnodes());
- return this->nodes_[n]->data;
+ mln_assertion(v < this->nvertices());
+ return this->vertices_[v]->data;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
E&
- graph<N, E>::edge_data(edge_id e)
+ graph<V, E>::edge_data(edge_id e)
{
mln_assertion(e < this->nedges());
return this->edges_[e]->data;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
const E&
- graph<N, E>::edge_data(edge_id e) const
+ graph<V, E>::edge_data(edge_id e) const
{
mln_assertion(e < this->nedges());
return this->edges_[e]->data;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
E&
- graph<N, E>::edge_data(node_id n1, node_id n2)
+ graph<V, E>::edge_data(vertex_id v1, vertex_id v2)
{
- mln_assertion(n1 < this->nnodes());
- mln_assertion(n2 < this->nnodes());
- ordpair_<node_id> node_pair (n1, n2);
- std::vector<edge_id>& edges_ids = this->nodes_[n1]->edges;
+ mln_assertion(v1 < this->nvertices());
+ mln_assertion(v2 < this->nvertices());
+ ordpair_<vertex_id> vertex_pair (v1, v2);
+ std::vector<edge_id>& edges_ids = this->vertices_[v1]->edges;
for (std::vector<edge_id>::iterator e = edges_ids.begin();
e != edges_ids.end(); ++e)
- if (this->edges_[*e] == node_pair)
+ if (this->edges_[*e] == vertex_pair)
return this->edges_[*e]->data;
- // If no edge between N1 and N2 was found, abort.
+ // If no edge between V1 and V2 was found, abort.
abort();
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
const E&
- graph<N, E>::edge_data(node_id n1, node_id n2) const
+ graph<V, E>::edge_data(vertex_id v1, vertex_id v2) const
{
- mln_assertion(n1 < this->nnodes());
- mln_assertion(n2 < this->nnodes());
- ordpair_<node_id> node_pair (n1, n2);
- const std::vector<edge_id>& edges_ids = this->nodes_[n1]->edges;
+ mln_assertion(v1 < this->nvertices());
+ mln_assertion(v2 < this->nvertices());
+ ordpair_<vertex_id> vertex_pair (v1, v2);
+ const std::vector<edge_id>& edges_ids =
this->vertices_[v1]->edges;
for (std::vector<edge_id>::const_iterator e = edges_ids.begin();
e != edges_ids.end(); ++e)
- if (this->edges_[*e] == node_pair)
+ if (this->edges_[*e] == vertex_pair)
return this->edges_[*e]->data;
- // If no edge between N1 and N2 was found, abort.
+ // If no edge between V1 and V2 was found, abort.
abort();
}
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 1992)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -42,16 +42,14 @@
# include <mln/core/concept/object.hh>
# include <mln/util/ordpair.hh>
-// FIXME: Rename node(s) as vertex (vertices).
-
namespace mln
{
namespace util
{
- /* FIXME: We should create actual types for node_id and edge_id,
+ /* FIXME: We should create actual types for vertex_id and edge_id,
(not just typedefs), at least to prevent the user from using a
- node_id where an edge_id is expected (and vice versa).
+ vertex_id where an edge_id is expected (and vice versa).
Conversion to and from unsigned would still be useful, but it
might be safer to turn them into explicit ones.
@@ -62,10 +60,10 @@
We /might/ want to integrate this into Milena's value system. */
- /// \brief The type used to identify nodes.
+ /// \brief The type used to identify vertices.
///
- /// Used internally as a key to manipulate nodes.
- typedef unsigned node_id;
+ /// Used internally as a key to manipulate vertices.
+ typedef unsigned vertex_id;
/// \brief The type used to identify edges.
///
@@ -73,15 +71,15 @@
typedef unsigned edge_id;
- /*-------.
- | Node. |
- `-------*/
+ /*---------.
+ | Vertex. |
+ `---------*/
- /// \brief Node of a graph, holding a value of type \p T.
+ /// \brief Vertex of a graph, holding a value of type \p T.
template<typename T>
- struct node
+ struct vertex
{
- node(T data)
+ vertex(T data)
: data(data)
{}
@@ -89,10 +87,10 @@
std::vector<edge_id> edges;
};
- /// \brief Specialization of mln::util::node for nodes with no
+ /// \brief Specialization of mln::util::vertex for vertices with no
/// associated value.
template <>
- struct node<void>
+ struct vertex<void>
{
std::vector<edge_id> edges;
};
@@ -106,38 +104,38 @@
template<typename T>
struct edge
{
- edge(node_id n1, node_id n2)
- : pair_node_(n1, n2)
+ edge(vertex_id v1, vertex_id v2)
+ : pair_vertex_(v1, v2)
{}
- /// Return the lowest node id adjacent to this edge.
- node_id n1() const { return pair_node_.first; }
- /// Return the highest node id adjacent to this edge.
- node_id n2() const { return pair_node_.second; }
+ /// Return the lowest vertex id adjacent to this edge.
+ vertex_id v1() const { return pair_vertex_.first; }
+ /// Return the highest vertex id adjacent to this edge.
+ vertex_id v2() const { return pair_vertex_.second; }
T data;
- ordpair_<node_id> pair_node_;
+ ordpair_<vertex_id> pair_vertex_;
};
- /// \brief Specialization of mln::util::node for edges with no
+ /// \brief Specialization of mln::util::vertex for edges with no
/// associated value.
template <>
struct edge<void>
{
- edge(node_id n1, node_id n2)
- : pair_node_(n1, n2)
+ edge(vertex_id v1, vertex_id v2)
+ : pair_vertex_(v1, v2)
{}
- /// Return the lowest node id adjacent to this edge.
- node_id n1() const { return pair_node_.first; }
- /// Return the highest node id adjacent to this edge.
- node_id n2() const { return pair_node_.second; }
+ /// Return the lowest vertex id adjacent to this edge.
+ vertex_id v1() const { return pair_vertex_.first; }
+ /// Return the highest vertex id adjacent to this edge.
+ vertex_id v2() const { return pair_vertex_.second; }
- ordpair_<node_id> pair_node_;
+ ordpair_<vertex_id> pair_vertex_;
};
// FIXME: Document this. In particular, we should state that edges are
- // only compared w.r.t. their adjacent nodes, not the data they
+ // only compared w.r.t. their adjacent vertices, not the data they
// possibly hold!
template <typename E>
bool
@@ -148,24 +146,24 @@
operator< (const edge<E>& lhs, const edge<E>& rhs);
- /*--------.
- | Graph. |
- `--------*/
+ /*-------------.
+ | Graph base. |
+ `-------------*/
namespace internal
{
/// \brief Base class for undirected graphs.
- template<typename N, typename E>
+ template<typename V, typename E>
class graph_base
{
- typedef graph_base<N, E> self_t;
+ typedef graph_base<V, E> self_t;
public:
- /* FIXME: Do we really want handle nodes and edges through
+ /* FIXME: Do we really want handle vertices and edges through
pointers? In my (Roland) opinion, this is just a drawback,
here. */
- /// The type of the set of nodes.
- typedef std::vector< util::node<N>* > nodes_t;
+ /// The type of the set of vertices.
+ typedef std::vector< util::vertex<V>* > vertices_t;
/// The type of the set of edges.
typedef std::vector< util::edge<E>* > edges_t;
/// A set to test the presence of a given edge.
@@ -179,10 +177,10 @@
~graph_base();
/// \}
- /// Return the node whose id is \a n.
+ /// Return the vertex whose id is \a v.
/// \{
- util::node<N>& node(node_id n);
- const util::node<N>& node(edge_id n) const;
+ util::vertex<V>& vertex(vertex_id v);
+ const util::vertex<V>& vertex(edge_id v) const;
/// \}
/// Return the edge whose id is \a e.
@@ -191,10 +189,10 @@
const util::edge<E>& edge(edge_id e) const;
/// \}
- /// Return the whole nodes of the graph.
+ /// Return the whole vertices of the graph.
/// \{
- nodes_t& nodes();
- const nodes_t& nodes() const;
+ vertices_t& vertices();
+ const vertices_t& vertices() const;
/// \}
/// Return the whole edges of the graph.
@@ -203,8 +201,8 @@
const edges_t& edges() const;
/// \}
- /// \brief Return the number of nodes in the graph.
- size_t nnodes() const;
+ /// \brief Return the number of vertices in the graph.
+ size_t nvertices() const;
/// \brief Return the number of edges in the graph.
size_t nedges() const;
@@ -216,12 +214,12 @@
void print_debug(std::ostream& ostr) const;
protected:
- /// Shortcuts factoring the insertion of nodes and edges.
+ /// Shortcuts factoring the insertion of vertices and edges.
/// \{
- /// \brief Add a node.
+ /// \brief Add a vertex.
///
- /// \return The id of the new node.
- node_id add_node_(util::node<N>* node);
+ /// \return The id of the new vertex.
+ vertex_id add_vertex_(util::vertex<V>* vertex);
/// \brief Add an edge.
///
/// \return The id of the new edge if it does not exist yet;
@@ -230,8 +228,8 @@
/// \}
protected:
- /// The nodes.
- nodes_t nodes_;
+ /// The vertices.
+ vertices_t vertices_;
/// The edges.
edges_t edges_;
/// An index of the set of edges, for fast-access purpose.
@@ -248,14 +246,14 @@
bool
operator==(const edge<E>& lhs, const edge<E>& rhs)
{
- return lhs.pair_node_ == rhs.pair_node_;
+ return lhs.pair_vertex_ == rhs.pair_vertex_;
}
template <typename E>
bool
operator< (const edge<E>& lhs, const edge<E>& rhs)
{
- return lhs.pair_node_ < rhs.pair_node_;
+ return lhs.pair_vertex_ < rhs.pair_vertex_;
}
namespace internal
@@ -265,23 +263,23 @@
| Construction, assignments and destruction. |
`--------------------------------------------*/
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- graph_base<N, E>::graph_base()
- : nodes_(), edges_(), edges_set_()
+ graph_base<V, E>::graph_base()
+ : vertices_(), edges_(), edges_set_()
{
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- graph_base<N, E>::graph_base(const graph_base<N, E>& rhs)
- : nodes_(), edges_(), edges_set_()
+ graph_base<V, E>::graph_base(const graph_base<V, E>& rhs)
+ : vertices_(), edges_(), edges_set_()
{
- nodes_.reserve(rhs.nodes_.size());
+ vertices_.reserve(rhs.vertices_.size());
edges_.reserve(rhs.edges_.size());
- for (typename nodes_t::const_iterator n = rhs.nodes_.begin();
- n != rhs.nodes_.end(); ++n)
- nodes_.push_back(new util::node<N>(**n));
+ for (typename vertices_t::const_iterator v = rhs.vertices_.begin();
+ v != rhs.vertices_.end(); ++v)
+ vertices_.push_back(new util::vertex<V>(**v));
for (typename edges_t::const_iterator e = rhs.edges_.begin();
e != rhs.edges_.end(); ++e)
edges_.push_back(new util::edge<E>(**e));
@@ -290,27 +288,27 @@
edges_set_.begin()));
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- graph_base<N, E>&
- graph_base<N, E>::operator=(const graph_base<N, E>& rhs)
+ graph_base<V, E>&
+ graph_base<V, E>::operator=(const graph_base<V, E>& rhs)
{
if (this != &rhs)
{
- /// Free previous nodes and edges.
- for (typename nodes_t::iterator n = nodes_.begin();
- n != nodes_.end(); ++n)
- delete *n;
+ /// Free previous vertices and edges.
+ for (typename vertices_t::iterator v = vertices_.begin();
+ v != vertices_.end(); ++v)
+ delete *v;
for (typename edges_t::iterator e = edges_.begin();
e != edges_.end(); ++e)
delete *e;
edges_set_.clear();
/// Assign values from RHS.
- nodes_.reserve(rhs.nodes_.size());
+ vertices_.reserve(rhs.vertices_.size());
edges_.reserve(rhs.edges_.size());
- for (typename nodes_t::const_iterator n = rhs.nodes_.begin();
- n != rhs.nodes_.end(); ++n)
- nodes_.push_back(new util::node<N>(**n));
+ for (typename vertices_t::const_iterator v = rhs.vertices_.begin();
+ v != rhs.vertices_.end(); ++v)
+ vertices_.push_back(new util::vertex<V>(**v));
for (typename edges_t::const_iterator e = rhs.edges_.begin();
e != rhs.edges_.end(); ++e)
edges_.push_back(new util::edge<E>(**e));
@@ -321,13 +319,13 @@
return *this;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- graph_base<N, E>::~graph_base()
+ graph_base<V, E>::~graph_base()
{
- for (typename nodes_t::iterator n = nodes_.begin(); n != nodes_.end();
- ++n)
- delete *n;
+ for (typename vertices_t::iterator v = vertices_.begin();
+ v != vertices_.end(); ++v)
+ delete *v;
for (typename edges_t::iterator e = edges_.begin(); e != edges_.end();
++e)
delete *e;
@@ -338,86 +336,86 @@
| Accessors. |
`------------*/
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- util::node<N>&
- graph_base<N, E>::node(node_id n)
+ util::vertex<V>&
+ graph_base<V, E>::vertex(vertex_id v)
{
- mln_assertion(n < this->nnodes());
- return *nodes_[n];
+ mln_assertion(v < this->nvertices());
+ return *vertices_[v];
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- const util::node<N>&
- graph_base<N, E>::node(node_id n) const
+ const util::vertex<V>&
+ graph_base<V, E>::vertex(vertex_id v) const
{
- mln_assertion(n < this->nnodes());
- return *nodes_[n];
+ mln_assertion(v < this->nvertices());
+ return *vertices_[v];
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
util::edge<E>&
- graph_base<N, E>::edge(edge_id e)
+ graph_base<V, E>::edge(edge_id e)
{
mln_assertion(e < this->nedges());
return *edges_[e];
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
const util::edge<E>&
- graph_base<N, E>::edge(edge_id e) const
+ graph_base<V, E>::edge(edge_id e) const
{
mln_assertion(e < this->nedges());
return *edges_[e];
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- typename graph_base<N, E>::nodes_t&
- graph_base<N, E>::nodes()
+ typename graph_base<V, E>::vertices_t&
+ graph_base<V, E>::vertices()
{
- return nodes_;
+ return vertices_;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- const typename graph_base<N, E>::nodes_t&
- graph_base<N, E>::nodes() const
+ const typename graph_base<V, E>::vertices_t&
+ graph_base<V, E>::vertices() const
{
- return nodes_;
+ return vertices_;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- typename graph_base<N, E>::edges_t&
- graph_base<N, E>::edges()
+ typename graph_base<V, E>::edges_t&
+ graph_base<V, E>::edges()
{
return edges_;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- const typename graph_base<N, E>::edges_t&
- graph_base<N, E>::edges() const
+ const typename graph_base<V, E>::edges_t&
+ graph_base<V, E>::edges() const
{
return edges_;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
size_t
- graph_base<N, E>::nnodes() const
+ graph_base<V, E>::nvertices() const
{
- return nodes_.size();
+ return vertices_.size();
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
size_t
- graph_base<N, E>::nedges() const
+ graph_base<V, E>::nedges() const
{
return edges_.size();
}
@@ -426,21 +424,21 @@
| Manipulators. |
`---------------*/
- template<typename N, typename E>
+ template<typename V, typename E>
inline
- node_id
- graph_base<N, E>::add_node_(util::node<N>* node)
+ vertex_id
+ graph_base<V, E>::add_vertex_(util::vertex<V>* vertex)
{
/* FIXME: This is not thread-proof (these two lines should
form an atomic section). */
- nodes_.push_back (node);
- return nodes_.size() - 1;
+ vertices_.push_back (vertex);
+ return vertices_.size() - 1;
}
- template<typename N, typename E>
+ template<typename V, typename E>
inline
edge_id
- graph_base<N, E>::add_edge_(util::edge<E>* edge)
+ graph_base<V, E>::add_edge_(util::edge<E>* edge)
{
// Does this edge already exist in the graph?
if (edges_set_.find(edge) != edges_set_.end ())
@@ -461,8 +459,8 @@
// Update the set of edges.
edges_set_.insert(edge);
- nodes_[edge->n1()]->edges.push_back(id);
- nodes_[edge->n2()]->edges.push_back(id);
+ vertices_[edge->v1()]->edges.push_back(id);
+ vertices_[edge->v2()]->edges.push_back(id);
return id;
}
@@ -472,22 +470,22 @@
| Debug. |
`--------*/
- template<typename N, typename E>
+ template<typename V, typename E>
inline
void
- graph_base<N, E>::print_debug (std::ostream& ostr) const
+ graph_base<V, E>::print_debug (std::ostream& ostr) const
{
ostr << "graph: " << std::endl;
int i = 0;
- for (typename nodes_t::const_iterator n = nodes_.begin ();
- n != nodes_.end (); ++n, ++i)
+ for (typename vertices_t::const_iterator v = vertices_.begin ();
+ v != vertices_.end (); ++v, ++i)
{
- ostr << "node: " << i << std::endl << " --
adjacent nodes: ";
+ ostr << "vertex: " << i << std::endl << " --
adjacent vertices: ";
/* FIXME: We shouldn't manipulate std::vector<edge_id>
directly, but use a typedef instead. */
for (typename std::vector<util::edge_id>::const_iterator e =
- (*n)->edges.begin();
- e != (*n)->edges.end(); ++e)
+ (*v)->edges.begin();
+ e != (*v)->edges.end(); ++e)
ostr << *e << " ";
ostr << std::endl;
}