On Wed, 8 Mar 2023 at 07:50, ZheNing Hu <adlternative@xxxxxxxxx> wrote: > > My question is: > 1. In step 3, why is the matrix size (a.nr + b.br) * (a.nr + b.br) > instead of a.nr * b.nr? There's some explanation of that in the man page for `git range-diff`, under "ALGORITHM". Look for "To explain also new commits, we introduce dummy nodes on both sides:". > 2. Why the cost(x,y) which satisfies "x ∈ [a.nr, a.nr + b.nr) y ∈ [0, > b.nr) || x ∈ [0, a.nr) y ∈ [b.nr, b. The cost of nr + a.nr)" is set to > "diffsize(a or b) * creation_factor / 100 : COST_MAX"? What is the > role of creation_factor? [1] The `--creation-factor` command line option is also described in the manpage. There was a thread on the mailing list with various discussions around this creation factor a while back. Maybe there's something interesting there [1]. > 3. How does LAPJV work here? [2] > > [1]: https://github.com/git/git/blob/725f57037d81e24eacfda6e59a19c60c0b4c8062/range-diff.c#L310 > [2]: https://github.com/git/git/blob/725f57037d81e24eacfda6e59a19c60c0b4c8062/linear-assignment.c#L15 This appears to be based on work by Jonker and Volgenant. Maybe searching for those names online could find something. Maybe not git-specific, but even if it's just the general algorithm as such, it might be possible to find different explanations of the algorithm. I haven't really studied this algorithm, but since it's faster than the Hungarian algorithm, I could imagine that either * it's super-useful to first understand the Hungarian algorithm, then understand why and how the Jonker-Volgenant algorithm does better, or, * it's completely useless to first understand the Hungarian algorithm, since they're so different. :-) [1] https://lore.kernel.org/git/1196830250.20220726145447@xxxxxxxxx/ Martin