Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

NodeColoringBergerRompel.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>
41 
42 namespace ogdf {
43 
50 public:
54  enum class BruteForceProcedure {
55  trivialColoring,
56  sequentialColoringSimple,
57  sequentialColoringDegree,
58  johnsonColoring,
59  wigdersonColoring,
60  pooled,
61  };
62 
69  : m_simpleColoring()
70  , m_sequentialColoring()
71  , m_johnsonColoring()
72  , m_wigdersonColoring()
73  , m_searchProcedure(SearchProcedure::wigdersonSearch)
74  , m_bruteForceProcedure(BruteForceProcedure::pooled)
75  , m_alpha(0.4) { }
76 
82  inline void setSearchProcedure(SearchProcedure searchProcedure) {
83  m_searchProcedure = searchProcedure;
84  }
85 
90  inline void setBruteForceProcedure(BruteForceProcedure bruteForceProcedure) {
91  m_bruteForceProcedure = bruteForceProcedure;
92  }
93 
100  inline void setAlpha(double alpha) {
101  OGDF_ASSERT(alpha > 0.1);
102  m_alpha = alpha;
103  }
104 
105  virtual NodeColor call(const Graph& graph, NodeArray<NodeColor>& colors,
106  NodeColor start = 0) override;
107 
108 private:
113  SearchProcedure m_searchProcedure;
115  double m_alpha;
116 
117  bool bergerRompelParameterized(const Graph& graph, NodeArray<NodeColor>& colors,
118  NodeColor& color, int k, double alpha);
119 
132  const Graph& graph, NodeArray<NodeColor>& colors, double alpha)
133  : m_coloring(coloringBergerRompel), m_graph(graph), m_colors(colors), m_alpha(alpha) { }
134 
135  bool step(int k) override {
136  NodeColor start = NodeColor(1);
137  return m_coloring.bergerRompelParameterized(m_graph, m_colors, start, k, m_alpha);
138  }
139 
141  const Graph& m_graph;
143  double m_alpha;
144  };
145 };
146 }
ogdf::NodeColoringBergerRompel::setBruteForceProcedure
void setBruteForceProcedure(BruteForceProcedure bruteForceProcedure)
Sets the brute force procedure.
Definition: NodeColoringBergerRompel.h:90
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::NodeColoringBergerRompel::m_bruteForceProcedure
BruteForceProcedure m_bruteForceProcedure
Definition: NodeColoringBergerRompel.h:114
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel::m_alpha
double m_alpha
Definition: NodeColoringBergerRompel.h:143
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel::m_coloring
NodeColoringBergerRompel & m_coloring
Definition: NodeColoringBergerRompel.h:140
Graph.h
Includes declaration of graph class.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel::m_colors
NodeArray< NodeColor > & m_colors
Definition: NodeColoringBergerRompel.h:142
ogdf::NodeColoringBergerRompel::m_wigdersonColoring
NodeColoringWigderson m_wigdersonColoring
Definition: NodeColoringBergerRompel.h:112
NodeColoringJohnson.h
Applies the node coloring approximation specified by Johnson.
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel
Wraps the parameterized Berger&Rompel algorithm.
Definition: NodeColoringBergerRompel.h:123
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel::step
bool step(int k) override
Performs a step in the search procedure.
Definition: NodeColoringBergerRompel.h:135
ogdf::NodeColoringWigderson
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringWigderson.h:53
ogdf::NodeColoringSimple
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringSimple.h:44
ogdf::colors
const std::array< Color, 63 > colors
An array of 63 different colors to cycle through.
ogdf::NodeColoringBergerRompel::m_sequentialColoring
NodeColoringSequential m_sequentialColoring
Definition: NodeColoringBergerRompel.h:110
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel::m_graph
const Graph & m_graph
Definition: NodeColoringBergerRompel.h:141
ogdf::NodeColoringModule
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringModule.h:48
ogdf::NodeColoringSequential
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringSequential.h:48
ogdf::NodeColoringBergerRompel::setAlpha
void setAlpha(double alpha)
Sets the parameter alpha which controls the accuracy of the algorithm.
Definition: NodeColoringBergerRompel.h:100
ogdf::NodeColoringBergerRompel::m_alpha
double m_alpha
Definition: NodeColoringBergerRompel.h:115
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
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:869
NodeColoringModule.h
Template of base class of node coloring algorithms.
ogdf::NodeColoringBergerRompel::m_searchProcedure
SearchProcedure m_searchProcedure
Definition: NodeColoringBergerRompel.h:113
ogdf::NodeColoringJohnson
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringJohnson.h:45
ogdf::NodeColoringBergerRompel::SearchWrapperBergerRompel::SearchWrapperBergerRompel
SearchWrapperBergerRompel(NodeColoringBergerRompel &coloringBergerRompel, const Graph &graph, NodeArray< NodeColor > &colors, double alpha)
Creates the wrapper.
Definition: NodeColoringBergerRompel.h:131
ogdf::NodeColoringBergerRompel::m_simpleColoring
NodeColoringSimple m_simpleColoring
Definition: NodeColoringBergerRompel.h:109
ogdf::NodeColoringBergerRompel::m_johnsonColoring
NodeColoringJohnson m_johnsonColoring
Definition: NodeColoringBergerRompel.h:111
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::NodeColoringModule::NodeColor
unsigned int NodeColor
Data type of the node colors.
Definition: NodeColoringModule.h:53
NodeColoringSequential.h
Applies the sequential coloring algorithm to a given graph.
ogdf::NodeColoringBergerRompel::NodeColoringBergerRompel
NodeColoringBergerRompel()
The constructor.
Definition: NodeColoringBergerRompel.h:68
ogdf::NodeColoringBergerRompel::setSearchProcedure
void setSearchProcedure(SearchProcedure searchProcedure)
Sets the search procedure to find the smallest possible parameter k such as the graph is k-colorable.
Definition: NodeColoringBergerRompel.h:82
ogdf::NodeColoringBergerRompel
Approximation algorithms for the node coloring problem in graphs.
Definition: NodeColoringBergerRompel.h:49
ogdf::NodeColoringBergerRompel::BruteForceProcedure
BruteForceProcedure
Declares the procedure dealing with the brute force coloring.
Definition: NodeColoringBergerRompel.h:54
NodeColoringWigderson.h
Applies the node coloring approximation specified by Wigderson.
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:196