标签:row cee with EAP find span limit new when
Shortest Path - Tree
Description:
? Directed edge \((u,v)\) in tree if \(u\) last relax \(v\) , the root is \(S\) or \(T\) .
The classic problem :
? forall edge \(i\) in the Graph , query the shortest path \((S, T)\) without edge \(i\) .
Solution:
? If edge \(i\) not in the shortest path, the answer is distance\((S, T)\) .
? Otherwise , build the shortest path-tree (the root is S). we can prove the shortest path must have only one non-tree-edge, assume edge \(i= (u,v)\) , we can find an optimal non-tree-edge \((x, y)\) that the Graph have least one path \((S, x)\) and path \((y, T)\) without edge \(i\) , the new path is \((S\rightarrow x\rightarrow y\rightarrow T)\) , and the additional value is distance\((S, x)\) \(+\) weight\((x,y)\) \(-\) distance\((S, y)\) . Obviously, We need minimum the additional value, we can enumerate the non-tree-edge to calculate answer in \(\mathcal O(m)\) complexity.
K-shortest Path
Description:
? The k‘th Shortest Path in the Graph.
Solution:
- Use A* algorithm and get timelimit exceed.
- Do some classic work in Shortest-Path tree (\(T\) is root), The path \((S, T)\) must consist of some tree-edge and non-tree-edge. The non-tree-edge\((x,y)\) ‘s additional value is distance\((y, T)\) \(+\) weight\((x,y)\) \(-\) distance\((x, T)\) . The problem transfrom to a new problem, get k-mininal sequence which consist of non-tree-edge. So we can use heap to maintain vertex and the sum of non-tree-edge value, the k‘th be popped node is answer. When node \(x\) be popped, expand all non-tree-edge in the treepath$(x, T) $,the complexity is \(\mathcal O(kmlogn)\) .
- According to solution 2, we can get a better solution. Obviously, when node \(x\) be popped, choose smallest non-tree-edge must better than choose second smallest non-tree-edge. So we can add a new situation to indicate which ranking non-tree-edge has been considered. When node \(x\) be poped, just consider next non-tree-edge or transfrom to another vertex. To maintain non-tree-edge ranking in the path,. we need use chairman‘s tree or mergeable heap . This solution‘s complexity is \(\mathcal O(k\ log n+m\log n)\).
Graph Theory
标签:row cee with EAP find span limit new when
原文地址:https://www.cnblogs.com/mangoyang/p/11323020.html