GraphDom
Loading...
Searching...
No Matches
multiset_graph_vertex_handle.h
1/*
2 * Copyright 2026 Michele Comparini
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef GRAPHDOM_MULTISET_GRAPH_VERTEX_HANDLE_IMPL_H
8#define GRAPHDOM_MULTISET_GRAPH_VERTEX_HANDLE_IMPL_H
9
10#include <stdexcept>
11
12#include "../../graph.h"
13#include "../vertex_base_handle.h"
14#include "../vertex_handle.h"
15#include "../../multiset_graph.h"
16#include "../multiset_graph_vertex_handle.h"
17
18template <typename VertexType>
19graphdom::multiset_graph<VertexType>::vertex_handle::vertex_handle(const graphdom::multiset_graph<VertexType>::vertex_handle& other) :
20graphdom::graph<VertexType>::template vertex_base_handle< typename graphdom::graph<VertexType>::vertex_container* >( other ) {}
21
22template <typename VertexType>
23graphdom::multiset_graph<VertexType>::vertex_handle::vertex_handle(const typename graph<VertexType>::vertex_handle& other) :
24graphdom::graph<VertexType>::template vertex_base_handle< typename graphdom::graph<VertexType>::vertex_container* >(
25 other.vertex_container_owner_graph_pointer,
26 other.vertex_container_owner_graph_edges_type,
27 nullptr
28) {
29 if ( dynamic_cast< const graphdom::multiset_graph<VertexType>* >( this->vertex_container_owner_graph_pointer ) == nullptr ) {
30 throw std::runtime_error("Attempt to convert a \"graphdom::graph<VertexType>::vertex_handle\", which identifies a vertex belonging to a \"graphdom::set_graph<VertexType>\", to a \"graphdom::multiset_graph<VertexType>::vertex_handle\""); //TODO: write a better message
31 }
32 this->vertex_container_pointer = const_cast< typename graphdom::graph<VertexType>::vertex_container* >( other.vertex_container_pointer );
33}
34
35template<typename VertexType>
36typename graphdom::multiset_graph<VertexType>::vertex_handle& graphdom::multiset_graph<VertexType>::vertex_handle::operator=(const vertex_handle& other) {
37 if ( this != &other ) {
38 this->vertex_container_owner_graph_pointer = other.vertex_container_owner_graph_pointer;
39 this->vertex_container_owner_graph_edges_type = other.vertex_container_owner_graph_edges_type;
40 this->vertex_container_pointer = other.vertex_container_pointer;
41 }
42 return (*this);
43}
44
45template<typename VertexType>
46typename graphdom::multiset_graph<VertexType>::adj_list graphdom::multiset_graph<VertexType>::vertex_handle::adj_list() const {
48 this->vertex_container_owner_graph_pointer,
49 this->vertex_container_owner_graph_edges_type,
50 this->vertex_container_pointer
51 );
52}
53
54template<typename VertexType>
55typename graphdom::multiset_graph<VertexType>::adj_list graphdom::multiset_graph<VertexType>::vertex_handle::adj_list(const edge_type edge_type) const {
56 return typename graphdom::multiset_graph<VertexType>::adj_list(
57 this->vertex_container_owner_graph_pointer,
58 this->vertex_container_owner_graph_edges_type,
59 this->vertex_container_pointer,
60 ( edge_type == undirected ) ?
61 graphdom::graph<VertexType>::edges_type_selection_type::undirected_edges :
62 graphdom::graph<VertexType>::edges_type_selection_type::directed_edges
63 );
64}
65
66template<typename VertexType>
67typename graphdom::graph<VertexType>::const_adj_list graphdom::multiset_graph<VertexType>::vertex_handle::const_adj_list() const {
68 return typename graphdom::graph<VertexType>::const_adj_list(
69 this->vertex_container_owner_graph_pointer,
70 this->vertex_container_owner_graph_edges_type,
71 this->vertex_container_pointer
72 );
73}
74
75template<typename VertexType>
76typename graphdom::graph<VertexType>::const_adj_list graphdom::multiset_graph<VertexType>::vertex_handle::const_adj_list(const edge_type edge_type) const {
77 return typename graphdom::graph<VertexType>::const_adj_list(
78 this->vertex_container_owner_graph_pointer,
79 this->vertex_container_owner_graph_edges_type,
80 this->vertex_container_pointer,
81 ( edge_type == undirected ) ?
82 graphdom::graph<VertexType>::edges_type_selection_type::undirected_edges :
83 graphdom::graph<VertexType>::edges_type_selection_type::directed_edges
84 );
85}
86
87template<typename VertexType>
88graphdom::multiset_graph<VertexType>::vertex_handle::vertex_handle(
89 const graph<VertexType>* const vertex_container_owner_ptr,
90 typename graph<VertexType>::graph_edges_type vertex_container_owner_et,
91 typename graph<VertexType>::vertex_container* const vertex_container_ptr):
92graphdom::graph<VertexType>::template vertex_base_handle< typename graphdom::graph<VertexType>::vertex_container* >(
93 vertex_container_owner_ptr,
94 vertex_container_owner_et,
95 vertex_container_ptr
96){}
97
98#endif //GRAPHDOM_MULTISET_GRAPH_VERTEX_HANDLE_IMPL_H
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
Every valid instance of this class is a "container-like and non-owning" handle to a subset of the set...
Definition multiset_graph_adj_list.h:31
Every valid instance of this class can be used to identify a specific vertex of a multiset graph and ...
Definition multiset_graph_vertex_handle.h:31
Every multiset graph created using this library is an instance of a concrete class publicly derived,...
Definition multiset_graph.h:19
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