Research Article

Metric-Based Cooperative Routing in Multihop Ad Hoc Networks

Algorithm 2

function modified Dijkstra (G, S, D):
 for each vertex v in Graph:
//Initializations
  cost [v]:= infinity;
//Unknown cost function from S to v
  previous [v]:= undefined;
//Previous node in optimal path from S
 end for;
  cost [S]:= 0;
  Q:= the set of all nodes in Graph;
 while Q is not empty:
u:= vertex in Q with smallest cost [ ] ;
  if cost [u] = infinity:
    break;
//remaining vertices inaccessible from S
 fi;
  remove u from Q;
 for each neighbor v of u:
//where v has not yet been
       removed from Q.
temp:= 1 (1cost [u]) linkmetric(u,v);
  //link cost for PDR
temp:= cost [u] + 1/linkmetric(u,v);
  //link cost for Throughput
        or Energy Efficiency
     if alt < cost [v]:
         cost [v]:= temp;
         //Update new metric
         previous [v]:= u;
         //Update new path
     fi;
  end for;
end while;
return cost [ ] ;
path:= empty sequence
//find shortest path between S and D
d:= D
while previous [d] is defined:
  insert u at the beginning of path
  d:= previous [d]
end while
return path;
end modified Dijkstra.