Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f66446

Browse files
Define macro for uncolored nodes
1 parent 556b378 commit 2f66446

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

‎include/colouring/graph_colouring.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ namespace graph_colouring {
4444
/**
4545
* Represents a colouring of a specific graph where
4646
* config[n] = c means that color c is associated to node with node id n
47-
* Use config[n] = std::numeric_limits<Color>::max() to mark node n as uncoloured
47+
* Use config[n] = UNCOLORED or config[n] = std::numeric_limits<Color>::max()
48+
* to mark node n as uncoloured
4849
*/
4950
typedef std::vector<Color> Colouring;
5051

@@ -111,7 +112,7 @@ namespace graph_colouring {
111112
inline size_t numberOfUncolouredNodes(const Colouring &s) {
112113
size_t count = 0;
113114
for (auto n : s) {
114-
if (n == std::numeric_limits<Color>::max()) {
115+
if (n == UNCOLORED) {
115116
count++;
116117
}
117118
}

‎include/data_structure/graph.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ typedef uint32_t NodeID;
3232
typedef uint32_t EdgeID;
3333
typedef uint32_t Color;
3434

35+
#define UNCOLORED std::numeric_limits<Color>::max()
36+
3537
struct Node {
3638
EdgeID firstEdge;
3739
};

‎src/colouring/graph_colouring.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace graph_colouring {
4444
std::vector<bool> usedColor(s.size());
4545
size_t color_count = 0;
4646
for (auto n : s) {
47-
if (n != std::numeric_limits<Color>::max() && !usedColor[n]) {
47+
if (n != UNCOLORED && !usedColor[n]) {
4848
usedColor[n] = true;
4949
color_count++;
5050
}
@@ -229,10 +229,10 @@ namespace graph_colouring {
229229

230230
//Represents the smallest number of colors used in a recently found colouring
231231
std::atomic<size_t> target_k(k);
232-
boost::lockfree::queue<WorkingPackage> workQueue(populationSize * strategies.size() * k);
232+
boost::lockfree::queue<WorkingPackage> workQueue(populationSize * strategies.size());
233233

234234
//It is possible that all threads report the same found k colouring
235-
boost::lockfree::queue<MasterPackage> masterQueue(k * threadCount);
235+
boost::lockfree::queue<MasterPackage> masterQueue(k);
236236

237237
//Used to signal the termination of the worker pool
238238
std::atomic<bool> terminated(false);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /