This question is most easy to describe as a modification of that my question.
Suppose that question is solved as the following Python class:
class Traversal(object): # ... def next(self): # next node of the graph # ...
Now I want to modify the algorithm: Sometimes I want to traverse to the next non-preferred node.
class Traversal(object): # ... def next(self): # next node of the graph # ... def next2(self): # next non-preferred node of the graph # ...
How to modify the algorithm to implement
Note that both
next2() return a graph node and this node should be recorded not to be traversed again.
Sorry I cannot describe the real example where this problem appears, it would be too verbose. You can see https://en.wikiversity.org/wiki/Automatic_transformation_of_XML_namespaces for the big problem I am solving.