Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWendland authored Mar 3, 2024
2 parents f44de02 + da5d4dc commit 0f1008d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mlrose_hiive/fitness/max_k_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ def evaluate(self, state):
edges = self.edges if self.graph_edges is None else self.graph_edges

if self.maximize:
# Maximise the number of adjacent nodes not of the same colour.
fitness = sum(int(state[n1] != state[n2]) for (n1, n2) in edges)
else:
# Minimise the number of adjacent nodes of the same colour.
fitness = sum(int(state[n1] == state[n2]) for (n1, n2) in edges)
return fitness

Expand Down

0 comments on commit 0f1008d

Please sign in to comment.