Webinar Recording Available

Thanks to those of you who attended our webinar: "Quantum Programming with the Ocean Tools Suite"

If you missed it, you can watch the recording here.

 

Bonus materials

Read the Lucas paper on Ising/QUBO formulations that Victoria mentions.

Below is the contents of the Antennas.py file used in the webinar:

## import networkx for graph tools
import networkx as nx 
 
## import dwave_networkx for d-wave functions
import dwave_networkx as dnx 
 
## import matplotlib.pyplot to draw graphs on screen
import matplotlib.pyplot as plt 
 
## Set the solver we're going to use
from dwave.system.samplers import DWaveSampler
from dwave.system.composites import EmbeddingComposite
sampler = EmbeddingComposite(DWaveSampler())
 
## Create empty graph
G = nx.Graph()
 
## Add edges to graph - this also adds the nodes
G.add_edges_from([(1,2),(1,3),(2,3),(3,4),(3,5),(4,5),(4,6),(5,6),(6,7)])
 
## Find the maximum independent set, S
S = dnx.maximum_independent_set(G, sampler=sampler, num_reads=10)
 
## Print the solution for the user
print('Maximum independent set size found is', len(S))
print(S)
 
## Visualize the results
#    Red nodes are in the set, blue nodes are not
k = G.subgraph(S)
notS = list(set(G.nodes())-set(S))
othersubgraph = G.subgraph(notS)
pos = nx.spring_layout(G)
plt.figure()
nx.draw(G,pos=pos)
nx.draw(k,pos=pos)
nx.draw(othersubgraph,pos=pos, node_color='b')
plt.show()

 

 

1

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post