Map problem to Graph
Weight represents cost of going
from one pixel to another.
Next
term in sum.