Ranking from Pairwise Comparisons in General Graphs and Graphs with Locality