{(0, 0): {(0, 1), (1, 0)},
(0, 3): {(0, 2), (0, 4), (1, 3)},
(0, 4): {(0, 3), (1, 4)},
(1, 1): {(0, 1), (1, 0), (1, 2), (2, 1)},
(1, 2): {(0, 2), (1, 1), (1, 3), (2, 2)},
(2, 0): {(1, 0), (2, 1), (3, 0)},
(2, 2): {(1, 2), (2, 1), (2, 3), (3, 2)},
(2, 3): {(1, 3), (2, 2), (2, 4), (3, 3)},
(2, 4): {(1, 4), (2, 3), (3, 4)},
(3, 0): {(2, 0), (3, 1)},
(3, 1): {(2, 1), (3, 0), (3, 2)},
(3, 3): {(2, 3), (3, 2), (3, 4)}}
Above is a dictionary that I have obtained from a 2D List: keys -- tuples (co-ordinates) values -- set of tuples (co-ordinates)
The co-ordinates are cells in the 2D list.
My goal is to compare the value of given key with next key.
example: compare {(0, 2), (0, 4), (1, 3)}
with (0, 4)
.
If the key is present in the value of the previous key then I would like to update the first value with values of the key that was found. For the given example: the result should be something like: {(0, 2), (0, 4), (1, 3), (0, 3), (1, 4)}
.
I would like to know if this is even possible? Is there a way to compare values of a dictionary with keys of the same dictionary?
I was also thinking of using DFS but I do not have all the vertices for that. Is DFS the right approach?