Improved support for writing new algorithms in application code #21
Replies: 4 comments 8 replies
-
Approaches 4 & 5 are possible (maybe in addition to 1). |
Beta Was this translation helpful? Give feedback.
-
Some libraries provide a DFS that several visitors can be given to. Additional chance: Their return values can control how the DFS continues. Disadvantage: In Python, function calls are quite slow. But since the application can decide whether to use this functionality or not, this might not be a problem. |
Beta Was this translation helpful? Give feedback.
-
A second approach could be to report vertices not just when they have a single, fixed state (e.g., visited), but in several states, together with the state. In order to keep the interface and typing constant, the state could be given as attribute of the traversal. This requires an attribute write (in the lib) and an attribute read (in the application) instead of a function call. |
Beta Was this translation helpful? Give feedback.
-
Both approaches could either be done by adding further parameters to existing functions (callback function or flags demanding additional functionality) or by offering an additional traversal algorithm with the additional features. I do not know so far, which approach in which form is the best for the users... |
Beta Was this translation helpful? Give feedback.
-
Originally posted by @HeWeMel in #12 (comment)
Hello again!
New issue, and now it's real deal, I think. Consider Tarjan algorithm: With DFS, we need to do some work on_leaving node, but how? The only visitor is 'next_something( vert )', and we already leaved it!
So, we in need of 'on_leave(v)'. What we can do (in user code part) now, is everytime leaving vertex, check it's predecessors, possibly all way to root. Not the dream.
Possible solutions:
Beta Was this translation helpful? Give feedback.
All reactions