0

i have a matrix of the form

a b 8.0
a d 0.1
......

where 1st column is Node A,2nd Node B and 3rd correlation coefficient i have to make a program that finds a threshold thus the connected network has a Giant Connected Component consist of 50-60% of total Network nodes. I wrote a program that using a binary search for the threshold like

if Giant Connected Component > 60% new threshold=oldthreshold + oldthreshold/2
if Giant Connected Component < 50% new threshold=oldthreshold - oldthreshold/2

The problem is that algorithm is also searching for thresholds > 1 and/or <0 .How i can handle this.Or is there any better idea how to calculate it?

valentinosael
  • 25
  • 1
  • 1
  • 6

1 Answers1

0

The algorithm you describe is not binary search.

To correctly implement binary search, keep track of two values, min_threshold and max_threshold. Initially set these to the minimum and maximum possible threshold values. Then at each step:

threshold = (min_threshold + max_threshold)/2
if GCC(threshold) > 60%:  # threshold is too low, update minimum
    min_threshold = threshold
else if GCC(threshold) < 50%:  # threshold is too high, update maximum
    max_threshold = threshold
augurar
  • 12,081
  • 6
  • 50
  • 65