Words near spanning tree algorithm in the dictionary