| 187 | } |
| 188 | |
| 189 | void RelationshipsImpl::copy( |
| 190 | const RelationshipsImpl& impl, const ModelCopyMapping& mapping ) |
| 191 | { |
| 192 | graph_ = impl.graph_->clone(); |
| 193 | initialize_attributes(); |
| 194 | std::vector< index_t > vertices_to_delete; |
| 195 | for( const auto vertex_id : Range{ graph_->nb_vertices() } ) |
| 196 | { |
| 197 | const auto& component_id = component_from_index( vertex_id ); |
| 198 | if( mapping.has_mapping_type( component_id.type() ) |
| 199 | && mapping.at( component_id.type() ) |
| 200 | .has_mapping_input( component_id.id() ) ) |
| 201 | { |
| 202 | const auto& new_uuid = mapping.at( component_id.type() ) |
| 203 | .in2out( component_id.id() ); |
| 204 | ids_->set_value( |
| 205 | vertex_id, { component_id.type(), new_uuid } ); |
| 206 | uuid2index_.set_new_mapping( new_uuid, vertex_id ); |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | vertices_to_delete.push_back( vertex_id ); |
| 211 | } |
| 212 | } |
| 213 | if( vertices_to_delete.empty() ) |
| 214 | { |
| 215 | return; |
| 216 | } |
| 217 | std::vector< bool > edges_to_delete( graph_->nb_edges(), false ); |
| 218 | for( const auto vertex_id : vertices_to_delete ) |
| 219 | { |
| 220 | for( const auto& edge : |
| 221 | graph_->edges_around_vertex( vertex_id ) ) |
| 222 | { |
| 223 | edges_to_delete[edge.edge_id] = true; |
| 224 | } |
| 225 | } |
| 226 | auto builder = GraphBuilder::create( *graph_ ); |
| 227 | builder->delete_edges( edges_to_delete ); |
| 228 | const auto old2new = |
| 229 | builder->delete_isolated_vertices( vertices_to_delete ); |
| 230 | uuid2index_.update( old2new ); |
| 231 | } |
| 232 | |
| 233 | void RelationshipsImpl::initialize_attributes() |
| 234 | { |
nothing calls this directly
no test coverage detected