-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.h
42 lines (33 loc) · 1.19 KB
/
Node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Created by danny on 5/1/22.
//
#ifndef GRAPHCOLORING_NODE_H
#define GRAPHCOLORING_NODE_H
#include "Parameters.h"
#include "ColoredNode.h"
#include <utility>
#include <vector>
#include <string>
#include <iostream>
class Node{
public:
std::vector<unsigned long> adjacentNodeList;
Node(){}
explicit Node(std::vector<unsigned long> adjacentNodeList): adjacentNodeList(std::move(adjacentNodeList)){}
int generateValidColor(const std::vector<ColoredNode> &colored_node_list, const std::vector<int> &color_list) const{
std::vector<int> valid_color_list;
for(auto &color : color_list) {
if(this->hasValidColor(colored_node_list, color)) valid_color_list.push_back(color);
}
std::uniform_int_distribution<std::mt19937::result_type> dist6(0, valid_color_list.size()-1);
auto index = dist6(rng);
return valid_color_list[index];
}
bool hasValidColor(const std::vector<ColoredNode> &colored_node_list, const int &color) const{
for(const auto &index :this->adjacentNodeList){
if(colored_node_list[index].node_color == color) return false;
}
return true;
}
};
#endif //GRAPHCOLORING_NODE_H