FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
coloring.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
11
12// includes, system
13#include <vector>
14
15namespace FEAT
16{
17 namespace Adjacency
18 {
19 // forward declaration
20 class Graph;
21
30 {
31 protected:
32 using IndexVector = std::vector < Index>;
33
36
46 IndexVector _coloring;
47
48 public:
49
55 Coloring();
56
74 Index num_nodes,
75 Index num_colors);
76
89 Index num_nodes,
90 Index* coloring);
91
103 Coloring(
104 Index num_colors,
105 const IndexVector& coloring);
106
116 explicit Coloring(const Graph& graph);
117
131 explicit Coloring(const Graph& graph, const Index* order);
132
134 Coloring(Coloring&& other) noexcept;
135
137 Coloring& operator=(Coloring&& other) noexcept;
138
140 virtual ~Coloring();
141
148 {
149 if (!_coloring.empty())
150 //return Coloring(Index(_coloring.size()), _coloring.data());
152 else
153 return Coloring();
154 }
155
163
169 {
170 return _coloring.data();
171 }
172
174 const Index* get_coloring() const
175 {
176 return _coloring.data();
177 }
178
185 {
186 return Index(_coloring.size());
187 }
188
190 auto size() const -> decltype(_coloring.size())
191 {
192 return _coloring.size();
193 }
194
201 {
202 return _num_colors - 1;
203 }
204
211 {
212 return _num_colors;
213 }
214
216 bool empty() const
217 {
218 return _coloring.empty();
219 }
220
223 {
224 ASSERT(i < _coloring.size());
225 return _coloring[i];
226 }
227
229 const Index& operator[](Index i) const
230 {
231 ASSERT(i < _coloring.size());
232 return _coloring[i];
233 }
234 }; // class Coloring
235 } // namespace Adjacency
236} // namespace FEAT
#define ASSERT(expr)
Debug-Assertion macro definition.
Definition: assertion.hpp:229
FEAT Kernel base header.
Coloring object implementation.
Definition: coloring.hpp:30
const Index & operator[](Index i) const
Returns the color for a node i.
Definition: coloring.hpp:229
Index & operator[](Index i)
Returns the color for a node i.
Definition: coloring.hpp:222
IndexVector _coloring
coloring vector
Definition: coloring.hpp:46
Graph create_partition_graph() const
Creates a color partition graph.
Definition: coloring.cpp:292
Index _num_colors
total number of colors used
Definition: coloring.hpp:35
Index get_num_nodes() const
Returns the total number of nodes.
Definition: coloring.hpp:184
virtual ~Coloring()
virtual destructor
Definition: coloring.cpp:289
bool empty() const
Checks whether the coloring is empty.
Definition: coloring.hpp:216
auto size() const -> decltype(_coloring.size())
Returns the total number of nodes.
Definition: coloring.hpp:190
Coloring & operator=(Coloring &&other) noexcept
move-assign operator
Definition: coloring.cpp:273
Index get_max_color() const
Returns the maximum color index.
Definition: coloring.hpp:200
Coloring()
Default constructor.
Definition: coloring.cpp:21
Index * get_coloring()
Returns the coloring array.
Definition: coloring.hpp:168
const Index * get_coloring() const
Returns the coloring array.
Definition: coloring.hpp:174
Index get_num_colors() const
Returns the number of colors.
Definition: coloring.hpp:210
Coloring clone() const
Clones this coloring.
Definition: coloring.hpp:147
Adjacency Graph implementation.
Definition: graph.hpp:34
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.