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 ...
Get Inside Microsoft® SQL Server™ 2005: T-SQL Querying now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.