16#ifndef dealii_graph_coloring_h
17# define dealii_graph_coloring_h
27# include <unordered_map>
28# include <unordered_set>
54 const std::vector<types::global_dof_index> &
indices1,
55 const std::vector<types::global_dof_index> &
indices2)
61 std::vector<types::global_dof_index>::const_iterator p =
indices1.begin(),
107 template <
typename Iterator>
108 std::vector<std::vector<Iterator>>
110 const Iterator &begin,
112 const std::function<std::vector<types::global_dof_index>(
116 unsigned int n_iterators = 0;
119 std::unordered_map<types::global_dof_index, std::vector<Iterator>>
121 for (Iterator
it = begin;
it != end; ++
it)
134 std::vector<std::vector<Iterator>>
zones(1,
135 std::vector<Iterator>(1, begin));
138 while (
used_it.size() != n_iterators)
144 zones.back().begin());
184 for (Iterator
it = begin;
it != end; ++
it)
187 zones.push_back(std::vector<Iterator>(1,
it));
220 template <
typename Iterator>
223 std::vector<Iterator> &partition,
224 const std::function<std::vector<types::global_dof_index>(
258 graph[i].push_back(
j);
259 graph[
j].push_back(i);
267 degrees_it = std::max_element(degrees.begin(), degrees.end());
274 std::vector<std::unordered_set<unsigned int>>
colors_used;
307 std::unordered_set<unsigned int> tmp;
325 template <
typename Iterator>
326 std::vector<std::vector<Iterator>>
330 std::vector<std::vector<Iterator>> coloring;
339 for (
unsigned int j = 0;
j < n_colors; ++
j)
364 std::unordered_set<unsigned int>
used_k;
369 std::vector<unsigned int>::iterator
it;
385 coloring[
pos].insert(
419 std::unordered_set<unsigned int>
used_k;
424 std::vector<unsigned int>::iterator
it;
538 template <
typename Iterator>
539 std::vector<std::vector<Iterator>>
541 const Iterator &begin,
543 const std::function<std::vector<types::global_dof_index>(
548 "GraphColoring is not prepared to deal with empty ranges!"));
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
Task< RT > new_task(const std::function< RT()> &function)
std::vector< std::vector< Iterator > > gather_colors(const std::vector< std::vector< std::vector< Iterator > > > &partition_coloring)
std::vector< std::vector< Iterator > > create_partitioning(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, const std::function< std::vector< types::global_dof_index >(const Iterator &)> &get_conflict_indices)
bool have_nonempty_intersection(const std::vector< types::global_dof_index > &indices1, const std::vector< types::global_dof_index > &indices2)
void make_dsatur_coloring(std::vector< Iterator > &partition, const std::function< std::vector< types::global_dof_index >(const Iterator &)> &get_conflict_indices, std::vector< std::vector< Iterator > > &partition_coloring)
std::vector< std::vector< Iterator > > make_graph_coloring(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, const std::function< std::vector< types::global_dof_index >(const std_cxx20::type_identity_t< Iterator > &)> &get_conflict_indices)
unsigned int color_sparsity_pattern(const SparsityPattern &sparsity_pattern, std::vector< unsigned int > &color_indices)
typename type_identity< T >::type type_identity_t