QAOA Optimization API
import networkx as nx
n_nodes = 6
p = 0.5 # probability of an edge
seed = 1967
g = nx.erdos_renyi_graph(n_nodes, p=p, seed=seed)
positions = nx.spring_layout(g, seed=seed)
nx.draw(g, with_labels=True, pos=positions, node_size=600)
qo = QAOA(g, task='maximum_clique')
qo.execute()
nodes, probs = qo.results(return_probs=True)
qo.plot_samples(probs)
sub = g.subgraph(nodes)
nx.draw(g, pos=positions, with_labels=True)
nx.draw(sub, pos=positions, node_color="r", edge_color="r")
assert set(nodes) == set([0,2,3,4])