A linear-time approximation algorithm for weighted matchings in graphs