MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / merge

Method merge

DEVELOPER/core/Graph.cpp:272–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270
271
272int
273Graph::merge(Graph &other) {
274
275 int result =0;
276 VertexIter &otherVertices = other.getVertices();
277 Vertex *vertexPtrOther;
278
279 // loop through other creating vertices if tag not the same in this
280 while ((vertexPtrOther = otherVertices()) != 0) {
281 int vertexTag = vertexPtrOther->getTag();
282 Vertex *vertexPtr = this->getVertexPtr(vertexTag);
283 if (vertexPtr == 0) {
284 int vertexRef = vertexPtrOther->getRef();
285 vertexPtr = new Vertex(vertexTag, vertexRef);
286 if (vertexPtr == 0) {
287 opserr << "Graph::merge - out of memory\n";
288 return -1;
289 }
290 this->addVertex(vertexPtr, false);
291 }
292 }
293
294
295 // loop through other adding all the edges that exist in other
296 VertexIter &otherVertices2 = other.getVertices();
297 while ((vertexPtrOther = otherVertices2()) != 0) {
298 int vertexTag = vertexPtrOther->getTag();
299 const ID &adjacency = vertexPtrOther->getAdjacency();
300 for (int i=0; i<adjacency.Size(); i++) {
301 if (this->addEdge(vertexTag, adjacency(i)) < 0) {
302 opserr << "Graph::merge - could not add an edge!\n";
303 return -2;
304 }
305 }
306 }
307
308 return result;
309}
310
311
312void

Callers

nothing calls this directly

Calls 6

getVertexPtrMethod · 0.95
addVertexMethod · 0.95
addEdgeMethod · 0.95
getTagMethod · 0.45
getRefMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected