1
If you take $S$ to be the sum of all the weights on all the edges in the graph and you add $S$ to all the weights in the graph, then a regular maximum weight matching will find you the matching you are looking for, since now with the large weights on all the edges, it will prefer a matching that uses the most number of edges first.
In your example of 1--2--3-...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
combinatorics × 593algorithms × 204
graphs × 99
optimization × 75
discrete-mathematics × 40
complexity-theory × 31
dynamic-programming × 31
permutations × 30
sets × 26
data-structures × 22
trees × 21
probability-theory × 19
algorithm-analysis × 16
word-combinatorics × 15
reference-request × 14
binary-trees × 14
recursion × 13
counting × 13
recurrence-relation × 12
matrices × 12
knapsack-problems × 12
time-complexity × 11
randomized-algorithms × 10
greedy-algorithms × 10
formal-languages × 9