forked from Mystelven/picasso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelChecker.cc
More file actions
executable file
·77 lines (61 loc) · 2.15 KB
/
Copy pathModelChecker.cc
File metadata and controls
executable file
·77 lines (61 loc) · 2.15 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/****************************************************************************************
*
* This file is part of Graph Coloring
*
* Graph Coloring is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* Graph Coloring is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Graph Coloring.
* If not, see http://www.gnu.org/licenses/.
*
* Contributors:
* - Valentin Montmirail (valentin.montmirail@univ-cotedazur.fr)
***************************************************************************************************/
#include "ModelChecker.h"
void ModelChecker::toDOT_color(FILE* file)
{
fprintf(file,"graph g {\n");
vector<unsigned int> same_colors;
unsigned int color_index = -1;
for(unsigned int i = 0; i < graph->nbVertices; ++i)
{
if(std::find(same_colors.begin(), same_colors.end(), i) == same_colors.end()) {
color_index++;
fprintf(file,"%d [style=filled, fillcolor=%s]\n",i+1,colors[color_index].c_str());
}
for(unsigned int j = i+1; j < graph->nbVertices; ++j)
{
if(model[encoding->s_ij[i][j]])
{
fprintf(file,"%d [style=filled, fillcolor=%s]\n",j+1,colors[color_index].c_str());
same_colors.push_back(j);
}
}
}
for(Edge* e : graph->edges) e->toDOT(file);
fprintf(file,"}");
}
unsigned int ModelChecker::obtainNbColors()
{
vector<unsigned int> same_colors;
unsigned int nbColors = graph->nbVertices;
for(unsigned int i = 0; i < graph->nbVertices; ++i)
{
if(std::find(same_colors.begin(), same_colors.end(), i) != same_colors.end()) {
nbColors--;
}
for(unsigned int j = i+1; j < graph->nbVertices; ++j)
{
if(model[encoding->s_ij[i][j]])
{
same_colors.push_back(j);
}
}
}
return nbColors;
}