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

Method addEdge

SRC/graph/graph/Graph.cpp:184–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182// graph. Returns $0$ if successful, a negative number if not.
183
184int
185Graph::addEdge(int vertexTag, int otherVertexTag)
186{
187 // get pointers to the vertices, if one does not exist return
188
189 Vertex *vertex1 = this->getVertexPtr(vertexTag);
190 Vertex *vertex2 = this->getVertexPtr(otherVertexTag);
191 if ((vertex1 == 0) || (vertex2 == 0)) {
192 opserr << "WARNING Graph::addEdge() - one or both of the vertices ";
193 opserr << vertexTag << " " << otherVertexTag << " not in Graph\n";
194 return -1;
195 }
196
197 // add an edge to each vertex
198 int result = vertex1->addEdge(otherVertexTag);
199 if (result == 1)
200 return 0; // already there
201 else if (result == 0) { // added to vertexTag now add to other
202 if ((result = vertex2->addEdge(vertexTag)) == 0) {
203 numEdge++;
204 }
205 else {
206 opserr << " WARNING Graph::addEdge() - " << vertexTag;
207 opserr << " added to " << otherVertexTag;
208 opserr << " adjacency - but already there in otherVertexTag!.\n";
209 opserr << *this; exit(0);
210 return -2;
211 }
212 } else {
213 opserr << " WARNING Graph::addEdge() - " << vertexTag;
214 opserr << " added to " << otherVertexTag;
215 opserr << " adjacency - but not vica versa!.\n";
216 opserr << *this; exit(0);
217 return -2;
218 }
219 return result;
220}
221
222void
223Graph::startAddEdge() {

Callers 14

GraphMethod · 0.95
mergeMethod · 0.95
mainFunction · 0.45
mainFunction · 0.45
buildEleGraphMethod · 0.45
buildNodeGraphMethod · 0.45
buildEleGraphMethod · 0.45
AnalysisModel.cppFile · 0.45
mergeSubGraphMethod · 0.45
DOF_GroupGraphMethod · 0.45
DOF_GraphMethod · 0.45

Calls 2

getVertexPtrMethod · 0.95
exitFunction · 0.85

Tested by

no test coverage detected