algorithm - highest weighted path for multiple destinations -
i have directed cyclic weighted graph. want find path highest of weights, in length of x vertices, , don't care destination. want find highest cost.
this can solved via dynamical-programming-like algorithm.
as have few hundreds of nodes , x round 10. can assign each node v array fv size x, , fv[i] represents maximum cost source node v length i.
let s source. set fs[0] = 0, , other fs[i] = -infinity.
all other arrays initialized -infinity array.
now,
for each node v, following update:
fv[i] = max{fv[i], fw[i-1] + cost(w, v) | w neighbor of v}
repeat above updates @ least x times, , check fv[x] v maximum possible value want.
you can use information retrieve path, should easy do.
above algorithm special case of bellman-ford algorithm
Comments
Post a Comment