def extendByOne(c, G): N = G.shape[0] for i in range(N): if i not in c: if verifyClique(c + [i], G): return c + [i] print "Maximal!" return c
def biggestClique(y, G): """Returns the biggest clique from key y, by looking at that biggest k elements of y until it is no longer a clique.""" l = len(y) ind = np.argsort(y) rev = np.argsort(ind) R = [] for i in range(1, l): k = np.zeros(l) k[-i:] = 1 k = k[rev] r = extractClique(k) if verifyClique(r, G): R = r else: break return R
from NPrepel import * from graphReader import getGraph from cliqueProject import extractClique from cliqueProject import verifyClique G = np.array( [[0, 1, 1, 0, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0]]) x, c, errors = solve(G, renormL2, 1e-3, 0, 1e-8, 10000, 100) print c G = getGraph() y, R, errors2 = solve(G, renormCube, 1e-2, 0.3, 1e-4, 100000000000, 1000) print R print len(R) print verifyClique(R, G)