Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
bidirectional_boost.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022: G-CSC, Goethe University Frankfurt
3 * Author: Felix Salfelder, 2022
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef UG4_GRAPH_INTERFACE_BIDIR_BOOST_H
34#define UG4_GRAPH_INTERFACE_BIDIR_BOOST_H
35
36#include "bidirectional.h"
37
38namespace boost{
39
41 : adjacency_graph_tag, bidirectional_graph_tag, vertex_list_graph_tag {};
42
43template <class T>
44struct graph_traits<ug::BidirectionalMatrix<T>>{
45 typedef typename T::value_type value_type;
46 typedef int vertex_descriptor;
48 typedef bidirectional_tag directed_category;
50 typedef disallow_parallel_edge_tag edge_parallel_category;
51 typedef counting_iterator<size_t> vertex_iterator;
55 typedef int degree_size_type;
56 typedef int vertices_size_type;
57};
58
59template<class T>
60std::pair<counting_iterator<size_t>, counting_iterator<size_t> > vertices(
62{
63 counting_iterator<size_t> b(0);
64 counting_iterator<size_t> e(M.num_rows());
65
66 return std::make_pair(b,e);
67}
68
69template<class T>
71{
72 return M.num_rows();
73}
74
75template<class T>
77{
78 return M.out_degree(v);
79}
80
81template<class T>
83{
84 return M.in_degree(v);
85}
86
87template<class T>
89{ untested();
90 return 2*M.degree(v);
91}
92
93template<class T>
95{
96 return e.source();
97}
98
99template<class T>
101{
102 return e.target();
103}
104
105template<class T>
106std::pair<typename graph_traits<T>::adjacency_iterator,
107 typename graph_traits<T>::adjacency_iterator>
109{
110 typedef typename graph_traits<T>::adjacency_iterator a;
111
112 typename T::const_row_iterator b = M.begin_row(v);
113 typename T::const_row_iterator e = M.end_row(v);
114
115 return std::make_pair(a(&b, &e), a(&e, &e));
116}
117
118template<class T>
119std::pair<typename graph_traits<T>::adjacency_iterator,
120 typename graph_traits<T>::adjacency_iterator>
122{
123 typedef typename T::value_type value_type;
124 typedef typename graph_traits<ug::SparseMatrix<value_type>>::adjacency_iterator a;
125
126 typename T::const_row_iterator b = M.begin_col(v);
127 typename T::const_row_iterator e = M.end_col(v);
128
129 return std::make_pair(a(&b, &e), a(&e, &e));
130}
131
132
133template<class T>
134inline std::pair<SM_out_edge_iterator<typename T::value_type>,
135 SM_out_edge_iterator<typename T::value_type>>
137{
138 typedef typename T::value_type value_type;
140 auto a = adjacent_vertices(v, g);
141 return std::make_pair(Iter(a.first, v), Iter(a.second, v));
142}
143
144template<class T>
145inline std::pair<SM_out_edge_iterator<typename T::value_type, false>,
146 SM_out_edge_iterator<typename T::value_type, false>>
148{
149 typedef typename T::value_type value_type;
151 auto a = coadjacent_vertices(v, g);
152 return std::make_pair(Iter(a.first, v), Iter(a.second, v));
153}
154
155template<class T>
156inline SM_edge_weight_map<typename T::value_type, ug::BidirectionalMatrix<T>>
157get(edge_weight_t, ug::BidirectionalMatrix<T> const & g) {
158 typedef typename T::value_type value_type;
160}
161
162template<class T>
163struct property_map<ug::BidirectionalMatrix<ug::SparseMatrix<T>>, vertex_index_t>{
166};
167
168template<class T>
169inline typename property_map<ug::BidirectionalMatrix<ug::SparseMatrix<T>>, vertex_index_t>::const_type
170get(vertex_index_t, ug::BidirectionalMatrix<T> const& m)
171{
173}
174
175} // boost
176
177#endif // guard
Definition sparsematrix_boost.h:37
Definition sparsematrix_boost.h:424
Definition sparsematrix_boost.h:152
int target() const
Definition sparsematrix_boost.h:169
int source() const
Definition sparsematrix_boost.h:166
Definition sparsematrix_boost.h:211
Definition sparsematrix_boost.h:350
Definition bidirectional.h:47
int in_degree(int v) const
Definition bidirectional.h:106
const_row_iterator end_row(int row) const
Definition bidirectional.h:126
const_row_iterator begin_col(int col) const
Definition bidirectional.h:135
const_row_iterator begin_row(int row) const
Definition bidirectional.h:118
int out_degree(int v) const
Definition bidirectional.h:97
const_row_iterator end_col(int col) const
Definition bidirectional.h:142
int num_rows() const
Definition bidirectional.h:83
int degree(int v) const
Definition bidirectional.h:114
#define untested()
Definition lua_table_handle.cpp:15
Definition boost_serialization_routines.h:49
std::pair< typename graph_traits< T >::adjacency_iterator, typename graph_traits< T >::adjacency_iterator > adjacent_vertices(size_t v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:108
std::pair< SM_out_edge_iterator< typename T::value_type >, SM_out_edge_iterator< typename T::value_type > > out_edges(size_t v, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:136
std::pair< typename graph_traits< T >::adjacency_iterator, typename graph_traits< T >::adjacency_iterator > coadjacent_vertices(size_t v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:121
int out_degree(int v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:76
int degree(int v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:88
std::pair< SM_out_edge_iterator< typename T::value_type, false >, SM_out_edge_iterator< typename T::value_type, false > > in_edges(size_t v, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:147
int in_degree(int v, ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:82
std::pair< counting_iterator< size_t >, counting_iterator< size_t > > vertices(ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:60
int num_vertices(ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:70
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:157
size_t target(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &m)
Definition bidirectional_boost.h:100
size_t source(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &)
Definition bidirectional_boost.h:94
the ug namespace
T value_type
Definition sparsematrix_interface.h:2
Definition bidirectional_boost.h:41
disallow_parallel_edge_tag edge_parallel_category
Definition bidirectional_boost.h:50
SM_out_edge_iterator< value_type, false > in_edge_iterator
Definition bidirectional_boost.h:53
SM_adjacency_iterator< value_type > adjacency_iterator
Definition bidirectional_boost.h:54
int vertices_size_type
Definition bidirectional_boost.h:56
counting_iterator< size_t > vertex_iterator
Definition bidirectional_boost.h:51
bidirectional_tag directed_category
Definition bidirectional_boost.h:48
int degree_size_type
Definition bidirectional_boost.h:55
SM_edge< value_type > edge_descriptor
Definition bidirectional_boost.h:47
BS_traversal_tag traversal_category
Definition bidirectional_boost.h:49
SM_out_edge_iterator< value_type, true > out_edge_iterator
Definition bidirectional_boost.h:52
int vertex_descriptor
Definition bidirectional_boost.h:46
T::value_type value_type
Definition bidirectional_boost.h:45
sparse_matrix_index_map< T > type
Definition bidirectional_boost.h:164