added algorithm to build tree from given list of edges