Threshold for distance is taken as 250 to find neighbor. This threshold is the transmission radius range between two nodes.

for {set j 0} {$j < $val(nn) } {incr j} {

set a [ expr $X1($j)-$X1($i)]
set b [ expr $a*$a]
set c [ expr $Y1($j)-$Y1($i)]
set d [ expr $c*$c]
set e [ expr $b+$d]
set f 0.5
set g [expr pow($e,$f)]

if {$g <= 250 && $i != $j} {

set k [ expr $k+1]
set nei($m) $j
set m [ expr $m+1]

puts “| Node($i) | ($j) |”

Leave a Comment