前K条最短路径算法

K短路径算法 K短路径算法 头文件 #ifndef _GRAPH_H #define _GRAPH_H #include<stdio.h> #include<stdlib.h> #include<vector> #include<iostream> #include... 阅读详情

[注:为了简便我这里只列出算法的步骤和伪代码,详细的数学证明请参见相关论文。C++代码的算法实现可以在我的sourceforge目录https://sourceforge.net/projects/ksp 下载使用。特别要指出的是葡萄牙教授Martins对此算法有深入研究,发表了为数众多的相关论文,我这里采用的也是基于他早期提出的deletion algorithm。Martins的Fortran代码可以在这个网站http://www.mat.uc.pt/~eqvm/ 下载,同时这个网站还提供大量相关论文和文献。在此我谨向Martins教授致以敬意。]

前 k 条最短路径算法

戴维编译

一、算法说明

 Deletion Algorithm 删除算法的核心是通过在有向图中已有的最短路径上删除某条弧,并寻找替换的弧来寻找下一条可选的最短路径。删除算法实际上是通过在有向图中增加附加节点和相应的弧来实现的。算法描述如下:

 

1. 利用 Dijkstra 算法求得有向图 (N,A) 中以开始节点 s 为根的最短路径树(注意,这里的最短路径树并不是最小生成树,因为 Dijkstra 算法并不保证能生成最小生成树),标记从开始节点 s 到结束节点 t 之间的最短路径为 pk , k=1 。

2. 如果 k小于要求的最短路径的最大数目K,并且仍然有候选路径存在, 令当前路径 p=pk , 转3。否则,程序结束。

3. 找出当前路径 p 中从第一个节点开始的入度大于 1 的第一个节点,记为 nh 。如果 nh 的扩展节点 n’ h 不在节点集 N 中,则转 4 ,否则找出路径 p 中 nh 后面所有节点中,其对应的扩展节点不在 N 中的第一个节点,记为 ni ,转 5 。

4.为节点 nh 构建一个扩展节点 n’ h ,并把其添加到集合 N 中,同时从图 (N,A) 中所有 nh 的前驱节点 连接一条到 n’ h 的弧,弧对应的权重不变,添加这些弧到弧集 A 中,但 nh 在 p 中的前一个节点 nh-1 除外。计算从开始节点 s 到 n’ h 的最短路径,并记 ni = nh+1 。

5. 对于 p 中从 ni 开始的所有后续节点,不妨记为 nj ,依次执行如下操作:

5.1 添加 nj 的扩展节点 n’ j 到节点集合 N 中。

5.2 除了路径 p 中 nj 的前一个节点 nj-1 外,分别连接一条从 nj 前驱节点到其扩展节点 n’ j 的弧,弧上的权值保持不变,并把这些弧添加到弧集 A 中。另外,如果 p 中 nj 的前一个节点 nj-1 具有扩展节点 n’ j-1 的话,也需要连接一条从 n’ j-1 到 n’ j 的弧,权值和弧 (nj-1 , nj ) 的权值相等。

5.3 计算从开始节点 s 到 n’ j 的最短路径。

6. 更新当前最短路径树,求得从开始节点 s 到结束节点的当前扩展节点 t(k)’ 之间的最短路径为第 k 条最短路径,令 k=k+1 ,转 2 继续。

 

在上述步骤 4 、 5 、 6 中均需要计算从开始节点到当前扩展节点的最短路径,因为程序开始时便生成了以开始节点为根的最短路径树,那么只要在扩充节点时,记录下每个新节点相对于开始节点的最短路径中其前一个节点编号以及从开始节点到当前节点的最短路径长度,就可以很容易求得任意时刻有向图中从开始节点到结束节点(或其扩充节点)之间的最短路径。  


        扩展节点 :上一条最短路径上的节点可能会在求取下一条最短路径的过程中进行扩展 ,也就是在上次节点集合的基础上增加相应的新节点,这些新的节点均称为扩展节点,其会继承被扩展结点的邻接边关系(具体请参见上述步骤4,5)。一个扩展节点仍然可能会在求取下一条最短路径的时候进行扩展,表现在示例图中就是在一个节点标记后面加一撇表示是在原始节点上扩展,加两撇表示是在上次扩展节点上再扩展,依次类推。
        前驱节点 :就是最短路径中某个节点的前一个节点。

 

二、算法示例
 
下面以图 1 所示网络图为例,根据上述算法,分别求得其第 k 条最短路径,求解过程中有向图的变化情况如图 1 - 5 所示,粗体路径表示当前状态下的最短路径,不同类型的圈表示不同阶段生成的节点 。

 

 

 

 

图1  k=1时的最短路径

 

 

图2  k=2时的最短路径

 

图3  k=3时的最短路径

 

图4  k=4时的最短路径

 

图5  k=5时的最短路径

 

 

 

 

 

   参考文献:[这个算法在70年代就提出来了,其间历经完善,发表的论文也是五花八门,为了能让初次接触此算法的人有个系统的认识,我这里列举了这个算法在近10多年发展过程中几篇有代表性的论文。]

1. J.A. Azevedo, J.J.E.R.S. Madeira, E.Q.V. Martins and F.M.A. Pires, A shortest paths ranking algorithm, (1990), Proceedings of the Annual Conference AIRO'90, Models and Methods for Decision Support, Operational Research Society of Italy, 1001-1011.

90这篇论文阐述了基于删除算法(deletion algorithm)的原理及方法,并指出了解决此类问题的三类算法,对其中删除算法以及基于最优化原理(Principle of Optimality)的算法进行了实验比较。

2. E.Q.V. Martins and J.L.E. Santos. A new shortest paths ranking algorithm. Investigacao Operacional, 20:(1):47-62,2000.

Martins在他99年这篇文章中对删除算法进行了改进,提出了MS Algorithm,实际上除了数据结构上的变化外,算法没有做实质性的改动。不过对于要从实现上来优化算法的人来说,当然是值得一看的。

3. E.Q.V. Martins. A new improvement for a k shortest paths algorithm. 2000。(忘了出处了,不好意思)

Martins随后又在他的这篇论文中改进了MS Algorithm,并依次详细列举了对早期的删除算法的逐步改进过程,所以这篇文章也是值得一读的。同样,这次改进也是从数据结构角度来改进算法效率的。

4.  Victor M. Jimenez and Andres Marzal. Computing the k shortest paths: A new algorithm and a experimental comparison. 1999. (忘了出处了,不好意思)

终于在这篇文章中有人提出了新的算法--递归枚举算法(REA, Recursive Enumeration Algorithm)。论文中分别对新的算法和Martins的算法MSA以及另外一个叫做Eppstein的人的算法(EA)进行了详细的实验比较。我之所以选择Martins的算法也是因为这篇文章对这些算法的对比实验表明,MSA算法在节点小于2000的情况下表现不错,加之MSA简明易懂并且处在不停的完善中:)。

 下面是其他相关的论文,好多哦,不过还是建议你访问Martins教授的网站。

Copyright@戴维 2006.5  于北京

相关论文:
[1] A. Aggarwal, B. Schieber, and T. Tokuyama. Finding a minimum weight K-link path in graphs
with Monge property and applications. Proc. 9th Symp. Computational Geometry, pp. 189–197.
Assoc. for Computing Machinery, 1993.
[2] R. K. Ahuja, K. Mehlhorn, J. B. Orlin, and R. E. Tarjan. Faster algorithms for the shortest path
problem. J. Assoc. Comput. Mach. 37:213–223. Assoc. for Computing Machinery, 1990.
[3] J. A. Azevedo, M. E. O. Santos Costa, J. J. E. R. Silvestre Madeira, and E. Q. V. Martins. An
algorithm for the ranking of shortest paths. Eur. J. Operational Research 69:97–106, 1993.
[4] A. Bako. All paths in an activity network. Mathematische Operationsforschung und Statistik
7:851–858, 1976.
[5] A. Bako and P. Kas. Determining the k-th shortest path by matrix method. Szigma 10:61–66,
1977. In Hungarian.
[6] R. E. Bellman. On a routing problem. Quart. Appl. Math. 16:87–90, 1958.
[7] A.W. Brander and M. C. Sinclair. A comparative study of k-shortest path algorithms. Proc. 11th
UK Performance Engineering Worksh. for Computer and Telecommunications Systems, September
1995.
[8] T. H. Byers and M. S.Waterman. Determining all optimal and near-optimal solutions when solving
shortest path problems by dynamic programming. Operations Research 32:1381–1384, 1984.
[9] P. Carraresi and C. Sodini. A binary enumeration tree to find K shortest paths. Proc. 7th
Symp. Operations Research, pp. 177–188. Athen¨aum/Hain/Hanstein, Methods of Operations Research
45, 1983.
[10] G.-H. Chen and Y.-C. Hung. Algorithms for the constrained quickest path problem and the enumeration
of quickest paths. Computers and Operations Research 21:113–118, 1994.
[11] Y. L. Chen. An algorithm for finding the k quickest paths in a network. Computers and Operations
Research 20:59–65, 1993.
[12] Y. L. Chen. Finding the k quickest simple paths in a network. Information Processing Letters
50:89–92, 1994.
[13] E. I. Chong, S. R. Maddila, and S. T. Morley. On finding single-source single-destination k shortest
paths. Proc. 7th Int. Conf. Computing and Information, July 1995. http://phoenix.trentu.ca/
jci/papers/icci95/A206/P001.html.
[14] A. Consiglio and A. Pecorella. Using simulated annealing to solve the K-shortest path problem.
Proc. Conf. Italian Assoc. Operations Research, September 1995.
[15] Y. Dai, H. Imai, K. Iwano, and N. Katoh. How to treat delete requests in semi-online problems.
Proc. 4th Int. Symp. Algorithms and Computation, pp. 48–57. Springer Verlag, Lecture Notes in
Computer Science 762, 1993.
[16] M. T. Dickerson and D. Eppstein. Algorithms for proximity problems in higher dimensions. Computational
Geometry Theory and Applications 5:277–291, 1996.
[17] S. E. Dreyfus. An appraisal of some shortest path algorithms. Operations Research 17:395–412,
1969.
[18] El-Amin and Al-Ghamdi. An expert system for transmission line route selection. Int. Power
Engineering Conf, vol. 2, pp. 697–702. Nanyang Technol. Univ, Singapore, 1993.
[19] D. Eppstein. Finding common ancestors and disjoint paths in DAGs. Tech. Rep. 95-52, Univ. of
California, Irvine, Dept. Information and Computer Science, 1995.
[20] D. Eppstein. Ten algorithms for Egyptian fractions. Mathematica in Education and Research
4(2):5–15, 1995. http://www.ics.uci.edu/»eppstein/numth/egypt/ .
[21] D. Eppstein, Z. Galil, and G. F. Italiano. Improved sparsification. Tech. Rep. 93-20, Univ. of
California, Irvine, Dept. Information and Computer Science, 1993. http://www.ics.uci.edu:80/
TR/UCI:ICS-TR-93-20.
[22] D. Eppstein, Z. Galil, G. F. Italiano, and A. Nissenzweig. Sparsification – A technique for speeding
up dynamic graph algorithms. Proc. 33rd Symp. Foundations of Computer Science, pp. 60–
69. IEEE, 1992.
[23] L. R. Ford, Jr. and D. R. Fulkerson. Flows in Networks. Princeton Univ. Press, Princeton, NJ,
1962.
23
[24] B. L. Fox. k-th shortest paths and applications to the probabilistic networks. ORSA/TIMS Joint
National Mtg., vol. 23, p. B263, 1975.
[25] G. N. Frederickson. Ambivalent data structures for dynamic 2-edge-connectivity and k smallest
spanning trees. Proc. 32nd Symp. Foundations of Computer Science, pp. 632–641. IEEE, 1991.
[26] G. N. Frederickson. An optimal algorithm for selection in a min-heap. Information and Computation
104:197–214, 1993.
[27] M. L. Fredman and R. E. Tarjan. Fibonacci heaps and their uses in improved network optimization
algorithms. J. Assoc. Comput. Mach. 34:596–615. Assoc. for Computing Machinery, 1987.
[28] M. L. Fredman and D. E. Willard. Trans-dichotomous algorithms for minimum spanning trees
and shortest paths. Proc. 31st Symp. Foundations of Computer Science, pp. 719–725. IEEE, 1990.
[29] A. V. Goldberg. Scaling algorithms for the shortest paths problem. SIAM J. Computing
24(3):494–504. Soc. Industrial and Applied Math., June 1995.
[30] V. Hatzivassiloglou and K. Knight. Unification-based glossing. Proc. 14th Int. Joint Conf.
Artificial Intelligence, pp. 1382–1389. Morgan-Kaufmann, August 1995. http://www.isi.edu/
natural-language/mt/ijcai95-glosser.ps.
[31] G. J. Horne. Finding the K least cost paths in an acyclic activity network. J. Operational Research
Soc. 31:443–448, 1980.
[32] L.-M. Jin and S.-P. Chan. An electrical method for finding suboptimal routes. Int. Symp. Circuits
and Systems, vol. 2, pp. 935–938. IEEE, 1989.
[33] D. B. Johnson. A priority queue in which initialization and queue operations take O.log log D/
time. Mathematical Systems Theory 15:295–309, 1982.
[34] N. Katoh, T. Ibaraki, and H. Mine. An O.Kn2/ algorithm for K shortest simple paths in an undirected
graph with nonnegative arc length. Trans. Inst. Electronics and Communication Engineers
of Japan E61:971–972, 1978.
[35] N. Katoh, T. Ibaraki, and H. Mine. An efficient algorithm for K shortest simple paths. Networks
12(4):411–427, 1982.
[36] P. N. Klein, S. Rao, M. H. Rauch, and S. Subramanian. Faster shortest-path algorithms for planar
graphs. Proc. 26th Symp. Theory of Computing, pp. 27–37. Assoc. for Computing Machinery,
1994.
[37] N. Kumar and R. K. Ghosh. Parallel algorithm for finding first K shortest paths. Computer
Science and Informatics 24(3):21–28, September 1994.
[38] A. G. Law and A. Rezazadeh. Computing the K-shortest paths, under nonnegative weighting.
Proc. 22nd Manitoba Conf. Numerical Mathematics and Computing, pp. 277–280, Congr. Numer.
92, 1993.
[39] E. L. Lawler. A procedure for computing the K best solutions to discrete optimization problems
and its application to the shortest path problem. Management Science 18:401–405, 1972.
24
[40] E. L. Lawler. Comment on computing the k shortest paths in a graph. Commun. Assoc. Comput.
Mach. 20:603–604. Assoc. for Computing Machinery, 1977.
[41] E. Q. V. Martins. An algorithm for ranking paths that may contain cycles. Eur. J. Operational
Research 18(1):123–130, 1984.
[42] S.-P. Miaou and S.-M. Chin. Computing k-shortest path for nuclear spent fuel highway transportation.
Eur. J. Operational Research 53:64–80, 1991.
[43] E. Minieka. On computing sets of shortest paths in a graph. Commun. Assoc. Comput. Mach.
17:351–353. Assoc. for Computing Machinery, 1974.
[44] E. Minieka. The K-th shortest path problem. ORSA/TIMS Joint National Mtg., vol. 23, p. B/116,
1975.
[45] E. Minieka and D. R. Shier. A note on an algebra for the k best routes in a network. J. Inst.
Mathematics and Its Applications 11:145–149, 1973.
[46] D. Naor and D. Brutlag. On near-optimal alignments of biological sequences. J. Computational
Biology 1(4):349–366, 1994. http://cmgm.stanford.edu/»brutlag/Publications/naor94.html .
[47] A. Perko. Implementation of algorithms for K shortest loopless paths. Networks 16:149–160,
1986.
[48] Y. Perl and Y. Shiloach. Finding two disjoint paths between two pairs of vertices in a graph. J.
Assoc. Comput. Mach. 25:1–9. Assoc. for Computing Machinery, 1978.
[49] J. B. Rosen, S.-Z. Sun, and G.-L. Xue. Algorithms for the quickest path problem and the enumeration
of quickest paths. Computers and Operations Research 18:579–584, 1991.
[50] E. Ruppert. Finding the k shortest paths in parallel. Proc. 14th Symp. Theoretical Aspects of
Computer Science, February 1997.
[51] T. Shibuya. Finding the k shortest paths by AI search techniques. Cooperative Research Reports
in Modeling and Algorithms 7(77):212–222. Inst. of Statical Mathematics, March 1995.
[52] T. Shibuya, T. Ikeda, H. Imai, S. Nishimura, H. Shimoura, and K. Tenmoku. Finding a realistic
detour by AI search techniques. Proc. 2nd Intelligent Transportation Systems, vol. 4, pp. 2037–
2044, November 1995. http://naomi.is.s.u-tokyo.ac.jp/papers/navigation/suboptimal-routes/
ITS%95/its.ps.gz.
[53] T. Shibuya and H. Imai. Enumerating suboptimal alignments of multiple biological sequences
efficiently. Proc. 2nd Pacific Symp. Biocomputing, pp. 409–420, January 1997. http://www-smi .
stanford.edu/people/altman/psb97/shibuya.pdf.
[54] T. Shibuya and H. Imai. New flexible approaches for multiple sequence alignment. Proc. 1st
Int. Conf. Computational Molecular Biology, pp. 267–276. Assoc. for Computing Machinery,
January 1997. http://naomi.is.s.u-tokyo.ac.jp/papers/genome/recomb97.ps.gz .
[55] T. Shibuya, H. Imai, S. Nishimura, H. Shimoura, and K. Tenmoku. Detour queries in geographical
databases for navigation and related algorithm animations. Proc. Int. Symp. Cooperative
Database Systems for Advanced Applications, vol. 2, pp. 333–340, December 1996. http:
//naomi.is.s.u-tokyo.ac.jp/papers/databases/codas96.ps.gz.
25
[56] D. R. Shier. Algorithms for finding the k shortest paths in a network. ORSA/TIMS Joint National
Mtg., p. 115, 1976.
[57] D. R. Shier. Iterative methods for determining the k shortest paths in a network. Networks
6(3):205–229, 1976.
[58] D. R. Shier. On algorithms for finding the k shortest paths in a network. Networks 9(3):195–214,
1979.
[59] C. C. Skicism and B. L. Golden. Solving k-shortest and constrained shortest path problems ef-
ficiently. Network Optimization and Applications, pp. 249–282. Baltzer Science Publishers, Annals
of Operations Research 20, 1989.
[60] K. Sugimoto and N. Katoh. An algorithm for finding k shortest loopless paths in a directed network.
Trans. Information Processing Soc. Japan 26:356–364, 1985. In Japanese.
[61] J. W. Suurballe. Disjoint paths in a network. Networks 4:125–145, 1974.
[62] R. E. Tarjan. Data Structures and Network Algorithms. CBMS-NSF Regional Conference Series
in Applied Mathematics 44. Soc. Industrial and Applied Math., 1983.
[63] R. Thumer. A method for selecting the shortest path of a network. Zeitschrift f¨ur Operations
Research, Serie B (Praxis) 19:B149–153, 1975. In German.
[64] M. S. Waterman. Sequence alignments in the neighborhood of the optimum. Proc. Natl. Acad.
Sci. USA 80:3123–3124, 1983.
[65] M. M. Weigand. A new algorithm for the solution of the k-th best route problem. Computing
16:139–151, 1976.
[66] A. Wongseelashote. An algebra for determining all path-values in a network with application to
k-shortest-paths problems. Networks 6:307–334, 1976.
[67] A. Wongseelashote. Semirings and path spaces. Discrete Mathematics 26:55–78, 1979.
[68] J. Y. Yen. Finding the K shortest loopless paths in a network. Management Science 17:712–716,
1971.
[69] J. Y. Yen. Another algorithm for finding the K shortest-loopless network paths. Proc. 41st Mtg.
Operations Research Society of America, vol. 20, p. B/185, 1972.
[70] D. Eppstein. Finding the k shortest paths. SIAM Journal on Computing, 28(2):652–673, April 1999.

 

