Source: https://www.tutorialspoint.com/data_structures_algorithms/pdf/spanning_tree.pdf