separated cost calc to DynamicEdgeDetector::getCost