I'm looking at Dijkstra's algorithm for single source shortest paths in a graph $G$ from a vertex $s$ from Introduction to Algorithms by Cormen et al. The $w$ parameter is the weight function such that $w(u,v)$ gives you the weight of the edge from $u$ to $v$.
DIJKSTRA(G, w, s)
INITIALIZE-SINGLE-SOURCE(G,s)
S = {}
# Put all vertices of G in a priority queue, Q.
Q = G.V
while Q != {}
u = EXTRACT-MIN(Q)
S = S U {u}
for each vertex v in G.Adj[u]:
RELAX(u,v,w)
Here, the INITIALIZE-SINGLE-SOURCE method simply sets the shortest distance values for $s$ to $0$ and all other vertices to $\infty$. The RELAX method:
RELAX(u,v,w)
if v.d > u.d + w(u,v)
v.d = u.d + w(u,v)
v.pi = u
Note that all vertices have the $v.d$ property which is the length of the shortest path from $s$ to $v$ and the $v.pi$ property which is the parent of $v$ in the shortest path.
Staring at the algorithm, I'm wondering what role the set $S$ is playing exactly. What if I removed $S$ completely - doesn't seem like it'll affect the algorithm at all. What am I missing?