------------------------------------------------------------------------------
| 1299 | } |
| 1300 | //------------------------------------------------------------------------------ |
| 1301 | void 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 | //------------------------------------------------------------------------------ |
| 1357 | void vtkGraph::AddEdgeInternal(const vtkVariant& uPedigreeId, vtkIdType v, bool directed, |
no test coverage detected