(id: ElementId)
| 256 | } |
| 257 | |
| 258 | public deleteVertex(id: ElementId): void { |
| 259 | const [label, uuid] = parseElementId(id); |
| 260 | const collection = this.getVertexCollectionMap(label); |
| 261 | const data = collection.get(uuid); |
| 262 | if (data == null) { |
| 263 | throw new VertexNotFoundError(id); |
| 264 | } |
| 265 | this.transact(() => { |
| 266 | // For incoming edges, this vertex is the target (inV) |
| 267 | // We need to remove the edge from the source's outgoing edges |
| 268 | const incomingEdges = data.get($InEKey) as undefined | Y.Map<unknown>; |
| 269 | if (incomingEdges != null) { |
| 270 | for (const edgeId of incomingEdges.keys() as IterableIterator<ElementId>) { |
| 271 | const [edgeLabel, edgeUuid] = parseElementId(edgeId); |
| 272 | const edgeCollection = this.getEdgeCollectionMap(edgeLabel); |
| 273 | const edgeData = edgeCollection.get(edgeUuid); |
| 274 | if (edgeData == null) { |
| 275 | continue; |
| 276 | } |
| 277 | // Get the source vertex (outV) and remove from its outgoing edges |
| 278 | const sourceV = edgeData.get($OutVKey) as ElementId | undefined; |
| 279 | if (sourceV == null) { |
| 280 | continue; |
| 281 | } |
| 282 | const sourceOutgoingEdges = this.getVertexMap(sourceV)?.get($OutEKey) as |
| 283 | | undefined |
| 284 | | Y.Map<unknown>; |
| 285 | if (sourceOutgoingEdges != null) { |
| 286 | sourceOutgoingEdges.delete(edgeId); |
| 287 | } |
| 288 | edgeCollection.delete(edgeUuid); |
| 289 | } |
| 290 | } |
| 291 | // For outgoing edges, this vertex is the source (outV) |
| 292 | // We need to remove the edge from the target's incoming edges |
| 293 | const outgoingEdges = data.get($OutEKey) as undefined | Y.Map<unknown>; |
| 294 | if (outgoingEdges != null) { |
| 295 | for (const edgeId of outgoingEdges.keys() as IterableIterator<ElementId>) { |
| 296 | const [edgeLabel, edgeUuid] = parseElementId(edgeId); |
| 297 | const edgeCollection = this.getEdgeCollectionMap(edgeLabel); |
| 298 | const edgeData = edgeCollection.get(edgeUuid); |
| 299 | if (edgeData == null) { |
| 300 | continue; |
| 301 | } |
| 302 | // Get the target vertex (inV) and remove from its incoming edges |
| 303 | const targetV = edgeData.get($InVKey) as ElementId | undefined; |
| 304 | if (targetV != null) { |
| 305 | const targetIncomingEdges = this.getVertexMap(targetV)?.get($InEKey) as |
| 306 | | undefined |
| 307 | | Y.Map<unknown>; |
| 308 | if (targetIncomingEdges != null) { |
| 309 | targetIncomingEdges.delete(edgeId); |
| 310 | } |
| 311 | } |
| 312 | edgeCollection.delete(edgeUuid); |
| 313 | } |
| 314 | } |
| 315 | collection.delete(uuid); |
nothing calls this directly
no test coverage detected