reorder to group nodes and edges together