Skip to content

Commit b9fabbe

Browse files
authored
Merge pull request CGAL#6550 from afabri/BGL-adjacency_iterator-GF
BGL: Add adjacency_iterator for several classes
2 parents 8b5c57e + 7360250 commit b9fabbe

File tree

11 files changed

+97
-29
lines changed

11 files changed

+97
-29
lines changed

Arrangement_on_surface_2/include/CGAL/graph_traits_Arrangement_2.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <CGAL/Named_function_parameters.h>
2828

2929
#include <boost/graph/graph_concepts.hpp>
30+
#include <CGAL/boost/graph/iterator.h>
3031
#include <CGAL/boost/iterator/counting_iterator.hpp>
3132
#include <CGAL/Arrangement_on_surface_2.h>
3233
#include <CGAL/Arrangement_2.h>
@@ -75,7 +76,8 @@ class graph_traits<CGAL::Arrangement_on_surface_2<GeomTraits, TopTraits> >
7576
public virtual boost::bidirectional_graph_tag, // This tag refines the
7677
// incidence_graph_tag.
7778
public virtual boost::vertex_list_graph_tag, // Can iterate over vertices.
78-
public virtual boost::edge_list_graph_tag // Can iterate over edges.
79+
public virtual boost::edge_list_graph_tag, // Can iterate over edges.
80+
public virtual boost::adjacency_graph_tag
7981
{};
8082

8183
/*! \class
@@ -232,7 +234,7 @@ class graph_traits<CGAL::Arrangement_on_surface_2<GeomTraits, TopTraits> >
232234
typedef typename Arrangement_on_surface_2::Size edges_size_type;
233235

234236
// Types not required by any of these concepts:
235-
typedef void adjacency_iterator;
237+
typedef CGAL::Vertex_around_target_iterator<Arrangement_on_surface_2> adjacency_iterator;
236238

237239
/*! Constructor. */
238240
graph_traits (const Arrangement_on_surface_2& arr) :
@@ -411,6 +413,20 @@ out_edges (typename
411413
return std::make_pair (gt_arr.out_edges_begin (v), gt_arr.out_edges_end (v));
412414
}
413415

