given a directed graph G(V,E) with weights , all weights have the value of 1 to |V| , given two vertices s and t find minimum bottleneck path from s to t in linear time .
my idea is to add edges gradualy according to its weights first add edges with weight equal to 1 if there is a path from s to t return 1 as the min bottleneck else add all edges with weight 2 and according to the edge itself change the visited vertices to unvisited .
i am not sure if the solution above is linear . any ideas ? thank you
Because all the weights are in [1,|V|], you can sort the edges by weight in linear time.
Then, clear all edges from the graph and start adding them back in weight order, stopping when vertex t becomes reachable from vertex s.
At this point, the graph will include a minimum bottleneck path, and no edges will be more expensive that the bottleneck. You can do a BFS in this graph to find the path.
In order to make this a linear time algorithm, you need to do step (2) in linear time, and for that you need to track which vertices are reachable from s in amortized constant time per edge. The trick is to process each edge for reachability just once: