# defining relationship between geometric entities (features)

I have different features located on a plane (2D); I want to define this structure mathematically in a way to represent their relations. Some of features are aligned in horizontally, vertically or diagonally and few are not. Also, some features have same geometric shape. Can I describe this situation using shape grammar or some other similar techniques? Or are there any other ways to describe this structure in geometrically or topologically. Is there a thing called graph-grammar? If so, can I use graph-grammar to describe this structure mathematically?

To get a clear idea, I have drawn the following figure;

Here, based on lower position each features can be aligned {a, b, d, c: H}{f, g, e, h: H }{i: H }{k, l, n: H }{j, m, q, o, p: H} {a, f, i, j: V}{b, g, k, m: V}{c, e, l, q: V}{n, o: V}{d, h: V}{p: V} {a, g, l, o: D}{b, e, n: D}, etc where H-horizontally aligned, V-vertivally aligned & D-digonal aligned

Also, based on shape, features can be grouped {a, b, d: H}{c: H }{f: H }{g, h: H }{e: H }....... {a, f, i, j: V }{m, k, g: V }{b: V }............... or {a, f, i, j,p, d: rectangle }{g, k, m, h: triangle}{c, e, l: circle}{n, q, o: hexagon}

-