I am copying a dict and removing element from it. But this is affecting the original dict:
ugraph = {0: {1}, 1: {0, 2}, 2: {1, 3}, 3: {2}}
print(ugraph)
graph = ugraph.copy()
graph[0].remove(1)
print(ugraph)
gives the output:
{0: {1}, 1: {0, 2}, 2: {1, 3}, 3: {2}}
{0: set(), 1: {0, 2}, 2: {1, 3}, 3: {2}}