merge nodes and draw graphs