Implement prune and branch for graph coloring. Already works better than previous solution.
This commit is contained in:
@@ -7,31 +7,6 @@ import coloring
|
||||
def solve_it(input_data):
|
||||
return coloring.solve_it(input_data)
|
||||
|
||||
# Modify this code to run your optimization algorithm
|
||||
|
||||
# parse the input
|
||||
lines = input_data.split('\n')
|
||||
|
||||
first_line = lines[0].split()
|
||||
node_count = int(first_line[0])
|
||||
edge_count = int(first_line[1])
|
||||
|
||||
edges = []
|
||||
for i in range(1, edge_count + 1):
|
||||
line = lines[i]
|
||||
parts = line.split()
|
||||
edges.append((int(parts[0]), int(parts[1])))
|
||||
|
||||
# build a trivial solution
|
||||
# every node has its own color
|
||||
solution = range(0, node_count)
|
||||
|
||||
# prepare the solution in the specified output format
|
||||
output_data = str(node_count) + ' ' + str(0) + '\n'
|
||||
output_data += ' '.join(map(str, solution))
|
||||
|
||||
return output_data
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
Reference in New Issue
Block a user