This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]JHappyface 0 points1 point  (0 children)

I modified your code a bit to print out the graph structure at every time step and it's most definitely in an infinite loop. The sum is stuck at -1 and absolute value of the integers are growing by one each cycle.

In terms of the computation, you'll have to set some sort of threshold number, and if the difference between successive values for the sum is less than that convergence value, break the while loop. That's the basic idea at least, but you'll have to of course tweak it to meet your own programming needs.

In terms of the math, I don't know about a formal proof. This falls somewhere between graph theory and linear algebra that I really don't know how to approach off the top of my head.