Minimum spanning tree and Hamiltonian cycle generation