flattens graph before processing