-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAPICallHeuristics.java
39 lines (34 loc) · 1.02 KB
/
APICallHeuristics.java
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
import com.gcol.GraphColoring;
import com.gcol.GraphReader;
import com.gcol.Graph;
public class APICallHeuristics
{
public static void main(String [] args) throws Exception
{
Graph graph = GraphReader.readGraph("filename");
// where filename is a DIMACS formatted graph file
boolean localsearch = true;
int iteratedgreedyiterations = 1000;
int localsearchiterations = 1000;
int localsearchtimeinmilliseconds = 1000;
int [] colors = GraphColoring.colorGraph(graph, localsearch, iteratedgreedyiterations, localsearchiterations, localsearchtimeinmilliseconds, false);
int maxColor = -1;
for(int i=0; i<colors.length; i++)
{
if(maxColor == -1)
{
maxColor = colors[i];
}
else if(maxColor < colors[i])
{
maxColor = colors[i];
}
}
System.out.println("Final Coloring of graph possible with " + maxColor + " colors.");
System.out.println("Colors of Vertices: ");
for(int i=0; i<colors.length; i++)
{
System.out.print(colors[i] + " ");
}
}
}