0
$\begingroup$

I am trying implement MAXCUT using QAOA. I have a graph with edges defined by an edges set. My edges set looks a bit like this:

edges_set = [Edge(0, 1), Edge(1, 2), Edge(2, 3), Edge(3, 0), Edge(2, 0), Edge(1, 3), Edge(0, 4), Edge(1, 4), Edge(2, 4), Edge(3, 4), Edge(4, 5), Edge(5, 0), Edge(2, 6), Edge(6, 3)]

The Edge object is already well defined as follows:

class Edge:
"""
This is a class defining the edges of the Graph that will be used by 
Networkx for the purpose of implementation and demonstration of the 
QAOA algorithm

Attributes
----------
start_node           :   (int) This is a variable containing the starting node
                         of a connecting edge in the Graph
end_node             :   (int) This is a variable containing the ending node of
                         a connecting edge in the Graph
"""
def __init__(self, start_node, end_node):
    self.start_node = start_node
    self.end_node = end_node

Now I'm trying to take this set of edges and turn them into GridQubits with assigned Qids. But I'm having trouble figuring out what would be the best way of going about this. I want to do this because, in the end, I want to visualize my MAXCUT coloring as they did in the Cirq QAOA tutorial as given here. But I cannot directly feed in my graph as that throws the error Gate was called with type different than Qid. Type: <class 'str'>

Any help would be absolutely fantastic. Thanks in advance!

$\endgroup$
1
  • 1
    $\begingroup$ The qubits should represent nodes, not edges. You can ignore GridQubits (which is a Qid btw) unless you want to work with a specific device topology (the tutorial was using a Google chip's topology as an example) - instead you could just have seven NamedQubits e.g named 0 to 6 or "a" to "f". The coloring is using networkx, doesn't depend on grid qubits (see output_cut function). Networkx graph nodes can be any python object really. $\endgroup$ – Balint Pato Feb 14 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.