Q:

Modification for Dijkstra Algorithm

I want to know, when the start vertex s is given, the shortest path is computed only if a vertex is no more than three edges away from the start vertex. 
I thought of doing this by counting the number of parents, and if number_of_parents<=3 then it is a valid path. 
Please can someone clarify this for me using the algorithm? 
Below is the standard Dijkstra Algorithm. 
Dijkstra(G,W,s)
   Initialize_Single_Source(G,s)
   S= {}
   Q = V[G]
   while Q ! = {} do
      u = extract_min(Q)
      S = S U {u}
      for each vertex v element of Adj[u] do
                 relax(u,v,w)

A:

Instead of a vertex we use array L to determine levels, i.e., how far a node is from the source
Dijkstra(G,W, s)
   Initialize_Single_Source(G,s)
   S= {}
   Q = V[G]
   L = {an array to determine levels of each node, 
    initially all nodes have level "infinite" except for s who has level 0}
   while Q ! = {} do
      u = extract_min(Q)
      u_level = L[u]
      if(u_level > 3){
        ignore u and don't add it to S;
        continue;
      }
      S = S U {u}
      for each vertex v element of Adj[u] do
                 relax(u,v,w)
                 in relax function you put L[v] = min(L[v], u_level + 1);

