There is a directed graph. All edges are in one direction only. The problem is to find the minimum number of possible changes so that you can get from one given node to another.
For example: For a graph with three nodes and two edges (1->2, 3->2). You need to determine how many changes in edge direction should be made to achieve a path from node 1 to node 3. The answer will be 1, since it is enough to change edge 2->3 and get the path 1->2->3.
This is a task with a limited time (5s). The number of points and edges are in the range [1,10^6]. Memory is limited to 256 megabytes
Please help with finding a fast algorithm to solve this task