summaryrefslogtreecommitdiff
path: root/aztec.cpp
blob: 12197d9704305dcc0675cb0a57a8d04977865b0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "aztec.hpp"

PerfectMatching findGroundState(const AztecDiamond& a) {
  PerfectMatching pm(a.vertices.size(), a.edges.size());

  for (const AztecDiamond::Edge& e : a.edges) {
    pm.AddEdge(e.head->index, e.tail->index, e.weight);
  }

  pm.options.verbose = false;
  pm.Solve();

  return pm;
}

bool edgeMatched(PerfectMatching& pm, const AztecDiamond::Edge& e) {
  return e.tail->index == pm.GetMatch(e.head->index);
}