7#ifndef GRAPHDOM_FULL_LABELED_SET_DIGRAPH_IMPL_H
8#define GRAPHDOM_FULL_LABELED_SET_DIGRAPH_IMPL_H
10#include "../full_labeled_set_digraph.h"
12template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
15labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(v_lab),
16labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(e_lab),
17vertices( custom_vertices_set_compare(v_comp) ) {}
19template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
22labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(v_lab),
23labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(std::move(e_lab)),
24vertices( custom_vertices_set_compare(v_comp) ) {}
26template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
29labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(std::move(v_lab)),
30labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(e_lab),
31vertices( custom_vertices_set_compare(v_comp) ) {}
33template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
36labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(std::move(v_lab)),
37labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(std::move(e_lab)),
38vertices( custom_vertices_set_compare(v_comp) ) {}
40template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
43labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(v_lab),
44labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(e_lab),
45vertices( custom_vertices_set_compare(std::move(v_comp)) ) {}
47template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
50labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(v_lab),
51labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(std::move(e_lab)),
52vertices( custom_vertices_set_compare(std::move(v_comp)) ) {}
54template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
57labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(std::move(v_lab)),
58labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(e_lab),
59vertices( custom_vertices_set_compare(std::move(v_comp)) ) {}
61template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
64labeled_vertex_set_graph<VertexType,VertexLabelType,VertexLabellerType>(std::move(v_lab)),
65labeled_edge_non_mixed_graph<VertexType,EdgeLabelType,EdgeLabellerType>(std::move(e_lab)),
66vertices( custom_vertices_set_compare(std::move(v_comp)) ) {}
68template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
69graphdom::full_labeled_set_digraph<VertexType,VertexLabelType,EdgeLabelType,Compare,VertexLabellerType,EdgeLabellerType>::~full_labeled_set_digraph() {
70 for (
auto digraph_vertices_itr = vertices.begin(); digraph_vertices_itr != vertices.end(); ++digraph_vertices_itr) {
71 auto& dv_itr_vertex_container = *digraph_vertices_itr;
72 auto& dv_itr_vc_adj = dv_itr_vertex_container.adj;
73 for (
auto edge_endpoint_to_deallocate = dv_itr_vc_adj.begin(); edge_endpoint_to_deallocate != dv_itr_vc_adj.end(); ++edge_endpoint_to_deallocate) {
74 safe_edge_endpoint_deallocation(*edge_endpoint_to_deallocate);
76 dv_itr_vc_adj.clear();
80template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
82 return vertices.size();
85template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
88 if ( graphdom::graph<VertexType>::get_owner_graph(vertex) !=
this ) {
89 throw std::runtime_error(
"Error");
91 const auto*
const vertex_container_ptr =
static_cast< const vertex_container*
>( graphdom::graph< VertexType >::get_vertex_container( vertex ) );
92 return vertex_container_ptr->vertex_label;
95template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
98 if ( graphdom::graph<VertexType>::get_owner_graph( edge ) !=
this ) {
99 throw std::runtime_error(
"Error");
103 static_cast<edge_endpoint*
>(
110template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
113 if ( graphdom::graph<VertexType>::get_owner_graph(vertex) ==
this ) {
114 const auto vertex_container_to_erase_ptr = graphdom::graph<VertexType>::get_vertex_container(vertex);
115 if ( vertex_container_to_erase_ptr !=
nullptr ) {
116 auto vertex_container_to_erase_found_vertices_itr = vertices.end();
117 for (
auto digraph_vertices_itr = vertices.begin(); digraph_vertices_itr != vertices.end(); ++digraph_vertices_itr) {
118 auto& digraph_vertices_itr_vertex_container = *digraph_vertices_itr;
119 if ( &digraph_vertices_itr_vertex_container == vertex_container_to_erase_ptr ) {
120 vertex_container_to_erase_found_vertices_itr = digraph_vertices_itr;
122 auto& digraph_vertices_itr_vertex_container_adj = digraph_vertices_itr_vertex_container.adj;
123 auto itr_vertex_container_adj_found_result_itr = digraph_vertices_itr_vertex_container_adj.find(vertex_container_to_erase_ptr);
124 if (itr_vertex_container_adj_found_result_itr != digraph_vertices_itr_vertex_container_adj.end()) {
125 safe_edge_endpoint_deallocation(*itr_vertex_container_adj_found_result_itr);
126 digraph_vertices_itr_vertex_container_adj.erase(itr_vertex_container_adj_found_result_itr);
129 if ( vertex_container_to_erase_found_vertices_itr != vertices.end() ) {
130 auto& vertex_container_to_erase = *vertex_container_to_erase_found_vertices_itr;
131 auto& vertex_container_to_erase_adj = vertex_container_to_erase.adj;
132 for(
auto vertex_container_to_erase_adj_itr = vertex_container_to_erase_adj.begin();
133 vertex_container_to_erase_adj_itr != vertex_container_to_erase_adj.end();) {
134 safe_edge_endpoint_deallocation(*vertex_container_to_erase_adj_itr);
135 vertex_container_to_erase_adj_itr = vertex_container_to_erase_adj.erase(vertex_container_to_erase_adj_itr);
137 vertices.erase(vertex_container_to_erase_found_vertices_itr);
146template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
147typename graphdom::graph<VertexType>::adj_list_iterator
150 if ( graphdom::graph<VertexType>::get_owner_graph(edge_itr) !=
this ) {
151 throw std::runtime_error(
"Error");
153 auto const edge_itr_begin_point =
static_cast< const vertex_container*
>( graphdom::graph<VertexType>::get_begin_point(edge_itr) );
155 auto const edge_itr_endpoint = *edge_itr_inner_iterator;
156 safe_edge_endpoint_deallocation(edge_itr_endpoint);
159 edge_itr_begin_point,
161 ( edge_itr_begin_point->adj ).erase( edge_itr_inner_iterator )
165template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
168 if ( graphdom::graph<VertexType>::get_owner_graph(vertex) !=
this ) {
169 throw std::runtime_error(
"Error");
171 const auto*
const vertex_container_ptr =
static_cast< const vertex_container*
>( graphdom::graph< VertexType >::get_vertex_container( vertex ) );
172 return const_cast< VertexLabelType&
>( (*vertex_container_ptr).vertex_label );
175template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
176std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>
178 const VertexType& v_core,
const VertexLabelType& vertex_label) {
179 auto inner_insertion_result = vertices.emplace(
183 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
184 graphdom::graph<VertexType>::vertex_handle_factory(
186 *(inner_insertion_result.first),
189 inner_insertion_result.second
193template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
194std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>
196const VertexType& v_core, VertexLabelType&& vertex_label) {
197 const auto lower_bound = vertices.lower_bound(v_core);
198 if ( lower_bound == vertices.cend() ) {
199 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
200 graphdom::graph<VertexType>::vertex_handle_factory(
202 *( vertices.emplace_hint(lower_bound, v_core, std::move(vertex_label)) ),
208 if ( ( vertices.key_comp() )( v_core, *lower_bound ) ) {
209 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
210 graphdom::graph<VertexType>::vertex_handle_factory(
212 *( vertices.emplace_hint(lower_bound, v_core, std::move(vertex_label)) ),
218 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
219 graphdom::graph<VertexType>::vertex_handle_factory(
228template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
229std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>
231VertexType&& v_core,
const VertexLabelType& vertex_label) {
232 const auto lower_bound = vertices.lower_bound(v_core);
233 if ( lower_bound == vertices.cend() ) {
234 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
235 graphdom::graph<VertexType>::vertex_handle_factory(
237 *( vertices.emplace_hint(lower_bound, std::move(v_core), vertex_label) ),
243 if ( ( vertices.key_comp() )( v_core, *lower_bound ) ) {
244 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
245 graphdom::graph<VertexType>::vertex_handle_factory(
247 *( vertices.emplace_hint(lower_bound, std::move(v_core), vertex_label) ),
253 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
254 graphdom::graph<VertexType>::vertex_handle_factory(
263template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
264std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>
266VertexType&& v_core, VertexLabelType&& vertex_label) {
267 const auto lower_bound = vertices.lower_bound(v_core);
268 if ( lower_bound == vertices.cend() ) {
269 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
270 graphdom::graph<VertexType>::vertex_handle_factory(
272 *( vertices.emplace_hint(lower_bound, std::move(v_core), std::move(vertex_label)) ),
278 if ( ( vertices.key_comp() )( v_core, *lower_bound ) ) {
279 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
280 graphdom::graph<VertexType>::vertex_handle_factory(
282 *( vertices.emplace_hint(lower_bound, std::move(v_core), std::move(vertex_label)) ),
288 return std::pair<typename graphdom::graph<VertexType>::vertex_handle,
bool>(
289 graphdom::graph<VertexType>::vertex_handle_factory(
298template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
301 if ( graphdom::graph<VertexType>::get_owner_graph( edge ) !=
this ) {
302 throw std::runtime_error(
"Error");
306 static_cast<edge_endpoint*
>(
313template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
317 const EdgeLabelType& edge_label) {
319 graphdom::graph<VertexType>::get_owner_graph( tail ) !=
this ||
320 graphdom::graph<VertexType>::get_owner_graph( head ) !=
this
322 throw std::runtime_error(
"Error");
324 auto const begin_point_vertex_container =
static_cast< const vertex_container*
>( graphdom::graph<VertexType>::get_vertex_container( tail ) );
325 auto const end_point_vertex_container = graphdom::graph<VertexType>::get_vertex_container( head );
326 if ( begin_point_vertex_container ==
nullptr || end_point_vertex_container ==
nullptr ) {
327 throw std::runtime_error(
"Error");
329 std::unique_ptr< edge_endpoint > edge_endpoint_to_insert(
new edge_endpoint( end_point_vertex_container , edge_label ) );
330 const auto inner_insertion_result = ( ( begin_point_vertex_container->adj ).insert( edge_endpoint_to_insert.get() ) ).second;
331 if ( inner_insertion_result ) {
332 edge_endpoint_to_insert.release();
336template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
340 EdgeLabelType&& edge_label) {
342 graphdom::graph<VertexType>::get_owner_graph( tail ) !=
this ||
343 graphdom::graph<VertexType>::get_owner_graph( head ) !=
this
345 throw std::runtime_error(
"Error");
347 auto const begin_point_vertex_container =
static_cast< const vertex_container*
>( graphdom::graph<VertexType>::get_vertex_container( tail ) );
348 auto const end_point_vertex_container = graphdom::graph<VertexType>::get_vertex_container( head );
349 if ( begin_point_vertex_container ==
nullptr || end_point_vertex_container ==
nullptr ) {
350 throw std::runtime_error(
"Error");
352 const auto lower_bound = ( begin_point_vertex_container->adj ).lower_bound( end_point_vertex_container );
353 if ( lower_bound == ( begin_point_vertex_container->adj ).cend() ) {
354 ( begin_point_vertex_container->adj ).emplace_hint( lower_bound,
new edge_endpoint( end_point_vertex_container , std::move(edge_label) ) );
357 if ( ( ( begin_point_vertex_container->adj ).key_comp() )( end_point_vertex_container, *lower_bound ) ) {
358 ( begin_point_vertex_container->adj ).emplace_hint( lower_bound,
new edge_endpoint( end_point_vertex_container , std::move(edge_label) ) );
370template<
typename VertexType,
typename VertexLabelType,
typename EdgeLabelType,
typename Compare,
typename VertexLabellerType,
typename EdgeLabellerType>
373 typename graphdom::graph<VertexType>::template edge_endpoint<VertexContainerPointerType>* ee_ptr) {
374 delete static_cast<edge_endpoint*
>(ee_ptr);
Definition full_labeled_set_digraph.h:37
const VertexLabelType & get_vertex_label(const typename graph< VertexType >::vertex_const_handle &vertex) const override
Definition full_labeled_set_digraph.h:86
void erase_vertex(const typename graphdom::graph< VertexType >::vertex_const_handle &vertex) override
Removes the vertex identified by vertex.
Definition full_labeled_set_digraph.h:111
std::size_t order() const override
Returns the order of *this, i.e. the number of vertices inside the graph.
Definition full_labeled_set_digraph.h:81
void insert_edge(const typename graph< VertexType >::vertex_const_handle &tail, const typename graph< VertexType >::vertex_const_handle &head, const EdgeLabelType &edge_label) override
Definition full_labeled_set_digraph.h:314
graphdom::graph< VertexType >::adj_list_iterator erase_edge(const typename graph< VertexType >::adj_list_const_iterator &) override
Definition full_labeled_set_digraph.h:148
std::pair< typename graph< VertexType >::vertex_handle, bool > insert_vertex(const VertexType &v_core, const VertexLabelType &vertex_label) override
Definition full_labeled_set_digraph.h:177
const EdgeLabelType & get_edge_label(const typename graph< VertexType >::adj_list_const_iterator &) const override
Definition full_labeled_set_digraph.h:96
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 graph created using this library is an instance of a concrete class publicly derived,...
Definition graph.h:43
Every set graph created using this library is an instance of a concrete class publicly derived,...
Definition set_graph.h:18
@ directed
This enum value means directed edge.
Definition graph.h:23