public void dfsSpanningTree ( Vertex < T > v , DFSVisitor < T > visitor ) { v . visit ( ) ; if ( visitor != null ) visitor . visit ( this , v ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; if ( ! e . getTo ( ) . visited ( ) ) { if ( visitor != null ) visitor . visit ( this , v , e ) ; e . mark ( ) ; dfsSpanningTree ( e . getTo ( ) , visitor ) ; } } }
Find the spanning tree using a DFS starting from v .