- Run Dijkstra’s on C.
- Maintain distance array (dist)
- It is mentioned that edges of ‘B’ are directed but it is undirected.
1 / \ 2 3 / \ 4 5
Here, there is not path possible between 3 and 5, if the edges are directed.
- For every edge, check whether nodes or vertex of a edge is in range or not (1 <= node <= A).
- Iterate the E and for each edge in E, check for (dist[from] - dist[to] ) < E, if yes.