= `adjacency_iterator_generator`

Synthesizes a vertex-iterator out of an existing *_out-edge_* iterator.
Reads each out-edge and yields its *_target_* vertex.

*Defined in:* `<boost/graph/adjacency_iterator.hpp>`

IMPORTANT: You almost certainly do not need this page.

Most BGL users just call `adjacent_vertices(v, g)` on any graph that
models xref:concepts/AdjacencyGraph.adoc[Adjacency Graph] (which every
built-in BGL graph class does). This page is for people *_implementing
a new graph class_* that models xref:concepts/IncidenceGraph.adoc[Incidence
Graph] and who want the compiler to give them the adjacency iterator for
free.

== Example

[source,cpp]
----
include::example$iterators/adjacency_iterator.cpp[]
----

[,text]
----
include::example$iterators/adjacency_iterator.txt[]
----

The example shows both paths:

. `adjacent_vertices(v, g)` — the everyday way to iterate over neighbors.
. `adjacency_iterator_generator<…>::type` — the type you would publish as
  `adjacency_iterator` in your own graph class.

For existing graph types like `adjacency_list`, the generator produces
the same type that `graph_traits` already exposes; there is no reason
to instantiate it yourself.

== Synopsis

[source,cpp]
----
namespace boost {

template <class Graph,
          class VertexDescriptor = typename graph_traits<Graph>::vertex_descriptor,
          class OutEdgeIter      = typename graph_traits<Graph>::out_edge_iterator>
class adjacency_iterator_generator {
public:
    typedef /* iterator_adaptor instantiation */ type;
};

} // namespace boost
----

== Template parameters

[cols="1,4"]
|===
| Parameter | Description

| `Graph`
| The graph type. Must model xref:concepts/IncidenceGraph.adoc[Incidence Graph].

| `VertexDescriptor`
| The vertex-descriptor type. Defaults to
  `graph_traits<Graph>::vertex_descriptor`. The parameter exists because
  the generator is typically instantiated *_inside_* the graph class's
  declaration, where `graph_traits<Graph>` cannot yet be resolved.

| `OutEdgeIter`
| The source out-edge iterator type. Defaults to
  `graph_traits<Graph>::out_edge_iterator`, with the same caveat as above.
|===

== Members

`adjacency_iterator_generator<…>::type` satisfies the
link:../../utility/MultiPassInputIterator.html[Multi-Pass Input Iterator]
concept. It exposes every operator required of a
link:../../utility/RandomAccessIterator.html[Random Access Iterator],
except that `reference` equals `value_type`, so `operator*()` returns
by value.

Constructor:

[source,cpp]
----
adjacency_iterator_generator<…>::type(const OutEdgeIter& it, const Graph* g);
----

== See also

* xref:traits/overview.adoc[Traits and Iterators overview]
* xref:concepts/AdjacencyGraph.adoc[AdjacencyGraph concept] —
  `adjacent_vertices(v, g)`, what you probably want.
* xref:traits/iterators/inv_adjacency_iterator.adoc[`inv_adjacency_iterator_generator`] —
  the bidirectional counterpart.
