Iterate through graph in dijstra algo