Maximum Cost Spanning Tree Algorithm Code Sample