def clique_perfects(G, seed_i):
	G_nodes = G.nodes()
	S,H = p.convert_graph_connectivity_to_sparse(G, G_nodes)
	bestQ = []
	for itr in xrange(PERFECT_MAXITR):
		alpha = uniform(.1, .9)
		Q = map(lambda x: G_nodes[x], p.construct(S, H, alpha, G_nodes.index(seed_i)))
		# NOTE: no guarantee that seed_i is in the clique
		if len(Q) > len(bestQ):
			bestQ = Q
	return bestQ
def clique_perfects(seed_i, cursor):
	G = seed_graph(seed_i, cursor)
	# first find a perfect clique of size >= PERFECT_CLIQUE_MIN_SIZE
	G.delete_nodes_from( filter(lambda n: G.degree(n)<PERFECT_CLIQUE_MIN_SIZE, G.nodes_iter()) )
	if not G.has_node(seed_i):
		return []
	print >> sys.stderr, "initial seed graph gets {0} nodes, {1} edges".format(\
			G.number_of_nodes(),G.number_of_edges())
	G_nodes = G.nodes()
	S,H = p.convert_graph_connectivity_to_sparse(G, G_nodes)
	remembered_perfects = []
	# for PERFECT_MAXITR iterations, store all found perfect cliques containing seed_i
	for itr in xrange(PERFECT_MAXITR):
		alpha = uniform(.1, .9)
		Q = map(lambda x: G_nodes[x], p.construct(S, H, alpha, G_nodes.index(seed_i)))
		Q.sort() # sort it, so we add only distinct cliques
		if seed_i in Q and len(Q) >= PERFECT_CLIQUE_MIN_SIZE\
				and Q not in remembered_perfects:
			remembered_perfects.append(Q)
	if len(remembered_perfects) == 0:
		return []
	remembered_perfects.sort(reverse=True,key=lambda x:len(x))
	return remembered_perfects[0]