Adjacency Map - How to remove a edge from a Graph
You should have HashMap (or dict in python) with Keys some kind of Node-index and Values to be for example HashSet (or set in python) of Node-indexes, edges from given Key node reach to.
For example {1: {2, 3}, 2: {1, 3}, 3: {1}} means, you have 3 nodes: 1, 2, 3 and eges are: [1, 2], [1, 3], [2, 1], [2, 3], [3, 1] - assuming it's directed graph. If you want to remove edge let's say 2, 3, obtain key (starting node of the edge) from your hashmap in O(1) time:
something like graph.get(2) which will return you your value - hashSet of Nodes edges lead to, in this case {1, 3}. From this set, you can remove 3 (end node) again in O(1) time.
Repeat this process for all edges you may have.
I'm in this problem for hours, because I can't find a method that can remove the edges from a adjacency map graph in O(1) time.
If anyone has any idea, it would be very helpful.