GraphDom
Toggle main menu visibility
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
17
namespace
graphdom
{}
18
19
namespace
graphdom
{
21
enum
edge_type
: std::uint8_t {
22
undirected
= 0,
23
directed
= 1
24
};
25
}
26
27
namespace
graphdom
{
29
42
template
<
typename
VertexType>
43
class
graph
{
44
public
:
45
class
vertex_handle
;
46
class
vertex_const_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
VertexContainerPo
int
erType>
74
class
vertex_base_handle;
75
template
<
typename
VertexContainerPo
int
erType>
76
class
base_adj_list;
77
template
<
typename
VertexContainerPo
int
erType>
78
class
adj_list_base_iterator;
79
80
class
vertex_container;
81
template
<
typename
VertexContainerPo
int
erType>
82
class
edge_endpoint;
83
template
<
typename
VertexContainerPo
int
erType,
typename
EdgeLabelType>
84
class
labeled_directed_edge_endpoint;
85
template
<
typename
VertexContainerPo
int
erType,
typename
EdgeLabelType>
86
class
labeled_undirected_edge_endpoint;
87
template
<
typename
VertexContainerPo
int
erType>
88
class
custom_edge_endpoint_less;
89
template
<
typename
VertexContainerPo
int
erType>
90
using
adj_set = std::set< edge_endpoint<VertexContainerPointerType>* , custom_edge_endpoint_less<VertexContainerPointerType> >;
91
enum
graph_edges_type : std::uint8_t {
92
undirected
=
edge_type::undirected
,
93
directed
=
edge_type::directed
,
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
VertexContainerPo
int
erType>
102
class
non_mixed_graph_vertex_container;
103
template
<
typename
VertexContainerPo
int
erType>
104
class
mixed_graph_vertex_container;
105
template
<
typename
VertexContainerPo
int
erType,
typename
VertexLabelType>
106
class
non_mixed_graph_labeled_vertex_container;
107
template
<
typename
VertexContainerPo
int
erType,
typename
VertexLabelType>
108
class
mixed_graph_labeled_vertex_container;
109
110
static
vertex_handle vertex_handle_factory(
111
const
graphdom::graph<VertexType>
*,
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(
117
const
graphdom::graph<VertexType>
*,
118
const
graphdom::graph<VertexType>::mixed_graph_vertex_container<const vertex_container*>&
119
);
120
121
static
vertex_const_handle vertex_const_handle_factory(
122
const
graphdom::graph<VertexType>
*,
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(
128
const
graphdom::graph<VertexType>
*,
129
const
graphdom::graph<VertexType>::mixed_graph_vertex_container<const vertex_container*>&
130
);
131
132
static
const
graphdom::graph<VertexType>
* get_owner_graph(
const
graphdom::graph<VertexType>::vertex_const_handle
&);
133
134
static
const
vertex_container* get_vertex_container(
const
graphdom::graph<VertexType>::vertex_const_handle
&);
135
136
static
const
graphdom::graph<VertexType>
* get_owner_graph(
const
graphdom::graph<VertexType>::adj_list_const_iterator
&);
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
graphdom::graph::adj_list
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
graphdom::graph::const_adj_list
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
graphdom::graph::vertex_const_handle
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
graphdom::graph::vertex_handle
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
graphdom::graph
Every graph created using this library is an instance of a concrete class publicly derived,...
Definition
graph.h:43
graphdom::graph::order
virtual std::size_t order() const =0
Returns the order of *this, i.e. the number of vertices inside the graph.
graphdom::graph::~graph
virtual ~graph()=default
To be polymorphic, this class has a virtual destructor.
graphdom::graph::erase_vertex
virtual void erase_vertex(const vertex_const_handle &vertex)=0
Removes the vertex identified by vertex.
graphdom
Definition
adj_list.h:16
graphdom::edge_type
edge_type
The enumerated type whose values represent the two types of edges of a graph.
Definition
graph.h:21
graphdom::undirected
@ undirected
This enum value means undirected edge.
Definition
graph.h:22
graphdom::directed
@ directed
This enum value means directed edge.
Definition
graph.h:23
include
graphdom
graph.h
Generated by
1.17.0