Understanding negative weight edges


So far, all the examples we considered for computing the single source shortest path were graphs with positive edge weights. However, many problems modeled as graphs may also have negative edge weights. To better understand these cases, let's look at a few real-world examples of such problems and how we can compute the single source shortest path for them.

Stages of chemical reaction

Complex chemical reactions often involve multiple stages where the transition from one stage to another requires a certain amount of energy.  When modeling the reactions as a graph, the nodes represent the stages, and the edge weights represent the amount of energy consumed. However, certain transitions may also release energy instead of consuming it, and those edges carry a negative weight as a consequence.

Liking the course? Check our discounted plans to continue learning.