add spanning tree code