昨天中午打饭等待时无聊,想了一下求K短路的多项式解法。在此之前大概了解过知道可以用A*解。具体做法是先从T做一次Dijkstra,用各点到T的最短路径作为估价函数。从S开始A*,在寻找过程中,使每个点都能被访问多次(即去掉close表),并且每次访问到一个点v并不需要到open表去查找判重,直接放到open中即可,那么第k次从open表中取出点T即是S-T的k短路(via Richard)。
由于之前明白了可以用堆来维护单调队列,通过单调队列的合并来求背包问题的前k优解,感觉应该也可适用于最短路算法。比如SPFA,使用单调队列来维护第k优值,判断是否在队列中时记录多一个最优值属性即可。在网上看到有人说这一算法的时间复杂度是O(KVE)的,但我不知道如何证明。
一开始没深入想,认为Dijkstra的处理只需要像背包那样每次更新最优路径时进行单调队列的合并即可。后来发现这样子会遗漏一部分路径。于是为了保证不遗漏路径,单调队列的处理会比较麻烦一些。可以证明若每个点出堆的次数都为k则可保证求得第k优路径。单调队列需要满足能够同时维护当前最优解(用于选取出堆点)和第k优解的值,我想到的解决方案是用一个min heap和max heap(要多记录一个信息,每个节点在min heap中的位置)来维护。后来在搜索过程中发现已经有了满足这一性质的堆:min-max heap和Deap,也可直接使用这两种数据结构进行维护。
不过以上两种算法都只能适用于k数值较小时,若k数值较大则只能用A*或转化为用二分判可行性的问题(参考SGU上某题)了。
转化为二分怎么做?给个小提示?
回复删除对于K比较大时,Yen算法和Eppstein算法都是比较适用的。
回ls,那个是lz乱吹的,lz一看就知道是那种没什么本事,但是说一通大话显得自己很厉害的那种人,你以为他很厉害么?放屁...我们队已经严密讨论过,二分不可能。
回复删除qihang0922,instyler max
回复删除tory burch outlet
ralph lauren outlet
gucci borse
jordan pas cher
ugg boots
longchamp handbags
air max
mulberry handbags
timberland boots
uggs on sale
mont blanc
fitflops sale clearance
michael kors handbags
air max 90
ugg sale
louis vuitton pas cher
replica watches
burberry outlet
ugg boots clearance
ugg outlet
fake oakleys
nike tn
pandora jewelry
louboutin
christian louboutin uk
hermes uk
cheap uggs
cheap jerseys
toms shoes
kate spade handbags
gucci shoes
michael kors
nike air force 1
nike air huarache
ray ban outlet
adidas superstar
tod's shoes
q
toms outlet, http://www.tomsoutlet-stores.com/
回复删除nike roshe, http://www.nikerosherunshoes.co.uk/
prada handbags, http://www.pradahandbagsoutlet.co.uk/
soccer jerseys, http://www.cheapsoccerjersey.net/
michael kors outlet store, http://www.michaelkorsoutlet-store.us.com/
true religion jeans, http://www.truereligionjeansoutlets.us.com/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
nike free 5, http://www.nikefree5.us/
louis vuitton bags, http://www.louisvuittonbag.us.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
chanel handbags, http://www.chanelhandbags-outlet.us.com/
louis vuitton handbags, http://www.louisvuittonhandbag.us/
louis vuitton outlet, http://www.louisvuittonoutlet.in.net/
ghd hair straighteners, http://www.ghdhairstraightenerssale.co.uk/
nba jerseys, http://www.nbajerseys.us.com/
coach outlet, http://www.coachoutletstores.com.co/
true religion jeans, http://www.truereligionjeanscanada.com/
swarovski crystal, http://www.swarovskicrystals.co.uk/
mbt shoes, http://www.mbtshoesoutlet.us.com/
michael kors handbags, http://www.michaelkorshandbags.in.net/
chanel handbags, http://www.chanelhandbagsoutlet.in.net/
michael kors outlet online, http://www.michaelkorsoutletonline.in.net/
polo ralph lauren, http://www.poloralphlauren.us.org/
the north face clearance, http://www.thenorthfaceclearances.us.com/
jordan shoes, http://www.jordan-shoes.us.com/
beats by dr dre, http://www.beatsbydrdre-headphones.us.com/
the north face uk, http://www.thenorthfaces.org.uk/
1003maoqiuyun
coach outlet online
回复删除oakley outlet
coach factory outlet
cheap ugg boots
nba jerseys
fitflops sale clearance
fitflops sale clearance
christian louboutin shoes
true religion outlet
louboutin pas cher
201612.26chenjinyan
rolex replica watches
回复删除ralph lauren uk
houston texans jerseys
ugg boots
oakley sunglasses
ugg boots
new balance shoes
hugo boss sale
oakley sunglasses
polo ralph lauren
polo ralph lauren
回复删除coach outlet
nike outlet store
ralph lauren outlet
ferragamo outlet
discount oakley sunglasses
coach outlet online
cheap ray ban sunglasses
20180829 xiaoou
回复删除toms outlet
ugg boots clearance
michael kors handbags
true religion outlet
ralph lauren outlet
ralph lauren outlet
jordan 4
mishka snapbacks
james harden shoes
michael kors outlet online
yeezys
回复删除adidas gazelle
yeezy boost
ultra boost
christian louboutin
moncler outlet
christian louboutin shoes
supreme
kd 11
supreme shirt