Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
NodeColoringWigderson.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/basic.h>
39
40#include <cmath>
41
42namespace ogdf {
43template<class E>
44class List;
45
54public:
58 enum class MaxDegreeProcedure {
59 smallestIndex,
60 minDegreeRecursion,
61 maxDegreeRecursion,
62 minDegreeOriginal,
63 maxDegreeOriginal,
64 minDegreeNeighbors,
65 maxDegreeNeighbors,
66 };
67
72 trivialColoring,
73 sequentialColoringSimple,
74 sequentialColoringDegree,
75 pooled,
76 };
77
82 sequentialColoringSimple,
83 sequentialColoringDegree,
84 pooled,
85 };
86
93 : m_coloringSimple()
94 , m_sequentialColoring()
95 , m_searchProcedure(SearchProcedure::wigdersonSearch)
96 , m_maxDegreeProcedure(MaxDegreeProcedure::smallestIndex)
97 , m_recursionAnchorProcedure(RecursionAnchorProcedure::pooled)
98 , m_bruteForceProcedure(BruteForceProcedure::pooled) { }
99
105 inline void setSearchProcedure(SearchProcedure searchProcedure) {
106 m_searchProcedure = searchProcedure;
107 }
108
113 inline void setMaxDegreeProcedure(MaxDegreeProcedure maxDegreeProcedure) {
114 m_maxDegreeProcedure = maxDegreeProcedure;
115 }
116
121 inline void setRecursionAnchorProcedure(RecursionAnchorProcedure recursionAnchorProcedure) {
122 m_recursionAnchorProcedure = recursionAnchorProcedure;
123 }
124
129 inline void setBruteForceProcedure(BruteForceProcedure bruteForceProcedure) {
130 m_bruteForceProcedure = bruteForceProcedure;
131 }
132
133 virtual NodeColor call(const Graph& graph, NodeArray<NodeColor>& colors,
134 NodeColor start = 0) override;
135
136private:
143
152 inline int wigdersonFunction(int n, int k) const {
153 OGDF_ASSERT(n >= 0);
154 OGDF_ASSERT(k >= 1);
155 return std::ceil(std::pow(n, 1.0 - (1.0 / (static_cast<double>(k) - 1.0))));
156 }
157
167 bool wigdersonCaller(const Graph& graph, NodeArray<NodeColor>& colors, NodeColor& color, int k);
168
179 bool wigdersonRecursive(const Graph& graph, NodeArray<NodeColor>& colors, NodeColor& color,
180 int k, NodeArray<int>& degreesOriginal, List<node>& nodesToBeColored);
181
192 SearchWrapperWigderson(NodeColoringWigderson& coloringWigderson, const Graph& graph,
193 NodeArray<NodeColor>& colors)
194 : m_coloring(coloringWigderson), m_graph(graph), m_colors(colors) { }
195
196 bool step(int k) override {
197 NodeColor start = NodeColor(1);
198 return m_coloring.wigdersonCaller(m_graph, m_colors, start, k);
199 }
200
204 };
205};
206}
Includes declaration of graph class.
Template of base class of node coloring algorithms.
Applies the sequential coloring algorithm to a given graph.
Trivial node coloring which assigns every node a different color.
Basic declarations, included by all source files.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Approximation algorithms for the node coloring problem in graphs.
unsigned int NodeColor
Data type of the node colors.
SearchProcedure
Declares the search procedures.
Approximation algorithms for the node coloring problem in graphs.
Approximation algorithms for the node coloring problem in graphs.
Approximation algorithms for the node coloring problem in graphs.
bool wigdersonCaller(const Graph &graph, NodeArray< NodeColor > &colors, NodeColor &color, int k)
Calls initially the recursive algorithm of Wigderson.
RecursionAnchorProcedure m_recursionAnchorProcedure
RecursionAnchorProcedure
Declares the procedure dealing with the recursion anchor coloring.
virtual NodeColor call(const Graph &graph, NodeArray< NodeColor > &colors, NodeColor start=0) override
The actual algorithm call.
void setMaxDegreeProcedure(MaxDegreeProcedure maxDegreeProcedure)
Sets the procedure of finding maximum degree nodes.
bool wigdersonRecursive(const Graph &graph, NodeArray< NodeColor > &colors, NodeColor &color, int k, NodeArray< int > &degreesOriginal, List< node > &nodesToBeColored)
Calls the recursive algorithm of Wigderson to find a feasible graph coloring.
void setBruteForceProcedure(BruteForceProcedure bruteForceProcedure)
Sets the brute force procedure.
MaxDegreeProcedure
Declares procedure to find the maximum degree nodes.
NodeColoringSequential m_sequentialColoring
void setRecursionAnchorProcedure(RecursionAnchorProcedure recursionAnchorProcedure)
Sets the recursion anchor procedure.
BruteForceProcedure
Declares the procedure dealing with the brute force coloring.
int wigdersonFunction(int n, int k) const
Calculates the function for the graph maximum degree specified by Wigderson.
BruteForceProcedure m_bruteForceProcedure
void setSearchProcedure(SearchProcedure searchProcedure)
Sets the search procedure to find the smallest possible parameter k such as the graph is k-colorable.
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.
const std::array< Color, 63 > colors
An array of 63 different colors to cycle through.
Wraps the search for the minimum parameter k so that the same code can be reused for all algorithms.
bool step(int k) override
Performs a step in the search procedure.
SearchWrapperWigderson(NodeColoringWigderson &coloringWigderson, const Graph &graph, NodeArray< NodeColor > &colors)
Creates the wrapper.