REDMAN Manager Election Protocol Pseudo-code
exploredList = ø;
forwarderList = ø;
bestNode = ø;
bestValue = MAX;
worstValue = 0;
unexploredList = Initiator;
while
(
unexploredList != ø
)
{
IN = Head
(
unexploredList
)
;
INValue = DistanceFromFarthest
(
IN
)
;
exploredList = exploredList U IN;
unexploredList = unexploredList - IN;
forwarderList = GetPromisingNeighbors
(
IN
)
;
forwarderList = forwarderList - exploredList;
if
(
(
INValue == MinInt
(
worstValue/2
)
||
(
INValue <= worstValue * desired_accuracy
)
)
exit;
if
(
INValue < bestValue
) {
bestNode = IN;
bestValue = INValue;
consecutiveEqualSolutions = 0;
unexploredList = forwarderList ;
}
if
(
INValue > worstValue
) {
worstValue = INValue;
if
((
bestValue == MinInt
(
worstValue/2
)
|| bestValue <= worstValue * desired_accuracy
))
exit;
}
if
(
INValue == bestValue
) {
consecutiveEqualSolutions++ ;
if
(consecutiveEqualSolutions == max_consecutive_equal_solutions) exit;
unexploredList = unexploredList U forwarderList ;
}
}
Print
(
bestNode
)