void GenGraph< Config >::removeEdge( WeakEdge edge ) { SharedEdge edgePtr = edge.lock(); if ( edgePtr == nullptr ) throw gtpo::bad_topology_error( "gtpo::GenGraph<>::removeEdge(): Error: Edge to be removed is already expired." ); auto source = edgePtr->getSrc().lock(); auto destination = edgePtr->getDst().lock(); auto hDestination = edgePtr->getHDst().lock(); if ( source == nullptr || // Expecting a non null source and either a destination or an hyper destination ( destination == nullptr && hDestination == nullptr ) ) throw gtpo::bad_topology_error( "gtpo::GenGraph<>::removeEdge(): Error: Edge source or destination are expired." ); BehaviourableBase::notifyEdgeRemoved( edge ); source->removeOutEdge( edge ); if ( destination ) // Remove edge from destination in edges destination->removeInEdge( edge ); if ( hDestination ) // Remove edge from hyper destination in hyper edges hDestination->removeInHEdge( edge ); // If there is in hyper edges, remove them since their destination edge is beeing destroyed if ( edgePtr->getInHDegree() > 0 ) { auto& inHEdges{ edgePtr->getInHEdges() }; // Make a deep copy of in hyper edges for ( auto& inHEdge : inHEdges ) removeEdge( inHEdge ); } edgePtr->setGraph( nullptr ); Config::template remove<SharedEdges>::from( _edges, edgePtr ); Config::template remove<WeakEdgesSearch>::from( _edgesSearch, edge ); }
void Vertex::removeEdge(Edge *edge) { removeOutEdge(edge); removeInEdge(edge); }