Patch for feasible divide by zero

Static analysis (coverity) detected a feasible (although
not likely) code path such that the variables testEdges
and testNotEdges could be zero, which would result in
a divide by zero.  Add in a check for the zero case.

Fixes coverity 746806 and 746807