Pangolin
Header-only C++20 plane computational geometry library
Loading...
Searching...
No Matches
pgl::Graph< Vertex >::EdgeIterator Class Reference

Forward iterator over the undirected edges of a graph. More...

#include <graph.hpp>

Public Types

using iterator_category = std::input_iterator_tag
using iterator_concept = std::forward_iterator_tag
using difference_type = std::ptrdiff_t
using value_type = EdgeType
using reference = EdgeType

Public Member Functions

 EdgeIterator ()=default
 Creates an iterator with no associated graph.
reference operator* () const
 Returns the current edge, smaller endpoint first.
EdgeIteratoroperator++ ()
 Advances to the next edge.
EdgeIterator operator++ (int)
 Advances to the next edge and returns the previous position.

Friends

class Graph
bool operator== (const EdgeIterator &, const EdgeIterator &)=default

Detailed Description

template<class Vertex>
class pgl::Graph< Vertex >::EdgeIterator

Forward iterator over the undirected edges of a graph.

Dereferencing yields an edge by value, as an EdgeType whose first vertex is the smaller of the two. The adjacency map holds both directions of every edge, so the iterator walks the adjacency sets and keeps only the direction that comes out increasing, visiting each edge once.

Requires a totally ordered VertexType, unlike the rest of the graph.

Member Typedef Documentation

◆ difference_type

template<class Vertex>
using pgl::Graph< Vertex >::EdgeIterator::difference_type = std::ptrdiff_t

◆ iterator_category

template<class Vertex>
using pgl::Graph< Vertex >::EdgeIterator::iterator_category = std::input_iterator_tag

◆ iterator_concept

template<class Vertex>
using pgl::Graph< Vertex >::EdgeIterator::iterator_concept = std::forward_iterator_tag

◆ reference

template<class Vertex>
using pgl::Graph< Vertex >::EdgeIterator::reference = EdgeType

◆ value_type

template<class Vertex>
using pgl::Graph< Vertex >::EdgeIterator::value_type = EdgeType

Constructor & Destructor Documentation

◆ EdgeIterator()

template<class Vertex>
pgl::Graph< Vertex >::EdgeIterator::EdgeIterator ( )
default

Creates an iterator with no associated graph.

Member Function Documentation

◆ operator*()

template<class Vertex>
reference pgl::Graph< Vertex >::EdgeIterator::operator* ( ) const
inline

Returns the current edge, smaller endpoint first.

◆ operator++() [1/2]

template<class Vertex>
EdgeIterator & pgl::Graph< Vertex >::EdgeIterator::operator++ ( )
inline

Advances to the next edge.

◆ operator++() [2/2]

template<class Vertex>
EdgeIterator pgl::Graph< Vertex >::EdgeIterator::operator++ ( int )
inline

Advances to the next edge and returns the previous position.

◆ Graph

template<class Vertex>
friend class Graph
friend

◆ operator==

template<class Vertex>
bool operator== ( const EdgeIterator & ,
const EdgeIterator &  )
friend