HPCC-10942 Refactor some of the graph transformations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>