Dijkstra first node visited

问题内容:

I’m implementing a Dijkstra program in C++ and I’m having some problems, let me explain:

For the moment I’ve been following this code:
http://www.geeksforgeeks.org/printing-paths-dijkstras-shortest-path-algorithm/

This code prints the full path from the source to all other vertexs.
I’m using an array int parent[num_vertexs]; to store the path. But the problem is that I don’t want the full path, only the FIRST vertex visited.

How can I get only the first node visited? Is there any way to print only the first node of the parent array for each node?

Thank you very much for your time.

问题评论:

    
Yes, there’s a way. If you edit the relevant function into your question, we’ll show you how to change it. (We don’t like link-dependent questions here.)

原文地址:

https://stackoverflow.com/questions/47755698/dijkstra-first-node-visited

添加评论