MCPcopy Create free account
hub / github.com/codemix/graph / deleteEdge

Method deleteEdge

packages/y-graph-storage/src/YGraphStorage.ts:361–382  ·  view source on GitHub ↗
(id: ElementId)

Source from the content-addressed store, hash-verified

359 }
360
361 public deleteEdge(id: ElementId): void {
362 const [label, uuid] = parseElementId(id);
363 const collection = this.getEdgeCollectionMap(label);
364 const data = collection.get(uuid);
365 if (data == null) {
366 throw new EdgeNotFoundError(id);
367 }
368 // inV is the target, outV is the source
369 const inV = data.get($InVKey) as ElementId;
370 const outV = data.get($OutVKey) as ElementId;
371 const inVMap = this.getVertexMap(inV);
372 const outVMap = this.getVertexMap(outV);
373 this.transact(() => {
374 // Remove from target's incoming edges
375 const incomingEdges = inVMap.get($InEKey) as undefined | Y.Map<unknown>;
376 incomingEdges?.delete(id);
377 // Remove from source's outgoing edges
378 const outgoingEdges = outVMap.get($OutEKey) as undefined | Y.Map<unknown>;
379 outgoingEdges?.delete(id);
380 collection.delete(uuid);
381 });
382 }
383
384 protected getVertexMap(vertexId: ElementId): Y.Map<unknown> {
385 const [label, uuid] = parseElementId(vertexId);

Callers

nothing calls this directly

Calls 5

getEdgeCollectionMapMethod · 0.95
getVertexMapMethod · 0.95
transactMethod · 0.95
parseElementIdFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected