special case graph as tree