Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

NodeColoringWigderson.h
Go to the documentation of this file.
1 
32 #pragma once
33 
37 
38 namespace ogdf {
39 
48 public:
52  enum class MaxDegreeProcedure {
53  smallestIndex,
54  minDegreeRecursion,
55  maxDegreeRecursion,
56  minDegreeOriginal,
57  maxDegreeOriginal,
58  minDegreeNeighbors,
59  maxDegreeNeighbors,
60  };
61 
66  trivialColoring,
67  sequentialColoringSimple,
68  sequentialColoringDegree,
69  pooled,
70  };
71 
75  enum class BruteForceProcedure {
76  sequentialColoringSimple,
77  sequentialColoringDegree,
78  pooled,
79  };
80 
87  : m_coloringSimple()
88  , m_sequentialColoring()
89  , m_searchProcedure(SearchProcedure::wigdersonSearch)
90  , m_maxDegreeProcedure(MaxDegreeProcedure::smallestIndex)
91  , m_recursionAnchorProcedure(RecursionAnchorProcedure::pooled)
92  , m_bruteForceProcedure(BruteForceProcedure::pooled) { }
93 
99  inline void setSearchProcedure(SearchProcedure searchProcedure) {
100  m_searchProcedure = searchProcedure;
101  }
102 
107  inline void setMaxDegreeProcedure(MaxDegreeProcedure maxDegreeProcedure) {
108  m_maxDegreeProcedure = maxDegreeProcedure;
109  }
110 
115  inline void setRecursionAnchorProcedure(RecursionAnchorProcedure recursionAnchorProcedure) {
116  m_recursionAnchorProcedure = recursionAnchorProcedure;
117  }
118 
123  inline void setBruteForceProcedure(BruteForceProcedure bruteForceProcedure) {
124  m_bruteForceProcedure = bruteForceProcedure;
125  }
126 
127  virtual NodeColor call(const Graph& graph, NodeArray<NodeColor>& colors,
128  NodeColor start = 0) override;
129 
130 private:
133  SearchProcedure m_searchProcedure;
137 
146  inline int wigdersonFunction(int n, int k) const {
147  OGDF_ASSERT(n >= 0);
148  OGDF_ASSERT(k >= 1);
149  return std::ceil(std::pow(n, 1.0 - (1.0 / (static_cast<double>(k) - 1.0))));
150  }
151 
161  bool wigdersonCaller(const Graph& graph, NodeArray<NodeColor>& colors, NodeColor& color, int k);
162 
173  bool wigdersonRecursive(const Graph& graph, NodeArray<NodeColor>& colors, NodeColor& color,
174  int k, NodeArray<int>& degreesOriginal, List<node>& nodesToBeColored);
175 
186  SearchWrapperWigderson(NodeColoringWigderson& coloringWigderson, const Graph& graph,
188  : m_coloring(coloringWigderson), m_graph(graph), m_colors(colors) { }
189 
190  bool step(int k) override {
191  NodeColor start = NodeColor(1);
192  return m_coloring.wigdersonCaller(m_graph, m_colors, start, k);
193  }
194 
196  const Graph& m_graph;
198  };
199 };
200 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::NodeColoringWigderson::m_searchProcedure
SearchProcedure m_searchProcedure
Definition: NodeColoringWigderson.h:133
ogdf::NodeColoringWigderson::RecursionAnchorProcedure
RecursionAnchorProcedure
Declares the procedure dealing with the recursion anchor coloring.
Definition: NodeColoringWigderson.h:65
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::NodeColoringWigderson::setMaxDegreeProcedure
void setMaxDegreeProcedure(MaxDegreeProcedure maxDegreeProcedure)
Sets the procedure of finding maximum degree nodes.
Definition: NodeColoringWigderson.h:107
ogdf::NodeColoringWigderson::setBruteForceProcedure
void setBruteForceProcedure(BruteForceProcedure bruteForceProcedure)
Sets the brute force procedure.
Definition: NodeColoringWigderson.h:123
ogdf::NodeColoringWigderson::MaxDegreeProcedure
MaxDegreeProcedure
Declares procedure to find the maximum degree nodes.
Definition: NodeColoringWigderson.h:52
ogdf::NodeColoringWigderson::SearchWrapperWigderson::m_coloring
NodeColoringWigderson & m_coloring
Definition: NodeColoringWigderson.h:195
ogdf::NodeColoringWigderson
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringWigderson.h:47
ogdf::NodeColoringSimple
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringSimple.h:42
ogdf::colors
const std::array< Color, 63 > colors
An array of 63 different colors to cycle through.
ogdf::NodeColoringWigderson::m_coloringSimple
NodeColoringSimple m_coloringSimple
Definition: NodeColoringWigderson.h:131
ogdf::NodeColoringWigderson::SearchWrapperWigderson::m_colors
NodeArray< NodeColor > & m_colors
Definition: NodeColoringWigderson.h:197
ogdf::NodeColoringWigderson::setSearchProcedure
void setSearchProcedure(SearchProcedure searchProcedure)
Sets the search procedure to find the smallest possible parameter k such as the graph is k-colorable.
Definition: NodeColoringWigderson.h:99
ogdf::NodeColoringModule
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringModule.h:44
ogdf::NodeColoringSequential
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringSequential.h:43
ogdf::NodeColoringWigderson::m_recursionAnchorProcedure
RecursionAnchorProcedure m_recursionAnchorProcedure
Definition: NodeColoringWigderson.h:135
ogdf::NodeColoringWigderson::m_bruteForceProcedure
BruteForceProcedure m_bruteForceProcedure
Definition: NodeColoringWigderson.h:136
ogdf::NodeColoringWigderson::SearchWrapperWigderson::SearchWrapperWigderson
SearchWrapperWigderson(NodeColoringWigderson &coloringWigderson, const Graph &graph, NodeArray< NodeColor > &colors)
Creates the wrapper.
Definition: NodeColoringWigderson.h:186
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
NodeColoringSimple.h
Trivial node coloring which assigns every node a different color.
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
NodeColoringModule.h
Template of base class of node coloring algorithms.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::NodeColoringWigderson::SearchWrapperWigderson
Wraps the Wigderson recursive algorithm.
Definition: NodeColoringWigderson.h:179
ogdf::NodeColoringModule::NodeColor
unsigned int NodeColor
Data type of the node colors.
Definition: NodeColoringModule.h:49
ogdf::NodeColoringWigderson::SearchWrapperWigderson::step
bool step(int k) override
Performs a step in the search procedure.
Definition: NodeColoringWigderson.h:190
NodeColoringSequential.h
Applies the sequential coloring algorithm to a given graph.
ogdf::NodeColoringWigderson::wigdersonFunction
int wigdersonFunction(int n, int k) const
Calculates the function for the graph maximum degree specified by Wigderson.
Definition: NodeColoringWigderson.h:146
ogdf::NodeColoringWigderson::m_maxDegreeProcedure
MaxDegreeProcedure m_maxDegreeProcedure
Definition: NodeColoringWigderson.h:134
ogdf::NodeColoringWigderson::m_sequentialColoring
NodeColoringSequential m_sequentialColoring
Definition: NodeColoringWigderson.h:132
ogdf::NodeColoringWigderson::BruteForceProcedure
BruteForceProcedure
Declares the procedure dealing with the brute force coloring.
Definition: NodeColoringWigderson.h:75
ogdf::NodeColoringWigderson::SearchWrapperWigderson::m_graph
const Graph & m_graph
Definition: NodeColoringWigderson.h:196
ogdf::NodeColoringWigderson::NodeColoringWigderson
NodeColoringWigderson()
The constructor.
Definition: NodeColoringWigderson.h:86
ogdf::NodeColoringWigderson::setRecursionAnchorProcedure
void setRecursionAnchorProcedure(RecursionAnchorProcedure recursionAnchorProcedure)
Sets the recursion anchor procedure.
Definition: NodeColoringWigderson.h:115
ogdf::NodeColoringModule::SearchWrapper
Wraps the search for the minimum parameter k so that the same code can be reused for all algorithms.
Definition: NodeColoringModule.h:192