Martin Ågren <martin.agren@xxxxxxxxx> 于2023年3月8日周三 15:47写道: > > 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:". > Thanks, I can understand why the length of the matrix is "a.nr + b.nr" now. Patches in one collection may have no matching patches in the other collection, this mismatch situation ("o--C" in the documentation) should also count the cost. > > 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]. > I understand it now. Because mismatch "o--C" "1--0" cost are generally greater than the cost of two completely different patches "1--C" "0--0". Use the creation-factor to reduce the cost of "0-C" "1--0" make "o--C", "1--0" as matching result. > > 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. > > :-) > Ah, I had a look at the Hungarian algorithm earlier, because it is the most typical algorithm in linear assignment problem, it can still be understood. I didn't read that paper by Jonker and Volgenant, but I should try to read it later. > [1] https://lore.kernel.org/git/1196830250.20220726145447@xxxxxxxxx/ > > Martin Thanks for the answer! -- ZheNing Hu