Neighbor of nodes can be detected by distance formulae and this can be written in a file

For that first create a file using following statement

set out1 [open neighbour w]

Then Fine neighbors, read this page

 

Then following code used to write neighbor in a file

set a1 [ expr $count(0)+$count(1)]
set b1 0

 

for {set i $count(0)} {$i < $a1 } {incr i} {
set neighbour2($b1) $nei($i)
set dd “set neighbournode(1) $neighbour2($b1)”
puts $out1 $dd
set b1 [ expr $b1+1]

}

 

set b2 0
set a2 [ expr $a1+$count(2)]
for {set i $a1} {$i < $a2 } {incr i} {
set neighbour3($b2) $nei($i)
set dd “set neighbournode(2) $neighbour3($b2)”
puts $out1 $dd
set b2 [ expr $b2+1]

}

 

set b3 0
set a3 [ expr $a2+$count(3)]
for {set i $a2} {$i < $a3 } {incr i} {
set neighbour4($b3) $nei($i)
set dd “set neighbournode(3) $neighbour4($b3)”
puts $out1 $dd
set b3 [ expr $b3+1]
}

 

set b4 0
set a4 [ expr $a3+$count(4)]
for {set i $a3} {$i < $a4 } {incr i} {
set neighbour5($b4) $nei($i)
set dd “set neighbournode(4) $neighbour5($b4)”
puts $out1 $dd
set b4 [ expr $b4+1]
}

 

set b5 0
set a5 [ expr $a4+$count(5)]
for {set i $a4} {$i < $a5 } {incr i} {
set neighbour6($b5) $nei($i)
set dd “set neighbournode(5) $neighbour6($b5)”
puts $out1 $dd
set b5 [ expr $b5+1]
}

 

set b6 0
set a6 [ expr $a5+$count(6)]
for {set i $a5} {$i < $a6 } {incr i} {
set neighbour7($b6) $nei($i)
set dd “set neighbournode(6) $neighbour7($b6)”
puts $out1 $dd
set b6 [ expr $b6+1]
}

 

 

set b7 0
set a7 [ expr $a6+$count(7)]
for {set i $a6} {$i < $a7 } {incr i} {
set neighbour8($b7) $nei($i)
set dd “set neighbournode(7) $neighbour8($b7)”
puts $out1 $dd
set b7 [ expr $b7+1]
}

 

set b8 0
set a8 [ expr $a7+$count(8)]
for {set i $a7} {$i < $a8 } {incr i} {
set neighbour9($b8) $nei($i)
set dd “set neighbournode(8) $neighbour9($b8)”
puts $out1 $dd
set b8 [ expr $b8+1]
}

 

 

set b9 0
set a9 [ expr $a8+$count(9)]
for {set i $a8} {$i < $a9 } {incr i} {
set neighbour10($b9) $nei($i)
set dd “set neighbournode(9) $neighbour10($b9)”
puts $out1 $dd
set b9 [ expr $b9+1]
}

 

set b10 0
set a10 [ expr $a9+$count(10)]
for {set i $a9} {$i < $a10 } {incr i} {
set neighbour11($b10) $nei($i)
set dd “set neighbournode(10) $neighbour11($b10)”
puts $out1 $dd
set b10 [ expr $b10+1]
}

Leave a Comment