Build tree from edges
I have the edges and i want to build a tree with it. The problem is that i can construct my tree structure only when edges are in specific order. Example of orders: (vertex, parent_vertex) good: bad: (0, ) <-top (3, 2) (1, 0) (1, 0) (2, 1) (3, 2) (3, 2) (0, ) <-top I iterate throw the edges and for current vertex trying to find it's parent in created tree, then i construct the node and insert it. result tree: 0 - 1 - 2 - 3 So there is always must exist a parent in the tree for the new added vertex. The question is how to sort the input edges. Voices tells me about the topological sort, but it