Distance between two nodes can be calculated using distance formulae

Distance = sqrt[(X2-X1)*(X2-X1) +(Y2-Y1)*(Y2-Y1)]

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) |”