Menu

#198 Bug in Betweenness calculation?

Likely Bug
open
nobody
None
5
2014-06-11
2014-06-10
Dave Walend
No

I've been writing tests of my algorithm for betweenness by comparing it to Jung's. I've been using the Stanford graphbase's list of adjacent states, writing in Scala. If I use the first 33 lines of http://www-cs-faculty.stanford.edu/~uno/contiguous-usa.dat , then my code agree's with Jungs. If I add the 34th line, our answers diverge. I think the bug is in Jung because the numbers are not the neat fractions I would expect from Brandes' algorithm.

The first column is the state, the second is my result, the third is Jung's result, for the first 34 lines. You can see that my code's results are eights, but Jung's look like rounding errors.

MA 0.0 0.0
NM 32.0 32.0
OR 0.0 0.0
TN 61.875 62.50000000000002
MO 0.0 0.0
AZ 54.5 54.5
NJ 0.0 0.0
TX 0.0 0.0
MD 6.0 6.0
NV 0.0 0.0
NE 0.0 0.0
KS 0.0 0.0
OK 110.0 110.0
CT 3.0 3.0
AR 134.5 134.5
FL 0.0 0.0
CO 129.5 129.5
DC 4.0 4.0
PA 0.0 0.0
GA 45.125 44.50000000000001
WY 0.0 0.0
LA 0.0 0.0
CA 20.0 20.0
UT 32.0 32.0
AL 14.375 15.000000000000005
VA 0.0 0.0
NC 0.0 0.0
NY 0.0 0.0
SC 0.0 0.0
RI 0.0 0.0
MS 13.125 12.499999999999996
DE 7.0 7.0

See https://github.com/dwalend/ScalaGraphMinimizer/blob/to0.1.0/src/test/scala/net/walend/digraph/semiring/AllPathsFirstStepsTest.scala , around 138 for the test case.

Thanks,

Dave

Discussion

  • Dave Walend

    Dave Walend - 2014-06-10

    On second thought, that looks like float-to-double error. Wave off. I'll keep digging.

     
  • Dave Walend

    Dave Walend - 2014-06-11

    Found my bug. Down to floating point differences now.

     

Log in to post a comment.