Coding Logical Graphs
My earliest experiments coding logical graphs as dynamic “pointer” data structures taught me that conceptual and computational efficiencies of a critical sort could be achieved by generalizing their abstract graphs from trees to the variety graph theorists know as cacti. The genesis of that generalization is a tale worth telling another time, but for now it’s best to jump right in and proceed by way of generic examples.
Figure 1 shows a typical example of a painted and rooted cactus.
Figure 2 shows a way to visualize the correspondence between cactus graphs and cactus strings, demonstrated on the cactus from Figure 1. By way of convenient terminology, the polygons of a cactus graph are called its lobes. An edge not part of a larger polygon is called a 2‑gon or a bi‑gon. A terminal bi‑gon is called a spike.
The correspondence between a cactus graph and a cactus string is obtained by an operation called traversing the graph in question.
- One traverses a cactus graph by beginning at the left hand side of the root node, reading off the list of paints one encounters at that point. Since the order of elements at any node is not significant, one may start the cactus string with that list of paints or save them for the end. We have done the latter in this case.
- One continues by climbing up the left hand side of the leftmost lobe, marking the ascent by means of a left parenthesis, traversing whatever cactus one happens to reach at the first node above the root, that done, proceeding from left to right along the top side of the lobe, marking each interlobal span by means of a comma, traversing each cactus in turn one meets along the way, on completing the last of them climbing down the right hand side of the lobe, marking the descent by means of a right parenthesis, and then traversing each cactus in turn, in left to right order, that is incident with the root node.
The string of letters, parentheses, and commas one obtains by this procedure is called the traversal string of the graph, in this case, a cactus string.