Adding graph merge functionality