const graph = new DirectedGraph();
graph.addVertex('A');
graph.addVertex('B');
graph.addVertex('C');
graph.addEdge('B', 'A');
graph.addEdge('C', 'A');
// 'Incoming to A should contain ['B','C']
console.log(graph.incomingEdgesOf('A').map((e) => e.src)); // ['B','C']
// Now delete B, which has no direct link to C, only that C -> A.
graph.deleteVertex('B');
// Now if we do the same call to incoming edges for A we should get only ['C']
console.log(
graph.incomingEdgesOf('A').map((e) => e.src), // []
);
// but it only shows an empty array, since we deleted all of `A's edges, not just the one to `B`.
// If we check C, it correctly shows A as an outgoing edge,
// even though A no longer has any knowledge of C linking to it.
console.log(graph.outgoingEdgesOf('C').map((e) => e.dest));
Unless I'm fundamentally misunderstanding how this should work, deleting B should not wipe out all incoming edges to A, only the edges pointing at B.
Describe the bug Mostly what the title says.
Here is a simple reproduction
Unless I'm fundamentally misunderstanding how this should work, deleting B should not wipe out all incoming edges to A, only the edges pointing at B.
I tracked the issue here https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/graph/directed-graph.ts#L264, which I believe should be deleting an
edge
insideA
's set of edges, not all ofA
's edges.