Блог пользователя DarkSilver

Автор DarkSilver, история, 23 месяца назад, По-английски

Given a directed graph, source node and destination node you have to start from source with value 1 and reach destination node along some path where each edge has a multiple associated with it. Find the maximum value you can attain? Assume, if cycles exists it does not increases value to greater than 1.

Can we use Dijkstra's algorithm here or a quadratic dp+dfs is more appropriate?

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Dijkstra won't work for this problem.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by DarkSilver (previous revision, new revision, compare).

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

multiple of what, exactly?

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

Taking the logarithm of each value will make your problem identical to the single source longest path problem. Following the analysis of such a problem, a Dijkstra's algorithm works if and only if your original graph doesn't contain edges with a value (or multiple as you stated it) more than 1, which would correspond to a positive weight on the transformed graph.

I don't get your 'quadratic dp+dfs' though, for it seems that it only works on DAGs. On more general graphs one might suggest using Bellman-Ford to solve this problem.