weighted graph algorithm: min-weight spaning tree