11#include <boost/graph/adjacency_list.hpp>
12#include <boost/graph/graph_traits.hpp>
13#include <boost/graph/graph_utility.hpp>
26 template <
typename Graph>
class VertexView :
public Graph {
35 explicit VertexView(Graph&& gra) noexcept : Graph{std::forward<Graph>(gra)} {}
44 [[nodiscard]]
auto begin()
const {
47 return boost::vertices(*this).first;
57 [[nodiscard]]
auto end()
const {
60 return boost::vertices(*this).second;
73 return boost::vertices(*this).first;
83 [[nodiscard]]
auto cend()
const {
86 return boost::vertices(*this).second;
122 return boost::edges(this->gra).first;
132 [[nodiscard]]
auto end()
const {
135 return boost::edges(this->gra).second;
148 return boost::edges(this->gra).first;
158 [[nodiscard]]
auto cend()
const {
161 return boost::edges(this->gra).second;
175 template <
typename Vertex,
typename Graph>
class AtlasView {
189 AtlasView(Vertex v,
const Graph& gra) : _v{v}, gra{gra} {}
201 return boost::out_edges(this->_v, this->gra).first;
214 return boost::out_edges(this->_v, this->gra).second;
227 return boost::out_edges(this->_v, this->gra).first;
240 return boost::out_edges(this->_v, this->gra).second;
254 using Vertex =
typename boost::graph_traits<_Graph>::vertex_descriptor;
256 using edge_t =
typename boost::graph_traits<_Graph>::edge_descriptor;
324 return boost::add_edge(
static_cast<Vertex>(u),
static_cast<Vertex>(v), *
this);
346 return boost::source(e, *
this);
359 return boost::target(e, *
this);
369 template <
typename Edge> [[nodiscard]]
auto end_points(
const Edge& e)
const {
370 auto s = boost::source(e, *
this);
371 auto t = boost::target(e, *
this);
372 return std::make_pair(s, t);
Atlas view for vertex adjacency in Boost Graph Library graphs.
Definition nx2bgl.hpp:175
auto end() const
Get iterator to the end of adjacent edges.
Definition nx2bgl.hpp:211
AtlasView(Vertex v, const Graph &gra)
Construct a new Atlas View object.
Definition nx2bgl.hpp:189
auto cend() const
Get const iterator to the end of adjacent edges.
Definition nx2bgl.hpp:237
auto begin() const
Get iterator to the beginning of adjacent edges.
Definition nx2bgl.hpp:198
auto cbegin() const
Get const iterator to the beginning of adjacent edges.
Definition nx2bgl.hpp:224
Edge view for Boost Graph Library graphs.
Definition nx2bgl.hpp:98
auto begin() const
Get iterator to the beginning of edges.
Definition nx2bgl.hpp:119
auto cend() const
Get const iterator to the end of edges.
Definition nx2bgl.hpp:158
auto cbegin() const
Get const iterator to the beginning of edges.
Definition nx2bgl.hpp:145
EdgeView(const Graph &gra)
Construct a new Edge View object.
Definition nx2bgl.hpp:110
auto end() const
Get iterator to the end of edges.
Definition nx2bgl.hpp:132
Graph adapter for Boost Graph Library integration.
Definition nx2bgl.hpp:252
static auto null_vertex() -> Vertex
Get the null vertex descriptor.
Definition nx2bgl.hpp:334
auto source(const Edge &e) const -> Vertex
Get the source vertex of an edge.
Definition nx2bgl.hpp:345
auto end_points(const Edge &e) const
Get the source and target vertices of an edge.
Definition nx2bgl.hpp:369
typename boost::graph_traits< _Graph >::edge_descriptor edge_t
Definition nx2bgl.hpp:256
auto add_edge(int u, int v)
Add an edge between two vertices.
Definition nx2bgl.hpp:323
GrAdaptor()=delete
Default constructor (deleted)
typename boost::graph_traits< _Graph >::vertex_descriptor Vertex
Definition nx2bgl.hpp:254
auto neighbors(Vertex v) const -> AtlasView< Vertex, _Graph >
Get neighbors of a vertex.
Definition nx2bgl.hpp:312
auto number_of_nodes() const
Get the number of vertices in the graph.
Definition nx2bgl.hpp:286
Vertex node_t
Definition nx2bgl.hpp:255
auto number_of_edges() const
Get the number of edges in the graph.
Definition nx2bgl.hpp:293
auto edges() const -> EdgeView< _Graph >
Get an edge view for the graph.
Definition nx2bgl.hpp:302
GrAdaptor(_Graph &&gra) noexcept
Construct a new graph adaptor object.
Definition nx2bgl.hpp:275
auto target(const Edge &e) const -> Vertex
Get the target vertex of an edge.
Definition nx2bgl.hpp:358
Vertex view for Boost Graph Library graphs.
Definition nx2bgl.hpp:26
auto cend() const
Get const iterator to the end of vertices.
Definition nx2bgl.hpp:83
auto cbegin() const
Get const iterator to the beginning of vertices.
Definition nx2bgl.hpp:70
auto end() const
Get iterator to the end of vertices.
Definition nx2bgl.hpp:57
VertexView(Graph &&gra) noexcept
Construct a new Vertex View object.
Definition nx2bgl.hpp:35
auto begin() const
Get iterator to the beginning of vertices.
Definition nx2bgl.hpp:44
Python-like utilities and data structures for C++.
Definition dict.hpp:18