represent a tree using adjacent matrix, and dfs