started working on optimizations. added a testcase for reference
fixed a bug with the potential which made it behave strange at times.
used sets to avoid updating same neighbor twice. test fails.