refactor ray to work with a partially merged graph