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

Method addVertex

SRC/graph/graph/Graph.cpp:133–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131// before the vertex is added.
132
133bool
134Graph::addVertex(Vertex *vertexPtr, bool checkAdjacency)
135{
136 // check the vertex * and its adjacency list
137 if (vertexPtr == 0) {
138 opserr << "WARNING Graph::addVertex";
139 opserr << " - attempting to add a NULL vertex*\n";
140 return false;
141 }
142
143 if (checkAdjacency == true) {
144 if (vertexPtr->getDegree() != 0) {
145 const ID &adjacency = vertexPtr->getAdjacency();
146 int size = adjacency.Size();
147 for (int i=0; i<size; i++) {
148 Vertex *other = this->getVertexPtr(adjacency(i));
149 if (other == 0) {
150 opserr << "WARNING Graph::addVertex";
151 opserr << " - vertex with adjacent vertex not in graph\n";
152 return false;
153 }
154 }
155 }
156 }
157
158
159 bool result = myVertices->addComponent(vertexPtr);
160 if (result == false) {
161 opserr << *this;
162 opserr << "BAD VERTEX\n: " << *vertexPtr;
163 opserr << "WARNING Graph::addVertex";
164 opserr << " - vertex could not be stored in TaggedObjectStorage object\n";
165 }
166
167
168 // check nextFreeTag
169 if (vertexPtr->getTag() >= nextFreeTag)
170 nextFreeTag = vertexPtr->getTag() + 1;
171
172 return result;
173}
174
175
176// int addEdge(int vertexTag, int otherVertexTag);

Callers 15

GraphMethod · 0.95
mergeMethod · 0.95
recvSelfMethod · 0.95
mainFunction · 0.45
mainFunction · 0.45
buildEleGraphMethod · 0.45
buildNodeGraphMethod · 0.45
buildEleGraphMethod · 0.45
partitionMethod · 0.45
releaseBoundaryMethod · 0.45
AnalysisModel.cppFile · 0.45

Calls 5

getVertexPtrMethod · 0.95
getDegreeMethod · 0.45
SizeMethod · 0.45
addComponentMethod · 0.45
getTagMethod · 0.45

Tested by

no test coverage detected