Chosen answer is best one but many people have doubt that why B is not selected as it is shortest than A.
Answer to this is when we run dijkstra algorithm
First S will update A ,B,D as 4,3,7 respectively.
then we select shortest of it i.e B (3). After there is nothing for B to relax and give better update.as D is already updated by S with weight 7.
So now it will select A . it will relax C and so on...
S-B-A-C-E-D-G-T-F.
please follow given tree. how algorithm will proceed and relax.
S
/ \ \
A B D
/ \
C F
|
E
/ \
G T
There for shortest path using Dijkstra Algorithm is SACET.