Fixed adjacency block problems, 2D grid generation and added tree layout toggle

I think that the way the adjacency functions are called might have changed at some point, because there were inconsistencies in their bodies that were causing errors. I've mad small changes to fix these issues, and done a bit of testing to make sure I haven't ruined everything. As far as I can tell all four of these blocks now work as intended. This resolves #226 and resolves #227. 

The 2D generator now works. Resolves #225 

I've added a tree layout button, but the layout itself doesn't display anything yet. 
(I couldn't figure out how to make a pull request without including this, sorry)
Good point about the ===, I'll keep that in mind. For this specific case though, using isFinite() causes problems with because it returns false for strings, so trying to change an edge's colour for example deletes the edge entirely. I think === works best here.