K Shortest Paths算法之Eppstein algorithm Eppstein的算法是David Eppstein于1998年提出的一种高效且易于实现的k条最短路径寻找方法。 阅读详情

相关推荐

图论算法(3)--- A*算法求k短路

在一个图中,如何求出前k短路,

VV 1986

求解前K短路径--Yen算法,C++实现

一、前K短路径含义 各个高校的数据结构或算法的教材普遍会介绍求解最短路径的问题。 最短路径问题一般分为两种: 单源最短路径,即指定点到其余个点的路径; 两对顶点之间的最短路径。 狭义的最短路径问题只能求解出一条最短的路径,但是很多时候我们需要知道第二短,第三短......等次优解、次次优解问题,而本文介绍的Yen算法就是解决此类问题的一种算法。 Yen算法是由发明者的...

qq_52642915的博客 3147

浅谈K短路算法(KSP)之一(A*算法求解)

对于简单图,K短路,是指的起点s到终点t的第K个最短路径

robator的专栏 4111

第K短路径问题

第 KKK 短路径(the K Shortest Path,KSP)问题是对最短路径问题的扩展。众所周知,使用 DijsktraDijsktraDijsktra 算法能够确定最短路径,但是在某些情形下,我们除了想知道最短路径外,还想知道次短路径、第三短路径等等[1]。一个现实中的例子就是在使用“高德地图”的时候,需要从某个出发点到达一个目标点,在查询驾车路线时,“高德地图”一般会给出三条候选路径,一条路径具有最少的行车时间,一条具有最短的行车距离,另外一条是备用路线,这三条路径可能具有不同的路径长度,“高德

