graphs compact ruby array to remove nil elements