hope everyone is staying safe.

I am in week 3 and doing problem set # 3 - Tideman voting. In the main function it says the following: enter image description here

Why does it need to clear the graph of locked in pairs? (p.s. I wrote the //why 😋 )


1 Answer 1


Interesting. I am working on the Tideman problem now and didn't notice this block until I read your question. Let's ignore the comment that states "clear graph..." and focus only on what the code is doing. The code is basically setting each cell of the 2 dimensional array to false. I believe it is doing this not to clear the array but rather to initialize it. Note that for locked cells where the candidate is the same (e.g. Alice to Alice, Bob to Bob, Charlie to Charlie, etc...) the value should always be false. So the code above does that. The second reason I believe this is being done is to help when you are comparing values in the lock_pairs function. Logically speaking, a pair of candidates should not be locked in (i.e. should be false) unless we have a reason to mark the edge as true. So I think marking all the edges as false from the start establishes the default state. It is your code's job figure out which edges to mark as true. I could be wrong on the reasoning but this makes sense to me.

  • Thanks for answering. Yes, I figured that as well like about a week after I wrote my post. I think the programmer thought of it as "clearing the graph" and so that's his commit and the bias in it. I figured out it does the intimidation for the like-like pairs as well, you can even remove it and edit to check.
    – ZeevKeane
    Commented Jun 13, 2020 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .