Graph Theory
Posted mangoyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Graph Theory相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
为啥即使 CPAN 说 GD::Graph::pie 已安装并且是最新的,“使用 GD::Graph::pie;”也会失败?
从图(Graph)到图卷积(Graph Convolution):漫谈图神经网络模型