concept node in category dask

This is an excerpt from Manning's book Data Science with Python and Dask.
Dicing onions, while important, is only a very small part of the whole recipe. To complete the entire recipe, we must define many more steps (or functions). Each of these functions is called a node in a graph. Since most steps in a recipe follow a logical order (for example, you wouldn’t plate the noodles before cooking them), each node can take on dependencies, which means that a prior step (or steps) must be complete before starting the next node’s operation. Another step of the recipe is to sauté the diced onions in olive oil, which is represented by another node. Of course, it’s not possible to sauté diced onions if you haven’t diced any onions yet! Because sautéing the diced onion is directly dependent on and related to dicing the onion, these two nodes are connected by a line.
Figure 1.3 A graph displaying nodes with dependencies
![]()
Figure 1.3 represents a graph of the process described so far. Notice that the Sauté Ingredients node has three direct dependencies: the onion and garlic must be diced and the guanciale must be sautéed before the three ingredients can be sautéed together. Conversely, the Dice Onion, Mince Garlic, and Heat Olive Oil nodes do not have any dependencies. The order in which you complete those steps does not matter, but you must complete all of them before proceeding to the final sauté step. Also notice that the lines connecting the nodes have arrows as endpoints. This implies that there is only one possible way to traverse the graph. It makes sense neither to sauté the onion before it’s diced, nor to attempt to sauté the onion without a hot, oiled pan ready. This is what’s meant by a directed acyclic graph: there’s a logical, one-way traversal through the graph from nodes with no dependencies to a single terminal node.
Another thing you may notice about the graph in figure 1.3 is that no lines connect later nodes back to earlier nodes. Once a node is complete, it is never repeated or revisited. This is what makes the graph an acyclic graph. If the graph contained a feedback loop or some kind of continuous process, it would instead be a cyclic graph. This, of course, would not be an appropriate representation of cooking, since recipes have a finite number of steps, have a finite state (finished or unfinished), and deterministically resolve to a completed state, barring any kitchen catastrophes. Figure 1.4 demonstrates what a cyclic graph might look like.
Figure 1.4 An example of a cyclic graph demonstrating an infinite feedback loop
![]()
From a programming perspective, this might sound like directed acyclic graphs would not allow looping operations. But this is not necessarily the case: a directed acyclic graph can be constructed from deterministic loops (such as
forloops) by copying the nodes to be repeated and connecting them sequentially. In figure 1.3, the guanciale was sautéed in two different steps—first alone, then together with the onions. If the ingredients needed to be sautéed a non-deterministic number of times, the process could not be expressed as an acyclic graph.