Skip to content

Instantly share code, notes, and snippets.

@stephentu
Created January 16, 2015 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephentu/65b0f971edd8aa2d3124 to your computer and use it in GitHub Desktop.
Save stephentu/65b0f971edd8aa2d3124 to your computer and use it in GitHub Desktop.
static inline SDP
ConstructMaxCutSDPFromGraph(const UndirectedGraph& g)
{
SDP sdp(g.NumVertices(), g.NumVertices(), 0);
g.Laplacian(sdp.SparseC());
sdp.SparseC() *= -1;
for (size_t i = 0; i < g.NumVertices(); i++)
{
sdp.SparseA()[i].zeros(g.NumVertices(), g.NumVertices());
sdp.SparseA()[i](i, i) = 1.;
}
sdp.SparseB().ones();
return sdp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment