# THIS IS ALL PRETTY OUT OF DATE!!

I'm trying to build an adjacency algorithm for 2D CAD's which will work quickly and be easy to implement. I won't guarantee a solution, but I will guarantee that any solution given is correct. When adjacencies cannot be decided, the algorithm will enumerate the possible adjacencies so that a future extension could use other methods to make these decisions.
• Specifications
I determine adjacencies for amongst cells in 3 successive stacks simultaneously; the second of the three having a section as a base. The main function of the method solves this problem.
c is a section cell in the 1D CAD, c_l is the sector to the left of c, and c_r the section to the right. P is the projection factor set, and J the projection polynomial set. The return value L will be a list of elements of the form ((i,j),(k,l)) indicating an adjacency between cell (i,j) and cell (k,l). More exact information is given below.
• Data Structures
The intent is that the adjacency calculations be based purely on multiplicity information and cell indices. Thus, a cell in the 2D CAD will be represented as a list: (I,M), where I is the cell index, and M is the multiplicity vector; i.e. a list of length = |P_2|, where P_2 is the set of level 2 projection factors, such that the ith element of M is the multiplicity of the ith element of P_2 in the cell. I refer to this as the Adj2D_Cell datatype.
• How It Works
Suppose we start with c_{i-1}, c_i, and c_{i+1} - where c_i is a section cell. Basically I just try to enumerate all possible "solutions" to this adjacency problem, where a "solution" is a list of all adjacencies between sections over c_i and sections over c_{i-1}, and between sections over c_i and sections over c_{i+1}. I have rules about these solutions though, and I throw out all "solutions" which violate these rules. If a unique "solution" is left, then I know I have THE solution. Otherwise, I have to find another method for deciding which of the many solutions is THE solution.

Naturally, I try to be clever, and I don't generate all possible solutions and then weed out the bad ones. I generate only those solutions which don't violate my rules.

• Functions
• Functions for operating on the Adj2D_Cell datatype.
• Misc functions
• Vector functions
• The functions that do the work