How does this really work?
Treat the image as a graph
q
c
p
Graph
node for every pixel p
link between every adjacent pair of pixels, p,q
cost c for each link
Note:  each node has a cost
this is a little different than the figure before where each pixel
had a cost