Flatten graph