According to what I could understand from the code and additional comments, the code is incomplete and therefore, no conclusion is drawn of the achieved results.
It seems like you are on the right track trying to move along the graph through the nearest vertex with the lowest cost without visiting the already visited vertices; however, graph creation and starting the problem could never take place due to some issues in implementation e.g. trying to loop through an integer or other data type that loops cannot work on.
Review by Milad
Major Issues