|
|
Algorithm 1. Dijkstra's Algorithm with proposed cost function |
|
| 1: |
for i = 1 to # of Nodes do |
| 2: |
nodei.visited ← 0 |
| 3: |
nodei.distance ← ∞ |
| 4: |
nodei.previous ← nodei
|
| 5: |
end for |
| 6: |
nodeAP.distance ← 0 |
| 7: |
energymin = min(node.energy) |
| 8: |
while unvisited nodes available do |
| 9: |
nodesource ← node with smallest distance |
| 10: |
for i = 1 to # of Links do |
| 11: |
if linki.source = nodesource then |
| 12: |
nodedest ← linki.destination |
| 13: |
if nodedest.visited = 0 then |
| 14: |
cost ← linki.power * (1 + (nodedest.energy/energymin)M)/2 |
| 15: |
newdistance ← nodesource.distance + cost |
| 16: |
if distance < nodedest.distance then |
| 17: |
nodedest.distance ← newdistance |
| 18: |
nodedest.previous ← nodesource
|
| 19: |
end if |
| 20: |
end if |
| 21: |
end if |
| 22: |
end for |
| 23: |
nodesource.visited ← 1 |
| 24: |
end while |
|