greedy_max_cut#
- iqm.applications.maxcut.greedy_max_cut(max_cut_problem)[source]#
Standard greedy algorithm for maxcut problem class.
Steps:
Start with a random assignment of nodes in two groups.
Iterate over all nodes
For each node, switch it to the other group if it improves the cost function.
Repeat steps 2-3 until no node can be switched.
Return the final assignment.
- Parameters:
max_cut_problem (MaxCutInstance | Graph) – A problem instance of maxcut or a
Graph
.- Returns:
A bitstring solution.
- Return type: