Finding the shortest path in a graph without any negative prefixes

后端 未结 9 1880
北荒
北荒 2021-01-31 11:15

Find the shortest path from source to destination in a directed graph with positive and negative edges, such that at no point in the path the sum of edges coming

9条回答
  •  庸人自扰
    2021-01-31 11:49

    I would like to clarify a few points :

    1. yes there can be negative weight cycles.
    2. n is the number of edges.
    3. weights are arbitrary not just +1/-1.
    4. Assume that a O(n) length path exists if the problem has a solution. (n is number of edges)

提交回复
热议问题