Add graph merging

This addresses #15.