Skip to content

Instantly share code, notes, and snippets.

@stephentu

stephentu/maxcut.cpp

Created Jan 16, 2015
Embed
What would you like to do?
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