I (almost) fully understand the Zipper data structure for trees. However, in some publications I saw hints that it is also possible to use the Zipper idea to create immutable functional data structure for arbitrary graphs (which might have cycles as well).
What's the way to do it?
As soon as we have cycles, it means that any node can be reached via several paths. Hence, if I focus on a node, do some change to it, and move the focus away, I might later on come back to the same node via a different path, which means that it would be an 'old' version of the node, prior to the change made.
The only solution I came up with is to include to the context the list of changes to any node. Every time before the focus is changed to node X, it should be checked whether X is the member of the list of changes, and if so, it should be taken as the focused node.
If we also track the number of times N node X was copied from the list of changes, we can remove X from the list of changes, as soon as N = number of edges, inward to X.
Is there any better way to do it?