function modified Dijkstra (G, S, D):
 for each vertex v in Graph:
  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:
//remaining vertices inaccessible from S
  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
  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.
Algorithm 2