Consequences of Cycles
Most operations on a composite, such as counting its number of leaf nodes, make sense even if the composite is not a tree. Usually, the only difference that nontree composites introduce is that you have to be careful to not operate on a given node twice. However, some operations become meaningless if the composite contains a cycle.
Operations that don't make sense if a composite contains cycles include any behavior that depends on the length of a path in the composite. For example, the height of a tree is the length of the longest path from the root to a leaf. This concept does not apply when cycles appear in a composite, as there is no limit to the length of some paths. In the fireworks process example, there is no “height” ...
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