Manipulating Graphs with Processing
Wednesday, September 3rd, 2008Recently I’ve been looking for a better way to work with representations of graphs, as I’m faced with increasingly complicated examples of cyclotomic matrices. At the moment, I have python code that reads in lists of matrices and returns the graphviz code for their representation. This is a good way to get a quick visual insight into what’s going on, except the rendering isn’t always consistent.
For instance, working with maximal 8-vertex graphs with 4 charges in Q(√-3) there are two known forms:

and

But when I generate an image of all such graphs generated during the growing procedure, I also find a couple of anomalies:

and

Obviously, I need to know whether these are genuinely new forms (and thus new results!) or just a strange representation of the known graphs. If your abstract spatial manipulation skills are good, you might be able to rearrange them in your head; the first, for instance, is pretty easy to recognise as being of the known cubic forms. The second looks temptingly similar to the chain, but in fact is also a cube, which took me quite a bit of drawing on the board to deduce!
The problem is that although graphviz allows several plotting options - all points on a circle, energy minimised etc. - once plotted, the graphs cannot be manipulated. So I wanted to create an interactive tool that would let me move points around until I either recognised the graph in question or was reasonably certain it was something new. This would also allow me to find more aesthetically pleasing representations of known forms; graphviz circular layouts tend to obscure symmetry, for instance.
Fortunately, this provided just the motivation to look into a language I’ve been interested in for some time- Processing. This is a stripped-down interface to java emphasing graphics, and has found application in both data visualisation and mathematical art. As luck would have it, artist, author and processing expert Ira Greenberg was in Edinburgh to give a workshop on its use, so I attended that to pick up the basics: in little over an hour we had simple physics simulations going, so it really is a friendly language!
Here then is a proof-of-concept graph manipulator. At the moment the graph itself is hard-coded; there’s an unusual 8-vertex non-maximal example that occurs only in the Q(√-3) case and ultimately leads to a unique 10-vertex maximal form. I knew it was something new, but found the graphviz representations unhelpful, so wanted to see if I could obtain a better one. After playing for a bit I managed to demonstrate a vertical axis of symmetry, as follows:

But perhaps you can do better? Left click on a vertex to have it follow the mouse; set it down again with a second left click.
