Bottom-up algorithm to build subset of maximum weight
This is the maximum-weight independent set problem, which is known to be NP-hard.  Therefore, there is unlikely to be any efficient solution. However, you could use any of the standard algorithms for this problem, if you're willing to accept an exponential-time algorithm.