Graphs and mergesort