[graph] VertexListGraph and InputIterator, and LEDA graph

Hi all, I'm currently fixing up leda_graph.hpp so it passes the tests, or indeed, fixing the tests ... A leda::GRAPH<int,int> (=Graph) has to fulfill VertexListGraphConcept. This means that boost::graph_traits<G>::vertex_iterator has to be a MultiPassInputIterator, i.e., also a InputIterator. I cannot read from http://www.sgi.com/tech/stl/InputIterator.html that it must be possible that you can compute the difference between two iterators. But apparently the concept check (which fails) requires a difference type, which must be a signed integer. Is this a bug in the concept check? The vertex_iterator type is defined in leda_graph.hpp using iterator_facade: class vertex_iterator : public iterator_facade<vertex_iterator, leda::node, bidirectional_traversal_tag, const leda::node&, const leda::node*> { public: vertex_iterator(leda::node node = 0, const leda::GRAPH<vtype, etype>* g = 0) : base(node), g(g) {} private: const leda::node& dereference() const { return base; } bool equal(const vertex_iterator& other) const { return base == other.base; } void increment() { base = g->succ_node(base); } void decrement() { base = g->pred_node(base); } leda::node base; const leda::GRAPH<vtype, etype>* g; friend class iterator_core_access; }; Is maybe iterator_facade insufficient? For me, bidirectional_traversal_tag does not indicate that random access is possible ... -- Jens

On Sun, 1 Jan 2012, Jens Müller wrote:
Hi all,
I'm currently fixing up leda_graph.hpp so it passes the tests, or indeed, fixing the tests ...
A leda::GRAPH<int,int> (=Graph) has to fulfill VertexListGraphConcept. This means that boost::graph_traits<G>::vertex_iterator has to be a MultiPassInputIterator, i.e., also a InputIterator.
I cannot read from http://www.sgi.com/tech/stl/InputIterator.html that it must be possible that you can compute the difference between two iterators.
But apparently the concept check (which fails) requires a difference type, which must be a signed integer. Is this a bug in the concept check?
You need the difference_type defined (to be the result of std::distance, for example) but not the operator-() to compute the distance itself (nor the other random access operators such as +). -- Jeremiah Willcock

Am 02.01.2012 16:39, schrieb Jeremiah Willcock:
which must be a signed integer. Is this a bug in the concept check? You need the difference_type defined (to be the result of std::distance, for example) but not the operator-() to compute the distance itself (nor
But apparently the concept check (which fails) requires a difference type, the other random access operators such as +).
Thanks, that makes sense. So the bug is in leda_graph.hpp: "const leda::node*" as difference type does not make sense at all. I will send a patch soon. Do you think a clarification in http://www.boost.org/doc/libs/1_48_0/libs/iterator/doc/iterator_facade.html#... would be in order? Best, Jens

Am 02.01.2012 17:40, schrieb Jens Müller:
So the bug is in leda_graph.hpp: "const leda::node*" as difference type does not make sense at all.
I will send a patch soon.
Can someone please checkin the attached patch? It fixes iterators and the clear_vertex function for the LEDA graph adapter. -- Jens

Am 05.01.2012 22:37, schrieb Jens Müller:
@@ -183,6 +179,9 @@ typedef int vertices_size_type; typedef int edges_size_type; typedef int degree_size_type; + + typedef vtype vertex_property_type; + typedef etype edge_property_type; };
Sorry, this shouldn't be part of this patch ... -- Jens
participants (2)
-
Jens Müller
-
Jeremiah Willcock