5 ms·
Can someone ELI12? How big of a deal is this for real world applications? Presentation by Aaron Bernstein (coauthor) on the paper https://www.youtube.com/watch
by sitkack 4y ago
Can someone ELI12? How big of a deal is this for real world applications?
Presentation by Aaron Bernstein (coauthor) on the paper https://www.youtube.com/watch?v=Bpw3yqWT_d0 https://www.youtube.com/watch?v=Bpw3yqWT_d0
Presentation by Danupon Nanongkai (coauthor) on the paper https://www.youtube.com/watch?v=awvBpvlbG1M https://www.youtube.com/watch?v=awvBpvlbG1M
Implementation in Java https://github.com/nevingeorge/Negative-Weight-SSSP https://github.com/nevingeorge/Negative-Weight-SSSP
- hammock 4y agoThis article helped me (I’m not a math guy at all, just a quick learner) https://algs4.cs.princeton.edu/44sp/ https://algs4.cs.princeton.edu/44sp/ Read the top section then the first answer in the Q&A at the bottom. Basically the problem is to find the least-cost (shortest) path across a graph of nodes from point a to point b, but the best algorithm we have (Djikstra’s) runs in exponential time in the worst case when there are some negative edge weights (see context below). This guy found an algorithm that runs must faster, in near-linear time. Context that is helpful is to think of edge weights not as distances, but as time or cost (this allows negative weights). Imagine a process workflow or something. Another helpful context that emerges from this is “negative cycle” which is an endless loop of negative weight edges (therefore asking an algorithm to find the “shortest” lowest weight path from one point to another that includes that cycle will fail). You can have negative weights without negative cycles though
- ithinkso 4y ago> but the best algorithm we have (Djikstra’s) runs in exponential time in the worst case Dijkstra doesn't handle negative weights so in that case you can use Ford-Bellman. It's slower than Dijkstra but far from exponential - O(VE) or something like that.
- hammock 4y ago> Dijkstra doesn't handle negative weights I took this straight from the Q&A I referenced in my link: Q. Does Dijkstra's algorithm work with negative weights? A. Yes and no. There are two shortest paths algorithms known as Dijkstra's algorithm, depending on whether a vertex can be enqueued on the priority queue more than once. When the weights are nonnegative, the two versions coincide (as no vertex will be enqueued more than once). The version implemented in DijkstraSP.java (which allows a vertex to be enqueued more than once) is correct in the presence of negative edge weights (but no negative cycles) but its running time is exponential in the worst case.
- thaumasiotes 4y ago> The version implemented in DijkstraSP.java (which allows a vertex to be enqueued more than once) is correct in the presence of negative edge weights (but no negative cycles) This is a strange parenthetical. No shortest-path algorithm can be correct in the presence of a negative cycle; the concept of "shortest path" does not apply to such a graph.
- ghusbands 4y agoI suspect it's to make clear to the peanut gallery that there is indeed a valid shortest path in the tests they were doing.
- deleted 4y ago[deleted]
- sitkack 4y agoThe video presentation from the author is approachable even for a non-domain expert. It looks like this has pretty broad applicability to applications in chemical processes, scheduling, logistics (pick ups and drop offs along the route), re-fueling, etc. I think @DropPanda gave a great example of regenerative charging in an EV. In the video the author does use cost/price-function terminology. Djikstra doesn't handle negative weights, Bellman-Ford is optimal for positive edge only. This apparently is also easier to parallelize. The Quanta article mentioned below is excellent https://www.quantamagazine.org/finally-a-fast-algorithm-for-shortest-paths-on-negative-graphs-20230118/ https://www.quantamagazine.org/finally-a-fast-algorithm-for-...
- spritefs 4y ago> Bellman-Ford is optimal for positive edge only. ??? CLRS says it takes negative weight edges (just no negative cycles) and does it in O(VE). I have no idea where you're getting this from
- meindnoch 4y ago>Bellman-Ford is optimal for positive edge only What do you mean “optimal”? The Bellman-Ford algorithm gives you the shortest path, period.
- rcme 4y agoIt doesn't seem like the shortest path on a graph with negative cycles would be defined for any algorithm.
- hammock 4y agoRight
- tejtm 4y ago"single source shortest acyclic path" would be the closest term that could make sense
- tylerhou 4y agoNit: In a graph with negative cycles, shortest paths are still well-defined for vertices s to t if there is no path from s to a negative cycle or if there is no path from a negative cycle to t. In the simplest case, suppose you have a graph with exactly one negative cycle that is completely isolated from the rest of the graph. The shortest paths between vertices in the negative cycle are not well-defined, but the shortest paths in the rest of the graph are well-defined. In general, look at the meta-DAG induced by the SCC decomposition of the graph. Mark any meta-vertices whose SCC contains some negative cycle. For s, t in the original graph, the distance from s to t is well-defined iff there exists no path from s's meta-vertex to t's meta-vertex in the meta-graph that traverses through a marked meta-vertex. (Proof left to the reader.)
- munchler 4y agoWouldn't a negative cycle be a good thing? You could drive the total cost down as low as you want before exiting the loop.
- londons_explore 4y agoYes, but the 'lowest' cost path is then travel to cycle, go round loop infinity times, and then go to destination.
- vecter 4y agoNegative cycles are bad for the exact reason you said. Not "bad" from the perspective of "let's lower the cost as much as possible", but "bad" from the perspective that it violates certain assumptions of Dikjstra's algorithm which leads it to produce incorrect results. When have a negative weight cycle, you can drive down the cost to be arbitrarily low by running through that cycle as many times as you'd like. What does "shortest path" or "lowest cost path" mean in this context then? More info: https://stackoverflow.com/questions/13159337/why-doesnt-dijkstras-algorithm-work-for-negative-weight-edges https://stackoverflow.com/questions/13159337/why-doesnt-dijk...
- sitkack 4y agoI have seen this in video games where there is some resource that respawns too quickly and the players just end up cycling back to the powerup every n-seconds. Easy to get stuck in a local minimum.
- tylerhou 4y agoNit: It's not negative weight cycles that mess up Dijkstra's, it's negative weights in general. Dijkstra's is effectively a greedy algorithm for finding shortest paths. By their very nature greedy algorithms cannot "look ahead." If there is a negative weight edge locked behind a expensive edge, Dijkstra's won't be able to see the negative weight edge until it's too late. 10 A -----------------> C \ ^ \ 11 -15 / \-----> B -----/
- kzrdude 4y ago
- rhn_mk1 4y agoWhat are negative weights good for?
- hammock 4y agoImagine a step in a process that saves you cost/time (negative edge weight) if you do it at one point, but adds cost/time (positive edge weight) if you do it at a different point
- wjholden 4y agoAn interesting use case is if you want to need to apply graph algorithms to a problem where edges multiply instead of adding. Just take the log of the multiplier and now your multiplication problem is addition. For example, suppose you cannot exchange the US dollar for the Russian ruble. You have to go through some path such as USD -> EUR -> RUB. Of all possible paths, which one gives you the most favorable exchange? You can use Bellman-Ford to find out.
- deleted 4y ago[deleted]
- thaumasiotes 4y ago> For example, suppose you cannot exchange the US dollar for the Russian ruble. You have to go through some path such as USD -> EUR -> RUB. Of all possible paths, which one gives you the most favorable exchange? Why is it necessary to assume I can't exchange dollars directly for rubles? If that is possible, wouldn't I still want whatever path has the most favorable exchange rate?
- hammock 4y agoIt’s not. That’s the problem he’s defining. It’s a real world problem
- thaumasiotes 4y ago> An interesting use case is if you want to need to apply graph algorithms to a problem where edges multiply instead of adding. Just take the log of the multiplier and now your multiplication problem is addition. I don't see what this has to add over just using the weights as they are. Dijkstra's algorithm tracks the distance from a source node to a target node. There's nothing about the algorithm that says that distance must be the sum of all the edge weights along a path; if it's the product, the algorithm will work without any changes.[1] The only requirement on the distance function is that you know how to calculate d(s,t) from the two values d(s, t') and d(t', t). [1] You'll still have problems [with Dijkstra's algorithm] if some weights are greater than 1 and some aren't, which is the exact analog of the problems that occur when distance is additive and some weights differ in sign. But that has no bearing on whether you can use multiplication directly or you need to convert it to addition.
- tylerhou 4y agoNo comment on how useful this is for real world applications. But here is a technique of the algorithm. Most of my knowledge is from CS 270, where this was taught last week. (The course notes are public, the lecture is not.) https://cs270.org/spring23/lec/ https://cs270.org/spring23/lec/ A naïve attempt at adapting Dijkstra's to graphs with negative weight edges is to add a constant bias to every edge weight to make all weights positive, then run Dijkstra's. But that doesn't work because it changes the ordering of paths (wrt. cost) if their lengths differ. A path with length one will have its cost increased by B, while a path with length 100 will have its length increased by 100 * B. If the length-100 path was cheaper before adding the bias, after adding it bias it can be more expensive. So path ordering is not preserved. But that idea, modified slightly, is not too far off a technique that works. Instead of adding a weight to each edge, the technique is to add a weight to each vertex (call this phi(v)) and modify each edge (u, v)'s weight to w(u, v) + phi(u) - phi(v). It turns out that modifying each edge's weight in this way preserves the ordering of paths that start from s and end at t. Consider a path s -> a -> b -> t; its new weight under w_phi is: w(s, a) + phi(s) - phi(a) + w(a, b) + phi(a) - phi(b) + w(b, t) + phi(b) - phi(t) = phi(s) + w(s, a) + w(a, b) + w(b, t) - phi(t) Notice how phi(a) and phi(b) cancel each other out. In other words, any path from s to t's weight will be changed by exactly phi(s) - phi(t), which is a constant! Therefore, the ordering of paths under cost is preserved under this new weight function (weights modified by phi). This technique, called "price functions" is not novel -- it has been known from the 70's. The paper's main contribution is how to discover price functions very efficiently. The main way the paper does this as follows: first, decompose the graph into smaller strongly connected components (SCCs) whose paths have a "low" number of negative edge weight graphs by removing some small subset of edges (low diameter decomposition, or LDD). Second, recursively find a phi function that makes all edges in the interiors of these SCCs have positive weight. Third, modify that phi (since phis compose additively) for the DAG induced by the SCC decomposition: "fixup" weights of edges that cross from one SCC into another. Finally, modify that phi again to account for the edges that were removed from the graph. (This last part is usually "slow," but it turns out that it is fast because of the LDD algorithm tends to only remove a small number of edges in any path.) Glossed over a lot of things, and probably not completely accurate -- see the lecture notes or the paper for the real analysis.
- 4y ago
- AndrewKemendo 4y ago(Almost) Everything we do in machine learning and optimization uses some graph traversal algorithm In RL we use Bellman's equations as a core component and implementations of Dijkstra's are embedded in many software suites as a useful tools for navigation (navmesh) etc.... This algorithm is faster than all of those, so you know: The same but faster TL;DR: Everything will continue to speed up
- dilawar 4y agohttps://www.quantamagazine.org/finally-a-fast-algorithm-for-shortest-paths-on-negative-graphs-20230118/ https://www.quantamagazine.org/finally-a-fast-algorithm-for-...