GraphDom
Loading...
Searching...
No Matches
graph.h
1/*
2 * Copyright 2026 Michele Comparini
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef GRAPHDOM_GRAPH_H
8#define GRAPHDOM_GRAPH_H
9
10#include <cstdint>
11#include <cstddef>
12#include <memory>
13#include <set>
14#include <utility>
15
17namespace graphdom{}
18
19namespace graphdom {
21 enum edge_type : std::uint8_t {
24 };
25}
26
27namespace graphdom {
29
42 template <typename VertexType>
43 class graph {
44 public:
45 class vertex_handle;
47 class adj_list;
48 class const_adj_list;
49 class adj_list_iterator;
50 class adj_list_const_iterator;
51
53 virtual ~graph() = default;
54
56
59 [[nodiscard]] virtual std::size_t order() const = 0;
60
62
68 virtual void erase_vertex(const vertex_const_handle& vertex) = 0;
69 [[nodiscard]] virtual adj_list_iterator erase_edge(const adj_list_const_iterator&) = 0;
70
72 protected:
73 template <typename VertexContainerPointerType>
74 class vertex_base_handle;
75 template <typename VertexContainerPointerType>
76 class base_adj_list;
77 template <typename VertexContainerPointerType>
78 class adj_list_base_iterator;
79
80 class vertex_container;
81 template<typename VertexContainerPointerType>
82 class edge_endpoint;
83 template <typename VertexContainerPointerType, typename EdgeLabelType>
84 class labeled_directed_edge_endpoint;
85 template <typename VertexContainerPointerType, typename EdgeLabelType>
86 class labeled_undirected_edge_endpoint;
87 template<typename VertexContainerPointerType>
88 class custom_edge_endpoint_less;
89 template<typename VertexContainerPointerType>
90 using adj_set = std::set< edge_endpoint<VertexContainerPointerType>* , custom_edge_endpoint_less<VertexContainerPointerType> >;
91 enum graph_edges_type : std::uint8_t {
94 mixed
95 };
96 enum edges_type_selection_type : uint8_t {
97 undirected_edges = edge_type::undirected,
98 directed_edges = edge_type::directed,
99 none
100 };
101 template<typename VertexContainerPointerType>
102 class non_mixed_graph_vertex_container;
103 template<typename VertexContainerPointerType>
104 class mixed_graph_vertex_container;
105 template<typename VertexContainerPointerType, typename VertexLabelType>
106 class non_mixed_graph_labeled_vertex_container;
107 template<typename VertexContainerPointerType, typename VertexLabelType>
108 class mixed_graph_labeled_vertex_container;
109
110 static vertex_handle vertex_handle_factory(
112 const graphdom::graph<VertexType>::non_mixed_graph_vertex_container<const vertex_container*>&,
113 graphdom::edge_type non_mixed_graph_type
114 );
115
116 static vertex_handle vertex_handle_factory(
118 const graphdom::graph<VertexType>::mixed_graph_vertex_container<const vertex_container*>&
119 );
120
121 static vertex_const_handle vertex_const_handle_factory(
123 const graphdom::graph<VertexType>::non_mixed_graph_vertex_container<const vertex_container*>&,
124 graphdom::edge_type non_mixed_graph_type
125 );
126
127 static vertex_const_handle vertex_const_handle_factory(
129 const graphdom::graph<VertexType>::mixed_graph_vertex_container<const vertex_container*>&
130 );
131
133
134 static const vertex_container* get_vertex_container(const graphdom::graph<VertexType>::vertex_const_handle&);
135
137
138 static const graphdom::graph<VertexType>::vertex_container* get_begin_point(const graphdom::graph<VertexType>::adj_list_const_iterator&);
140 };
141}
142
143#include "detail/vertex_container.h"
144#include "detail/edge_endpoint.h"
145#include "detail/labeled_directed_edge_endpoint.h"
146#include "detail/labeled_undirected_edge_endpoint.h"
147#include "detail/custom_edge_endpoint_less.h"
148#include "detail/non_mixed_graph_vertex_container.h"
149#include "detail/mixed_graph_vertex_container.h"
150#include "detail/non_mixed_graph_labeled_vertex_container.h"
151#include "detail/mixed_graph_labeled_vertex_container.h"
152
153#include "detail/vertex_base_handle.h"
154#include "detail/vertex_handle.h"
155#include "detail/vertex_const_handle.h"
156#include "detail/base_adj_list.h"
157#include "detail/adj_list.h"
158#include "detail/const_adj_list.h"
159#include "detail/adj_list_base_iterator.h"
160#include "detail/adj_list_iterator.h"
161#include "detail/adj_list_const_iterator.h"
162
163#include "impl/graph.h"
164
165#endif //GRAPHDOM_GRAPH_H
Every valid instance of this class is a "container-like and non-owning" handle to a subset of the set...
Definition adj_list.h:32
Every valid instance of this class is a "container-like and non-owning" handle to a subset of the set...
Definition const_adj_list.h:35
Every valid instance of this class can be used to identify a specific vertex of a graph and to access...
Definition vertex_const_handle.h:35
Every valid instance of this class can be used to identify a specific vertex of a graph and to access...
Definition vertex_handle.h:32
Every graph created using this library is an instance of a concrete class publicly derived,...
Definition graph.h:43
virtual std::size_t order() const =0
Returns the order of *this, i.e. the number of vertices inside the graph.
virtual ~graph()=default
To be polymorphic, this class has a virtual destructor.
virtual void erase_vertex(const vertex_const_handle &vertex)=0
Removes the vertex identified by vertex.
Definition adj_list.h:16
edge_type
The enumerated type whose values represent the two types of edges of a graph.
Definition graph.h:21
@ undirected
This enum value means undirected edge.
Definition graph.h:22
@ directed
This enum value means directed edge.
Definition graph.h:23