I am currently working on Dijkstra's Shortest Path problem. I have nothing specific in this project, algorithm is standard (implement with set of pairs) except I need to print the types of edges from one vertex to another.
Imagine I have 4 vertices and 5 edges. There exist a pair of vertices p(v1, v2) such that there are 2 or more edges connecting v1 and v2. For instance, we want to find distance from London to Paris. We know that we both can drive by car (one type of edge) or we can buy a plane ticket (another type of edge). What I want to do is to print the type of edge.
Example: I have two ways to reach Paris from London: London -> Calais -> Paris, min time 5 hours, by car; London -> Paris, min time 1 hour, by plane.
I know exactly, how to print min time or min distance, how to print the path, etc. But, how can I print the type of edge (type of transportation) such as 'by plane' or 'by car'? Here is what I tried:
struct neighbor {
int target_vertex;
double weight;
int type;
// for type: 0 - car
// 1 - bus
// 2 - plane
};
But still, I could not figure out, how would I store those edge 'types' while computing shortest path.
Code here: https://gist.github.com/anonymous/5943c448e47ebf0d3964baa53361459d