That sounds like a minimum spanning tree, try using Prim's algorithm and storing the order of addition in a list you would get that sorting.
確定! 回上一頁