MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / copy

Method copy

src/geode/model/mixin/core/detail/relationships_impl.cpp:189–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 13

has_mapping_typeMethod · 0.80
typeMethod · 0.80
has_mapping_inputMethod · 0.80
atMethod · 0.80
set_new_mappingMethod · 0.80
emptyMethod · 0.80
cloneMethod · 0.45
nb_verticesMethod · 0.45
set_valueMethod · 0.45
nb_edgesMethod · 0.45
delete_edgesMethod · 0.45

Tested by

no test coverage detected