public static int getWorstCaseEditDistance ( int sourceLength , int targetLength , int changeCost , int openGapCost , int continueGapCost ) { int maxLen = Math . max ( sourceLength , targetLength ) ; int minLen = Math . min ( sourceLength , targetLength ) ; // Compute maximum cost of changing one string into another. If the // lengths differ, you'll need maxLen - minLen insertions or deletions. int totChangeCost = scriptCost ( openGapCost , continueGapCost , maxLen - minLen ) + minLen * changeCost ; // Another possibility is to just delete the entire source and insert the // target, and not do any changes. int blowAwayCost = scriptCost ( openGapCost , continueGapCost , sourceLength ) + scriptCost ( openGapCost , continueGapCost , targetLength ) ; return Math . min ( totChangeCost , blowAwayCost ) ; }
Return the worst case edit distance between strings of this length