I came across Qiskit's 'Max-Cut and Traveling Salesman Problem' and would like to adapt it to currency arbitrage problem.

I have assigned currencies as nodes in the code below, and written the currency exchange rates in a matrix.

I'm not sure whether the edges are being assigned to the exchange rate, and what is causing the error?

enter image description here

Thanks in advance for any help! :)

  • $\begingroup$ can you paste all the code here, not screeen shot, so I can quickly try it out. $\endgroup$
    – poig
    Jun 10 at 16:19

1 Answer 1


The code is looking for the "weight" as an attribute of edge, in this case each edge being a dictionary of attributes. It is failing in get_item call as its trying to get this item from the dictionary there but instead you have a float, i.e. the weight directly. Its expecting weights to be accessed this way

graph.edges[w, v]["weight"]

Taking a look at this routine that builds out a random TSP may be helpful too as it shows the way things are expected as well.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.