Computing Tree Structures in Anonymous Graphs via Mobile Agents