MCPcopy Create free account
hub / github.com/Kitware/VTK / AddEdgeInternal

Method AddEdgeInternal

Common/DataModel/vtkGraph.cxx:1301–1354  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1299}
1300//------------------------------------------------------------------------------
1301void vtkGraph::AddEdgeInternal(
1302 vtkIdType u, vtkIdType v, bool directed, vtkVariantArray* propertyArr, vtkEdgeType* edge)
1303{
1304 this->ForceOwnership();
1305 if (this->DistributedHelper)
1306 {
1307 this->DistributedHelper->AddEdgeInternal(u, v, directed, propertyArr, edge);
1308 return;
1309 }
1310
1311 if (u >= this->GetNumberOfVertices() || v >= this->GetNumberOfVertices())
1312 {
1313 vtkErrorMacro(<< "Vertex index out of range");
1314 return;
1315 }
1316
1317 vtkIdType edgeId = this->Internals->NumberOfEdges;
1318 vtkIdType edgeIndex = edgeId;
1319 this->Internals->NumberOfEdges++;
1320 this->Internals->Adjacency[u].OutEdges.emplace_back(v, edgeId);
1321 if (directed)
1322 {
1323 this->Internals->Adjacency[v].InEdges.emplace_back(u, edgeId);
1324 }
1325 else if (u != v)
1326 {
1327 // Avoid storing self-loops twice in undirected graphs.
1328 this->Internals->Adjacency[v].OutEdges.emplace_back(u, edgeId);
1329 }
1330
1331 if (this->EdgeList)
1332 {
1333 this->EdgeList->InsertNextValue(u);
1334 this->EdgeList->InsertNextValue(v);
1335 }
1336
1337 if (edge)
1338 {
1339 *edge = vtkEdgeType(u, v, edgeId);
1340 }
1341
1342 if (propertyArr)
1343 {
1344 // Insert edge properties
1345 vtkDataSetAttributes* edgeData = this->GetEdgeData();
1346 int numProps = propertyArr->GetNumberOfValues();
1347 assert(numProps == edgeData->GetNumberOfArrays());
1348 for (int iprop = 0; iprop < numProps; iprop++)
1349 {
1350 vtkAbstractArray* array = edgeData->GetAbstractArray(iprop);
1351 array->InsertVariantValue(edgeIndex, propertyArr->GetValue(iprop));
1352 }
1353 }
1354}
1355
1356//------------------------------------------------------------------------------
1357void vtkGraph::AddEdgeInternal(const vtkVariant& uPedigreeId, vtkIdType v, bool directed,

Callers 5

AddEdgeMethod · 0.80
LazyAddEdgeMethod · 0.80
AddEdgeMethod · 0.80
LazyAddEdgeMethod · 0.80
AppendBondMethod · 0.80

Calls 13

ForceOwnershipMethod · 0.95
GetNumberOfVerticesMethod · 0.95
AddVertexInternalMethod · 0.95
GetEdgeDataMethod · 0.80
GetAbstractArrayMethod · 0.80
vtkEdgeTypeClass · 0.70
assertFunction · 0.50
emplace_backMethod · 0.45
InsertNextValueMethod · 0.45
GetNumberOfValuesMethod · 0.45
GetNumberOfArraysMethod · 0.45
InsertVariantValueMethod · 0.45

Tested by

no test coverage detected