java - Levenshtein Distance-like algorithm for diffing in-memory objects? -


java 8 here, though answer should apply lang.

i have problem need compare objects, say, widgets, , produce "diff" between them: is, set of steps that, if followed, transform 1 widget (the source) other (the target).

class widget {     // properties , such. }  class widgetdiffer extends differ<widget> {     list<transformation> diff(widget source, widget target) {         // produced list convert source target, if executed         // runtime.     } }  class widgettransformer extends transformer<widget> {     @override     widget transformsourcetotarget(widget source, list<transformation> transforms) {         // somehow, run 'transforms' on 'source', *should*         // produce object same state/properties         // original target.     } } 

i aware of levenshtein distance algorithm string transformations, but:

  • that's strings, not widgets; and
  • it gives integer (# of transformations required turn sink target), whereas need list<transformation> that, when executed engine, turns source target

i'm wondering if there known algorithms doing type of operations. chance these algorithms live in library somewhere?!?

i see search problem. construct graph destination node desired widget , start node widget transformed. each step (edge in graph) represents 1 possible transformation widget (adding or removing properties). once graph constructed run dfs path-extraction on , steps needed transform starting widget desired 1 (it minimum ammount of steps needed).


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -