11#include <boost/graph/adjacency_list.hpp>
12#include <boost/graph/graph_traits.hpp>
13#include <boost/graph/graph_utility.hpp>
25 template <
typename Graph>
class VertexView :
public Graph {
34 explicit VertexView(Graph&& gra) noexcept : Graph{std::move(gra)} {}
43 [[nodiscard]]
auto begin()
const {
46 return boost::vertices(*this).first;
56 [[nodiscard]]
auto end()
const {
59 return boost::vertices(*this).second;
72 return boost::vertices(*this).first;
82 [[nodiscard]]
auto cend()
const {
85 return boost::vertices(*this).second;
121 return boost::edges(this->gra).first;
131 [[nodiscard]]
auto end()
const {
134 return boost::edges(this->gra).second;
147 return boost::edges(this->gra).first;
157 [[nodiscard]]
auto cend()
const {
160 return boost::edges(this->gra).second;
174 template <
typename Vertex,
typename Graph>
class AtlasView {
188 AtlasView(Vertex v,
const Graph& gra) : _v{v}, gra{gra} {}
200 return boost::out_edges(this->_v, this->gra).first;
213 return boost::out_edges(this->_v, this->gra).second;
226 return boost::out_edges(this->_v, this->gra).first;
239 return boost::out_edges(this->_v, this->gra).second;
257 using Vertex =
typename boost::graph_traits<Graph>::vertex_descriptor;
259 using edge_t =
typename boost::graph_traits<Graph>::edge_descriptor;
327 return boost::add_edge(
static_cast<Vertex>(u),
static_cast<Vertex>(v), *
this);
349 return boost::source(e, *
this);
362 return boost::target(e, *
this);
372 template <
typename Edge> [[nodiscard]]
auto end_points(
const Edge& e)
const {
373 auto s = boost::source(e, *
this);
374 auto t = boost::target(e, *
this);
375 return std::make_pair(s, t);
Atlas view for vertex adjacency in Boost Graph Library graphs.
Definition nx2bgl.hpp:174
auto end() const
Get iterator to the end of adjacent edges.
Definition nx2bgl.hpp:210
AtlasView(Vertex v, const Graph &gra)
Construct a new Atlas View object.
Definition nx2bgl.hpp:188
auto cend() const
Get const iterator to the end of adjacent edges.
Definition nx2bgl.hpp:236
auto begin() const
Get iterator to the beginning of adjacent edges.
Definition nx2bgl.hpp:197
auto cbegin() const
Get const iterator to the beginning of adjacent edges.
Definition nx2bgl.hpp:223
Edge view for Boost Graph Library graphs.
Definition nx2bgl.hpp:97
auto begin() const
Get iterator to the beginning of edges.
Definition nx2bgl.hpp:118
auto cend() const
Get const iterator to the end of edges.
Definition nx2bgl.hpp:157
auto cbegin() const
Get const iterator to the beginning of edges.
Definition nx2bgl.hpp:144
EdgeView(const Graph &gra)
Construct a new Edge View object.
Definition nx2bgl.hpp:109
auto end() const
Get iterator to the end of edges.
Definition nx2bgl.hpp:131
Graph adapter for Boost Graph Library integration.
Definition nx2bgl.hpp:255
GrAdaptor()=delete
Default constructor (deleted)
auto edges() const -> EdgeView< Graph >
Get an edge view for the graph.
Definition nx2bgl.hpp:305
auto neighbors(Vertex v) const -> AtlasView< Vertex, Graph >
Get neighbors of a vertex.
Definition nx2bgl.hpp:315
typename boost::graph_traits< Graph >::vertex_descriptor Vertex
Definition nx2bgl.hpp:257
auto add_edge(int u, int v)
Add an edge between two vertices.
Definition nx2bgl.hpp:326
Vertex node_t
Definition nx2bgl.hpp:258
GrAdaptor(Graph &&gra) noexcept
Construct a new graph adaptor object.
Definition nx2bgl.hpp:278
auto target(const Edge &e) const -> Vertex
Get the target vertex of an edge.
Definition nx2bgl.hpp:361
auto source(const Edge &e) const -> Vertex
Get the source vertex of an edge.
Definition nx2bgl.hpp:348
auto end_points(const Edge &e) const
Get the source and target vertices of an edge.
Definition nx2bgl.hpp:372
auto number_of_nodes() const
Get the number of vertices in the graph.
Definition nx2bgl.hpp:289
auto number_of_edges() const
Get the number of edges in the graph.
Definition nx2bgl.hpp:296
typename boost::graph_traits< Graph >::edge_descriptor edge_t
Definition nx2bgl.hpp:259
static auto null_vertex() -> Vertex
Get the null vertex descriptor.
Definition nx2bgl.hpp:337
Vertex view for Boost Graph Library graphs.
Definition nx2bgl.hpp:25
auto cend() const
Get const iterator to the end of vertices.
Definition nx2bgl.hpp:82
auto cbegin() const
Get const iterator to the beginning of vertices.
Definition nx2bgl.hpp:69
auto end() const
Get iterator to the end of vertices.
Definition nx2bgl.hpp:56
VertexView(Graph &&gra) noexcept
Construct a new Vertex View object.
Definition nx2bgl.hpp:34
auto begin() const
Get iterator to the beginning of vertices.
Definition nx2bgl.hpp:43
Python-like utilities and data structures for C++.
Definition dict.hpp:18