public boolean removeVertex ( Vertex < T > v ) { if ( ! verticies . containsValue ( v ) ) return false ; verticies . remove ( v . getName ( ) ) ; if ( v == rootVertex ) rootVertex = null ; // Remove the edges associated with v for ( int n = 0 ; n < v . getOutgoingEdgeCount ( ) ; n ++ ) { Edge < T > e = v . getOutgoingEdge ( n ) ; v . remove ( e ) ; Vertex < T > to = e . getTo ( ) ; to . remove ( e ) ; edges . remove ( e ) ; } for ( int n = 0 ; n < v . getIncomingEdgeCount ( ) ; n ++ ) { Edge < T > e = v . getIncomingEdge ( n ) ; v . remove ( e ) ; Vertex < T > predecessor = e . getFrom ( ) ; predecessor . remove ( e ) ; } return true ; }
Remove a vertex from the graph