reversing arrays for graph