Trees in Graph Theory

In a composite structure, we can say that a node that holds references to other nodes is a tree. However, this definition is a bit loose. To be more precise, we can apply a few terms from graph theory to object modeling. We can start by drawing an object model as a graph—a collection of nodes and edges—with objects as nodes and object references as edges.

Consider an object model of an assay, or analysis, of a batch of a chemical. The Assay class has a batch attribute of type Batch, and the Batch class has a chemical attribute of type Chemical. Suppose that a particular Assay object a has a batch attribute that refers to a Batch object b. Suppose too that the chemical attribute of the Batch object b refers to a Chemical ...

Get Design Patterns Java™ Workbook 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.