This work extends the dynamic programming approach to calculation of an elastic metric between two curves to finding paths in pairs of graph drawings that are closest under this metric. The new algorithm effectively solves this problem when all paths between two given nodes in one of these graphs have the same length. It is then applied to the problem of pattern recognition constrained by a superpixel segmentation. Segmentations of test images, obtained without statistical modeling given two shape endpoints, have good accuracy.