Skip to main content
. 2022 Jun 16;22(12):4539. doi: 10.3390/s22124539
Algorithm 2 Route optimization with the minimum spanning tree algorithm.
  • 1:

    initialize variables:

  • 2:

    hop_count=0

  • 3:

    xanodea

  • 4:

    xbnodeb

  • 5:

    centroid node

  • 6:

    C ← cluster

  • 7:

    for all clusters (C) do

  • 8:

        calculate hop_count from centroid

  • 9:

        if distance between (xa and centroid) == 1 then

  • 10:

            hop_count=hop_count+1

  • 11:

        else

  • 12:

            hop_count=hop_count+2

  • 13:

        end if

  • 14:

        if hop_count<2 then

  • 15:

            select node for routing

  • 16:

        else

  • 17:

            drop node

  • 18:

        end if

  • 19:

    end for

  • 20:

    repeat

  • 21:

        step 7

  • 22:

    until the centroid does not change

  • 23:

    while the topology has changed do

  • 24:

        steps 1 to 7

  • 25:

    end while