Iteration/Recursion
Iterative approaches apply some form of loops or recursion. There are many iterative algorithms that traverse graphs. Some traverse graphs a node at a time and are usually implemented with cursors, but these are typically very slow. I will focus on algorithms that traverse graphs a level at a time using a combination of iterative or recursive logic and set-based queries. Given a set of nodes U, the next level of subordinates refers to the set V, which consists of the direct subordinates (children) of the nodes in U. In my experience, implementations of iterative algorithms that traverse a graph a level at a time perform much better than the ones that traverse a graph a node at a time.
There are several advantages to using iterative ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access