寂静山林 5221

前k条最短路径(KSP)算法文献

压缩文当中包括了25篇中英文文献(23篇英文以及2篇这种文),均取自网络。 所有算法文献均以Yen先生的Delete算法和Martin先生的Devation算法为基础。

最短路径算法实现 k-shortest-paths

最短路径算法实现 k-shortest-paths

前 k 条最短路径算法

[注:为了简便我这里只列出算法的步骤和伪代码,详细的数学证明请参见相关论文。C++代码的算法实现可以在我的sourceforge目录https://sourceforge.net/projects/ksp 下载使用。特别要指出的是葡萄牙教授Martins对此算法有深入研究,发表了为数众多的相关论文,我这里采用的也是基于他早期提出的deletion algorithm。Martins的Fortr

仰望星空的麦兜 4542

Flink CDC 1.18.1 Oracle 数据同步到postgresql

8、修改Flink的配置文件,主要是各种服务的绑定地址,默认为localhost,统统改为0.0.0.0,如:rest.address: 0.0.0.0 #localhost。将flink-sql-connector-oracle-cdc-3.0.1.jar复制到flink-1.18.1/lib目录中。6、下载 flink-connector-jdbc-3.1.1-1.17.jar,postgresql-42.7.3.jar。7、安装postgresql就不说了,相信你已经有了数据库了。

ynzhangyao的专栏 1799

前k条最短路径算法

一、算法说明 Deletion Algorithm删除算法的核心是通过在有向图中已有的最短路径上删除某条弧,并寻找替换的弧来寻找下一条可选的最短路径。删除算法实际上是通过在有向图中增加附加节点和相应的弧来实现的。算法描述如下: 1.利用Dijkstra算法求得有向图(N,A)中以开始节点s为根的最短路径树(注意,这里的最短路径树并不是最小生成树,因为Dijkstra算法并不保证能生成最

Ghost 2391

SAP 财务接口开发:完全清账 vs 标准过账的 CO-PA(获利能力字段) 赋值全解析(含设计哲学)

用于完全清账场景:用于标准凭证过账/部分清账两者对 CO-PA 数据的传递方式截然不同。本文不仅提供完整的代码实现,更深入解析为什么 SAP 要这样设计——了解设计哲学,才能灵活应对各类需求。完全清账→ 调用,必须在T_FTPOST中传递,其他特征用BSEG-RKE_前缀。标准过账/部分清账→ 调用,在CRITERIA表中传递特征,字段名直接用WERKSARTNR等。SAP 的设计智慧面向不同场景,采用不同机制,各司其职。通过接口抽象,将复杂的 CO-PA 配置逻辑封装在内部,对外提供简洁的调用方式。

Pegasus666的博客 328

ENVI 5.6保姆级教程:高分七号DLC影像从打开到融合的完整流程(附避坑指南)

本文详细介绍了ENVI 5.6处理高分七号DLC影像的完整流程,包括环境准备、数据解压、正射校正、图像融合等关键步骤。特别针对国产卫星数据处理的独特挑战,提供了实用的避坑指南和优化技巧,帮助用户高效完成光学影像的预处理和质量提升。

weixin_33269743的博客 382

YEN--K最短路算法(K-Shortest-Path) Java实现

前段时间要做一个Project,在建模过程中发现要求出一个网络拓扑中的前K条最短路才能进行后续的运算,自己研究了一段时间,实现了java版本的YEN--ksp算法。 Yen's算法是Yen 在1971 年提出的以其名字命名 的Yen 算法。Yen's算法基于偏离路径算法思想,算法原理详见https://en.wikipedia.org/wiki/Yen%27s_algorithm 我自己实现的...

lovemylife1234的博客 4579

S32的进阶之路->3,S32DS新建/删除/导入工程

右击工程名,点击Delect进行工程删除。选中Delect project contents on disk则会彻底删除工程,不选中Delect project contents on disk工程文件会保存在工作空间中。在Improt Projects中选择工程所在文件夹,选中所需要导入的工程,勾选Copy projects into workspace。选中目标示例工程,点击Finish,完成创建工程。导入已有工程,右击右击Project Explorer空白处,选择Import。

LC_8575的博客 2226

KSP算法的实现(Top-k-shortest paths 的Matlab实现)

摘要 本文主要讲述前K条最短路径的Matlab的实现。 1. all_paths_gen.m函数 function [] = all_paths_gen(weight_matrix, k, output_file) len = length(weight_matrix); fileID = fopen(output_file,'wt'); fprintf(fileID,'%d

林微的博客 1万+

Delft3D从入门到实践:安装、编译与首次模拟指南

本文为Delft3D初学者提供了一份详尽的从零开始指南。内容涵盖软件获取、许可证申请、图形界面安装、核心计算内核的编译环境搭建与编译步骤,以及最终整合运行首个水动力模拟的全流程。重点解决了Windows系统下Delft3D安装与编译的常见问题,帮助用户快速上手这一开源水动力与泥沙输运模拟工具。

weixin_29303701的博客 538

爆破shadow文件密码脚本(完成版)

由于添加了一个for循环,再稍作修改,让password not found!print(f"Trying password:")显示爆破的密码和过程。将代码中的password="123456"替换成下面代码。line.strip()函数首尾去空格。

m0_56578216的博客 771

利用JGraphT 库的KShortestPathAlgorithm<V, E> 接口计算前K条最短路径

KShortestPathAlgorithm 是 JGraphT 库中的一个接口,用于计算从一个起点到一个终点的前 K 条最短路径。这个接口主要适用于需要找到多条最短路径的场景,而不仅仅是单条最短路径。

bxdxstu的博客 540

华为OD机试真题新系统-空间占用计算(Py/Java/C/C++/Js/Go)

华为OD机试新系统机试真题 【空间占用计算】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【空间占用计算】。

qq_45776114的博客 3439

第k短路

最短路,即第1短路有很多种求法,SPFA,Dijkstra等,但第k短路怎么求呢?其实也是基于Dijkstra;因为Dijkstra用的是堆优化,这样保证每次弹出来的都是最小值,只是求最短路只是弹出一次就返回了,我们可以用Dijkstra弹出k个距离后再返回,这样根据弹出的先后顺序能够求出1~k短路 #include <bits/stdc++.h> using namesp...

weixin_30919919的博客 85

优快云独家首发!万字长文,YOLOv5/v7/v8算法模型yaml文件史上最详细解析与教程!小白也能看懂!掌握了这个就掌握了魔改YOLO的核心!

🍀🍀🍀YOLOv5/v7/v8算法模型yaml文件史上最详细解析与教程,全网最强,学不会算我输!!!

Coding... 1万+

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

K 最短路问题

**转载sharpdew《https://blog.youkuaiyun.com/sharpdew/article/details/446510》 在此基础上增加了一点自己的理解 推荐与论文《A SHORTEST PATHS RANKING ALGORITHM》一起看会比较好理解。** 前K个最短路径生成方法: Step 1: 利用Dijkstra算法求得有向图(N,A)中以开始节点s为根的最短路径树,标记从开始节点s到结束节点t之间的最短路径为pk,K=1。 记录原点到当前节点k的最短路径πk和最短路径中节点k的前

qq_38424395的博客 1001

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

【最短路】【k短路】【Usaco2008 Mar】牛跑步

洛谷P2901 Description BESSIE准备用从牛棚跑到池塘的方法来锻炼. 但是因为她懒,她只准备沿着下坡的路跑到池塘, 然后走回牛棚. BESSIE也不想跑得太远,所以她想走最短的路经. 农场上一共有M (1 <= M <= 10,000)条路, 每条路连接两个用1..N(1 <= N <= 1000)标号的地点. 更方便的是,如果X>Y,则地点X的...

qq_43398760的博客 457

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

【BZOJ】1598 [Usaco2008 Mar]牛跑步 k短路(最短路径+A*)

题目传送门 补一发k短路(虽然以前会的,但是现在好像都忘光了……在学习的过程中还是要多复习啊)。 恩?这题不就是k短路的模板题吗?题意已经很明确了,就是让我们求前k短路的长度,若不存在则输出-1。 然后就是喜闻乐见的套模板……然后就是打板子的时候了。 不过OLE也是比较少见的,今天竟然被我弄出来了一个:已经找完k短路了,但是忘记退出a*函数了…… 打板子也不能放松啊,基础才是最重要的。(

Chester King 385

POJ 2449 Remmarguts' Date K最短路问题(单源点最短路径+A*算法)

算法解释感谢Jarily  http://blog.youkuaiyun.com/jarily/article/details/8871968 /* *算法引入: *在单源点最短路径问题中,实际运用时还需知道最短路径外,次短路或者第三短路; *即要知道多条最短路,并排出其长度增加的顺序,即为K最短路问题; * *算法思想: *单源点最短路径+高级搜索A*; *A*算法结合了启发式方法和形式化方

Veda_的专栏 1078
上一篇: 搜索引擎中几种语言模型的性能比较
下一篇: Indri 信息检索模型
sharpdew
博客等级 码龄23年 76粉丝 35原创
评论 31
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值