@ Override public void remove ( ) { checkClass ( ) ; final OrientBaseGraph graph = checkIfAttached ( ) ; graph . setCurrentGraphInThreadLocal ( ) ; graph . autoStartTransaction ( ) ; final ODocument doc = getRecord ( ) ; if ( doc == null ) throw ExceptionFactory . vertexWithIdDoesNotExist ( this . getId ( ) ) ; Map < String , List < ODocument > > treeRidbagEdgesToRemove = new HashMap < String , List < ODocument > > ( ) ; if ( ! graph . getRawGraph ( ) . getTransaction ( ) . isActive ( ) ) { for ( String fieldName : doc . fieldNames ( ) ) { final OPair < Direction , String > connection = getConnection ( Direction . BOTH , fieldName ) ; if ( connection == null ) // SKIP THIS FIELD continue ; Object fv = doc . field ( fieldName ) ; if ( fv instanceof ORidBag && ! ( ( ORidBag ) fv ) . isEmbedded ( ) ) { List < ODocument > docs = new ArrayList < ODocument > ( ) ; for ( OIdentifiable id : ( ORidBag ) fv ) docs . ( OrientBaseGraph . getDocument ( id , true ) ) ; treeRidbagEdgesToRemove . put ( fieldName , docs ) ; } } } // REMOVE THE VERTEX RECORD FIRST TO CATCH CME BEFORE EDGES ARE REMOVED super . removeRecord ( ) ; // REMOVE THE VERTEX FROM MANUAL INDEXES final Iterator < Index < ? extends Element > > it = graph . getIndices ( ) . iterator ( ) ; if ( it . hasNext ( ) ) { final Set < Edge > allEdges = new HashSet < Edge > ( ) ; for ( Edge e : getEdges ( Direction . BOTH ) ) allEdges . ( ) ; while ( it . hasNext ( ) ) { final Index < ? extends Element > index = it . next ( ) ; if ( Vertex . class . isAssignableFrom ( index . getIndexClass ( ) ) ) { OrientIndex < OrientVertex > idx = ( OrientIndex < OrientVertex > ) index ; idx . removeElement ( this ) ; } if ( Edge . class . isAssignableFrom ( index . getIndexClass ( ) ) ) { OrientIndex < OrientEdge > idx = ( OrientIndex < OrientEdge > ) index ; for ( Edge e : allEdges ) idx . removeElement ( ( OrientEdge ) ) ; } } } for ( Map . Entry < String , List < ODocument > > entry : treeRidbagEdgesToRemove . entrySet ( ) ) { doc . removeField ( entry . getKey ( ) ) ; Iterator < ODocument > iter = entry . getValue ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ODocument docEdge = iter . next ( ) ; OrientBaseGraph . deleteEdgeIfAny ( docEdge , false ) ; } } graph . removeEdgesInternal ( this , doc , null , true , settings . isUseVertexFieldsForEdgeLabels ( ) , settings . isAutoScaleEdgeType ( ) ) ; }
Removes the current Vertex from the Graph . all the incoming and outgoing edges are automatically removed too .