416+
template <class GeomTraits, class TopTraits>
417+
Iterator_range< typename
418+
boost::graph_traits<CGAL::Arrangement_on_surface_2<GeomTraits,
419+
TopTraits> >::
420+
adjacency_iterator>
421+
adjacent_vertices(typename
422+
boost::graph_traits<CGAL::Arrangement_on_surface_2<GeomTraits,
423+
TopTraits> >::
424+
vertex_descriptor v,
425+
const CGAL::Arrangement_on_surface_2<GeomTraits, TopTraits>& arr)
426+
{
427+
return CGAL::vertices_around_target(v,arr);
428+
}
429+
414430
/*!
415431
* Get the source vertex of an arrangement edge.
416432
* \param e The edge.

BGL/doc/BGL/graph_traits.txt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The traits class `boost::graph_traits< CGAL::Surface_mesh<T> >` provides the fol
3636
| `face_iterator` | `Surface_mesh::Face_iterator` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
3737
| `directed_category` | `boost::undirected_tag` | This graph is not directed. |
3838
| `edge_parallel_category` | `boost::disallow_parallel_edge_tag` | This graph does not support multiedges. |
39-
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, and `boost::edge_list_graph_tag` | The ways in which the vertices in the graph can be traversed. |
39+
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, `boost::edge_list_graph_tag`, and `boost::adjacency_graph_tag` | The ways in which the vertices in the graph can be traversed. |
4040
| `vertices_size_type` | `Surface_mesh::vertices_size_type` | The size type of the vertex list. |
4141
| `edges_size_type` | `Surface_mesh::edges_size_type` | The size type of the edge list. |
4242
| `degree_size_type` | `Surface_mesh::degree_size_type` | The size type of the adjacency list. |
@@ -69,7 +69,7 @@ The traits class `boost::graph_traits< CGAL::Polyhedron_3<T> >` provides the fol
6969
| `face_iterator` | `unspecified_type` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
7070
| `directed_category` | `boost::undirected_tag` | This graph is not directed. |
7171
| `edge_parallel_category` | `boost::disallow_parallel_edge_tag` | This graph does not support multiedges. |
72-
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, and `boost::edge_list_graph_tag` | The ways in which the vertices in the graph can be traversed. |
72+
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, `boost::edge_list_graph_tag`, and`boost::adjacency_graph_tag` | The ways in which the vertices in the graph can be traversed. |
7373
| `vertices_size_type` | `Polyhedron_3::size_type` | The size type of the vertex list. |
7474
| `edges_size_type` | `Polyhedron_3::size_type` | The size type of the edge list. |
7575
| `degree_size_type` | `Polyhedron_3::size_type` | The size type of the adjacency list. |
@@ -102,7 +102,7 @@ The traits class `boost::graph_traits<LCC>` provides the following types:
102102
| `edge_iterator` | `unspecified_type` | Iterate through the edges of LCC.|
103103
| `halfedge_iterator` | `unspecified_type` | Iterate through the halfedges of LCC.|
104104
| `face_iterator` | `unspecified_type` | Iterate through the faces of LCC.|
105-
| `directed_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag` and `boost::edge_list_graph_tag` | |
105+
| `directed_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, `boost::edge_list_graph_tag`, and `boost::adjacency_graph_tag` | |
106106
| `edge_parallel_category` | `boost::disallow_parallel_edge_tag` | Indicates that this graph does not support multiedges |
107107
| `traversal_category` | `boost::bidirectional_graph_tag` | Indicates that this graph is bidirectional |
108108
| `vertices_size_type` | `LCC::size_type` | The size type of the vertex list |
@@ -197,14 +197,14 @@ provides the following types:
197197
| :----------------------- | :----: | :---------- |
198198
| `vertex_descriptor` | `Arrangement_2::Vertex_handle` | Identify vertices in the graph. |
199199
| `edge_descriptor` | `Arrangement_2::Halfedge_handle` | Identify edges in the graph. |
200-
| `adjacency_iterator` | Not provided| |
200+
| `adjacency_iterator` | `Vertex_around_target_iterator<Arrangement_2>`| An iterator to traverse through the vertices adjacent to a vertex. Its value type is `vertex_descriptor`.|
201201
| `out_edge_iterator` | `unspecified_type` | An edge iterator which only iterates over the outgoing halfedges around a vertex. It corresponds to a `Arrangement_2::Halfedge_around_vertex_circulator` with the difference that its value type is an edge descriptor and not `Arrangement_2::Halfedge`|
202202
| `in_edge_iterator` | `unspecified_type` | An edge iterator which only iterates over the incoming edges around a vertex. It corresponds to a `Arrangement_2::Halfedge_around_vertex_circulator` with the difference that its value type is an edge descriptor and not `Arrangement_2::Halfedge`|
203203
| `vertex_iterator` | `unspecified_type` | An iterator corresponding to `Arrangement_2::Vertex_iterator`, with the difference that its value type is a vertex descriptor and not `Arrangement_2::Vertex` |
204204
| `edge_iterator` | `unspecified_type` | An iterator corresponding to `Arrangement_2::Halfedge_iterator` with the difference that its value type is an edge descriptor and not `Arrangement_2::Halfedge`|
205205
| `directed_category` | `boost::directed_tag` | This graph is directed. |
206206
| `edge_parallel_category` | `boost::allow_parallel_edge_tag` | This graph supports multiedges. |
207-
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, and `boost::edge_list_graph_tag` | The ways in which the vertices in the graph can be traversed. |
207+
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, `boost::edge_list_graph_tag`, and `boost::adjacency_graph_tag` | The ways in which the vertices in the graph can be traversed. |
208208
| `vertices_size_type` | `Arrangement_2::Size` | The size type of the vertex list. |
209209
| `edges_size_type` | `Arrangement_2::Size` | The size type of the edge list. |
210210
| `degree_size_type` | `Arrangement_2::Size` | The size type of the adjacency list. |
@@ -221,20 +221,20 @@ The traits class `boost::graph_traits<OpenMesh::PolyMesh_ArrayKernelT<K> >` prov
221221

222222
| Member | Value | Description |
223223
| :----------------------- | :----: | :---------- |
224-
| `vertex_descriptor` | `OpenMesh::PolyMesh_ArrayKernelT::VertexHandle` | Identify vertices in the graph. |
224+
| `vertex_descriptor` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%VertexHandle` | Identify vertices in the graph. |
225225
| `edge_descriptor` | `unspecified_type` | Identify edges in the graph. |
226-
| `halfedge_descriptor` | `OpenMesh::PolyMesh_ArrayKernelT::HalfedgeHandle` | Identify halfedges in the graph. |
227-
| `face_descriptor` | `OpenMesh::PolyMesh_ArrayKernelT::FaceHandle` | Identify faces in the graph. |
228-
| `adjacency_iterator` | `unspecified_type` | An iterator to traverse through the vertices adjacent to a vertex. Its value type is `vertex_descriptor`. |
226+
| `halfedge_descriptor` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%HalfedgeHandle` | Identify halfedges in the graph. |
227+
| `face_descriptor` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%FaceHandle` | Identify faces in the graph. |
228+
| `adjacency_iterator` | `CGAL::Vertex_around_target_iterator<OpenMesh::PolyMesh_ArrayKernelT<K> >` | An iterator to traverse through the vertices adjacent to a vertex. Its value type is `vertex_descriptor`. |
229229
| `out_edge_iterator` | `CGAL::Out_edge_iterator<OpenMesh::PolyMesh_ArrayKernelT<K> >` | An iterator to traverse through the outgoing edges incident to a vertex. Its value type is `edge_descriptor`. |
230230
| `in_edge_iterator` | `CGAL::In_edge_iterator<OpenMesh::PolyMesh_ArrayKernelT<K> >` | An iterator to traverse through the incoming edges incident to a vertex. Its value type is `edge_descriptor`. |
231-
| `vertex_iterator` | `OpenMesh::PolyMesh_ArrayKernelT::VertexIter` | An iterator to traverse through the vertices of the graph. Its value type is `vertex_descriptor`. |
231+
| `vertex_iterator` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%VertexIter` | An iterator to traverse through the vertices of the graph. Its value type is `vertex_descriptor`. |
232232
| `edge_iterator` | `unspecified_type` | An iterator to traverse through the edges of the graph. Its value type is `edge_descriptor`. |
233-
| `halfedge_iterator` | `OpenMesh::PolyMesh_ArrayKernelT::HalfedgeIter` | An iterator to traverse through the halfedges of the graph. Its value type is `halfedge_descriptor`. |
234-
| `face_iterator` | `OpenMesh::PolyMesh_ArrayKernelT::FaceIter` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
233+
| `halfedge_iterator` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%HalfedgeIter` | An iterator to traverse through the halfedges of the graph. Its value type is `halfedge_descriptor`. |
234+
| `face_iterator` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%FaceIter` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
235235
| `directed_category` | `boost::undirected_tag` | This graph is not directed. |
236236
| `edge_parallel_category` | `boost::disallow_parallel_edge_tag` | This graph does not support multiedges. |
237-
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, and `boost::edge_list_graph_tag` | The ways in which the vertices in the graph can be traversed. |
237+
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`,`boost::edge_list_graph_tag`, and`boost::adjacency_graph_tag` | The ways in which the vertices in the graph can be traversed. |
238238
| `vertices_size_type` | `unsigned int` | The size type of the vertex list. |
239239
| `edges_size_type` | `unsigned int` | The size type of the edge list. |
240240
| `degree_size_type` | `unsigned int` | The size type of the adjacency list. |
@@ -251,20 +251,20 @@ The traits class `boost::graph_traits<OpenMesh::TriMesh_ArrayKernelT<K> >` provi
251251

252252
| Member | Value | Description |
253253
| :----------------------- | :----: | :---------- |
254-
| `vertex_descriptor` | `OpenMesh::TriMesh_ArrayKernelT::VertexHandle` | Identify vertices in the graph. |
254+
| `vertex_descriptor` | `OpenMesh::TriMesh_ArrayKernelT<K>::%VertexHandle` | Identify vertices in the graph. |
255255
| `edge_descriptor` | `unspecified_type` | Identify edges in the graph. |
256-
| `halfedge_descriptor` | `OpenMesh::TriMesh_ArrayKernelT::HalfedgeHandle` | Identify halfedges in the graph. |
257-
| `face_descriptor` | `OpenMesh::TriMesh_ArrayKernelT::FaceHandle` | Identify faces in the graph. |
258-
| `adjacency_iterator` | `unspecified_type` | An iterator to traverse through the vertices adjacent to a vertex. Its value type is `vertex_descriptor`. |
256+
| `halfedge_descriptor` | `OpenMesh::TriMesh_ArrayKernelT<K>::%HalfedgeHandle` | Identify halfedges in the graph. |
257+
| `face_descriptor` | `OpenMesh::TriMesh_ArrayKernelT<K>::%FaceHandle` | Identify faces in the graph. |
258+
| `adjacency_iterator` | `CGAL::Vertex_around_target_iterator<OpenMesh::TriMesh_ArrayKernelT<K> >` | An iterator to traverse through the vertices adjacent to a vertex. Its value type is `vertex_descriptor`. |
259259
| `out_edge_iterator` | `CGAL::Out_edge_iterator<OpenMesh::TriMesh_ArrayKernelT<K> >` | An iterator to traverse through the outgoing edges incident to a vertex. Its value type is `edge_descriptor`. |
260260
| `in_edge_iterator` | `CGAL::In_edge_iterator<OpenMesh::TriMesh_ArrayKernelT<K> >` | An iterator to traverse through the incoming edges incident to a vertex. Its value type is `edge_descriptor`. |
261-
| `vertex_iterator` | `OpenMesh::PolyMesh_ArrayKernelT::VertexIter` | An iterator to traverse through the vertices of the graph. Its value type is `vertex_descriptor`. |
261+
| `vertex_iterator` | `OpenMesh::PolyMesh_ArrayKernelT<K>::%VertexIter` | An iterator to traverse through the vertices of the graph. Its value type is `vertex_descriptor`. |
262262
| `edge_iterator` | `unspecified_type` | An iterator to traverse through the edges of the graph. Its value type is `edge_descriptor`. |
263-
| `halfedge_iterator` | `OpenMesh::TriMesh_ArrayKernelT::HalfedgeIter` | An iterator to traverse through the halfedges of the graph. Its value type is `halfedge_descriptor`. |
264-
| `face_iterator` | `OpenMesh::TriMesh_ArrayKernelT::FaceIter` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
263+
| `halfedge_iterator` | `OpenMesh::TriMesh_ArrayKernelT<K>::%HalfedgeIter` | An iterator to traverse through the halfedges of the graph. Its value type is `halfedge_descriptor`. |
264+
| `face_iterator` | `OpenMesh::TriMesh_ArrayKernelT<K>::%FaceIter` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
265265
| `directed_category` | `boost::undirected_tag` | This graph is not directed. |
266266
| `edge_parallel_category` | `boost::disallow_parallel_edge_tag` | This graph does not support multiedges. |
267-
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, and `boost::edge_list_graph_tag` | The ways in which the vertices in the graph can be traversed. |
267+
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::vertex_list_graph_tag`, `boost::edge_list_graph_tag`, and `boost::adjacency_graph_tag` | The ways in which the vertices in the graph can be traversed. |
268268
| `vertices_size_type` | `unsigned int` | The size type of the vertex list. |
269269
| `edges_size_type` | `unsigned int` | The size type of the edge list. |
270270
| `degree_size_type` | `unsigned int` | The size type of the adjacency list. |

BGL/include/CGAL/boost/graph/graph_traits_OpenMesh.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ struct graph_traits< OPEN_MESH_CLASS >
8181

8282
struct SM_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
8383
public virtual boost::vertex_list_graph_tag,
84-
public virtual boost::edge_list_graph_tag
84+
public virtual boost::edge_list_graph_tag,
85+
public virtual boost::adjacency_graph_tag
8586
{};
8687

8788
public:
@@ -124,10 +125,12 @@ struct graph_traits< OPEN_MESH_CLASS >
124125

125126
typedef CGAL::Out_edge_iterator<SM> out_edge_iterator;
126127

128+
typedef CGAL::Vertex_around_target_iterator<SM> adjacency_iterator;
129+
127130
// nulls
128131
static vertex_descriptor null_vertex() { return vertex_descriptor(); }
129132
static face_descriptor null_face() { return face_descriptor(); }
130-
static halfedge_descriptor null_halfedge() { return halfedge_descriptor(); }
133+
static halfedge_descriptor null_halfedge() { return halfedge_descriptor(); }
131134
};
132135

133136
template<typename K>
@@ -264,6 +267,17 @@ out_edges(typename boost::graph_traits<OPEN_MESH_CLASS >::vertex_descriptor v,
264267
}
265268

266269

270+
template <typename K>
271+
CGAL::Iterator_range<typename boost::graph_traits<OPEN_MESH_CLASS >::adjacency_iterator>
272+
adjacent_vertices(typename boost::graph_traits<OPEN_MESH_CLASS >::vertex_descriptor v,
273+
const OPEN_MESH_CLASS& sm)
274+
{
275+
return CGAL::vertices_around_target(v,sm);
276+
}
277+
278+
279+
280+
267281
template<typename K>
268282
std::pair<typename boost::graph_traits<OPEN_MESH_CLASS >::edge_descriptor,
269283
bool>

BGL/test/BGL/graph_concept_Linear_cell_complex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef LCC::Traits::Point Point_3;
2121
template<typename Graph>
2222
void concept_check_polyhedron() {
2323
boost::function_requires< boost::GraphConcept<LCC> >();
24+
boost::function_requires< boost::AdjacencyGraphConcept<LCC> >();
2425
boost::function_requires< boost::VertexListGraphConcept<LCC> >();
2526
boost::function_requires< boost::EdgeListGraphConcept<LCC> >();
2627
boost::function_requires< boost::IncidenceGraphConcept<LCC> >();

BGL/test/BGL/graph_concept_OpenMesh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef Traits::face_descriptor face_descriptor;
1818
template<typename Graph>
1919
void concept_check_polyhedron() {
2020
boost::function_requires< boost::GraphConcept<Sm> >();
21+
boost::function_requires< boost::AdjacencyGraphConcept<Sm> >();
2122

2223
// Those have to be disabled due to OpenMesh's broken iterators.
2324
// boost::function_requires< boost::VertexListGraphConcept<Sm> >();

BGL/test/BGL/graph_concept_Polyhedron_3.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ typedef Kernel::Point_3 Point_3;
1515
template<typename Graph>
1616
void concept_check_polyhedron() {
1717
boost::function_requires< boost::GraphConcept<Polyhedron> >();
18+
boost::function_requires< boost::AdjacencyGraphConcept<Polyhedron> >();
1819
boost::function_requires< boost::VertexListGraphConcept<Polyhedron> >();
1920
boost::function_requires< boost::EdgeListGraphConcept<Polyhedron> >();
2021
boost::function_requires< boost::IncidenceGraphConcept<Polyhedron> >();

BGL/test/BGL/graph_concept_Surface_mesh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ typedef Traits::face_descriptor face_descriptor;
1515
void concept_check_surface_mesh()
1616
{
1717
boost::function_requires< boost::GraphConcept<Surface_mesh> >();
18+
boost::function_requires< boost::AdjacencyGraphConcept<Surface_mesh> >();
1819
boost::function_requires< boost::VertexListGraphConcept<Surface_mesh> >();
1920
boost::function_requires< boost::EdgeListGraphConcept<Surface_mesh> >();
2021
boost::function_requires< boost::IncidenceGraphConcept<Surface_mesh> >();

HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ struct HDS_graph_traits
155155
private:
156156
struct HDS_graph_traversal_category : public virtual boost::bidirectional_graph_tag,
157157
public virtual boost::vertex_list_graph_tag,
158-
public virtual boost::edge_list_graph_tag
158+
public virtual boost::edge_list_graph_tag,
159+
public virtual boost::adjacency_graph_tag
159160
{};
160161

161162
public:
@@ -179,6 +180,8 @@ struct HDS_graph_traits
179180

180181
typedef In_edge_iterator<HDS> in_edge_iterator;
181182

183+
typedef Vertex_around_target_iterator<HDS> adjacency_iterator;
184+
182185
typedef boost::undirected_tag directed_category;
183186
typedef boost::disallow_parallel_edge_tag edge_parallel_category;
184187
typedef HDS_graph_traversal_category traversal_category;

0 commit comments

Comments
 (0)