Add template macro to reduce boilerplate in adjacency methods.

Seems like a hideous macro, but I'm not sure how to improve it.